Subclassing with new syntax
| Project: | GNU Smalltalk |
| Component: | Base classes |
| Category: | feature |
| Priority: | normal |
| Assigned: | bonzinip |
| Status: | fixed |
Hi!
I've been wondering how to subclass classes
like String and Dictionary. How do I do it with
the new syntax? Using:
String subclass: MyString []
didn't seem to work.
Updates
It works:
st> String subclass: MyString [] st> MyString MyString
but you have to set the shape:
st> MyString shape nil
I might add a <shape: #inherit> pragma. It's good that the default is nil, because each class should set its shape manually (or tell that it's fine to use the superclass shape).
| Assigned to: | Unassigned | » bonzinip |
| Status: | active | » fixed |
> I think elmex's issue is really about the inability to specify variable subclasses
> of any shape; for example
st> MyString withAll: #($a $b) Object: MyString error: should not be implemented in this class, use #new instead
> Will the aforementioned pragma have a way to make classes traditional ST-80
> variable classes as well?
That's already supported with for example <shape: #pointer>. Shapes were introduced in gst 2.2 and the converter automatically converts variableSubclass: and friends to the appropriate shape pragma. See also the tutorial.
