Fix meta_class, sis class instance variables and class methods
after some serious recursive thinking it now actually makes sense. The key was to change the actual type of the class that the meta_class manages For objects it's (still) ok just to change the instance_type, but since the class object exists and has type, when adding instance variables, that actual type has to change
This commit is contained in:
@ -1,8 +1,17 @@
|
||||
# Behaviour is something that has methods, basically class and modules superclass
|
||||
|
||||
# instance_methods is the attribute in the including class that has the methods
|
||||
|
||||
module Parfait
|
||||
# Behaviour is the old smalltalk name for the duperclass of class and meta_class
|
||||
#
|
||||
# Classes and meta_classes are in fact very similar, in that they manage
|
||||
# - the type of instances
|
||||
# - the methods for instances
|
||||
#
|
||||
# The main way they differ is that Classes manage type for a class of objects (ie many)
|
||||
# whereas meta_class, or singleton_class manages the type of only one object (here a class)
|
||||
#
|
||||
# Singleton classes can manage the type/methods of any single object, and in the
|
||||
# future off course they will, just not yet. Most single objects don't need that,
|
||||
# only Classes and Modules _always _ do, so that's where we start.
|
||||
#
|
||||
class Behaviour < Object
|
||||
|
||||
attr_reader :instance_type , :instance_methods
|
||||
|
@ -43,6 +43,12 @@ module Parfait
|
||||
inspect
|
||||
end
|
||||
|
||||
# adding an instance changes the instance_type to include that variable
|
||||
def add_instance_variable( name , type)
|
||||
super(name,type)
|
||||
@clazz.set_type(@instance_type)
|
||||
end
|
||||
|
||||
# Nil name means no superclass, and so nil returned
|
||||
def super_class
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user