Abstract actor classes can be summoned

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Abstract actor classes can be summoned

Abstract actor classes can be summoned

by Player701 » Thu Nov 21, 2019 1:29 am

ZScript allows defining abstract classes, intended to serve as parents for one or more concrete subclasses with shared logic and/or interface. As in many other programming languages, attempting to create an instance of an abstract class will cause an error:

Code: Select all

class TestClass abstract
{
    static TestClass Create()
    {
        return new('TestClass'); // Error: Cannot instantiate abstract class TestClass
    }
}
While there's no doubt that this behavior is certainly intended, there is also an inconsistency: abstract classes can still be instantiated with the "summon" console command, provided that they inherit from Actor. This should probably not be allowed.

(As a side note, I wish there were real abstract methods in ZScript...)

Top