Subclassing dictionary

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Subclassing dictionary

Tim Felgentreff
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

Trying to port the Squeak JSON package I came across rather strange behaviour. One of the classes, JsonObject, is a subclass of dictionary. I noticed that subclassing Dictionary would throw an error:

st> Dictionary subclass: JsonObject [
st> ]
st> JsonObject new
Object: JsonObject error: should not be implemented in this class, use #basicNew instead
SystemExceptions.WrongMessageSent(Exception)>>signal (ExcHandling.st:254)
SystemExceptions.WrongMessageSent class>>signalOn:useInstead: (SysExcept.st:1248)
JsonObject class(Behavior)>>basicNew: (Builtins.st:84)
JsonObject class(HashedCollection class)>>primNew: (HashedColl.st:44)
JsonObject class(HashedCollection class)>>new: (HashedColl.st:62)
JsonObject class(Dictionary class)>>new (Dictionary.st:70)
UndefinedObject>>executeStatements (a String:1)
nil

"Dictionary new" works as expected:

st> Dictionary new
Dictionary new (
)
st>

I don't understand the problem here, can somebody please shed some light on this?
Thanks
Tim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAkweQJkACgkQLbWJItnd6CwHewCgh+hp8oVie3ilYu5eV8duCIpV
CMkAmwUueUm6OYnCPLBanVLCV3zg153u
=IFIX
-----END PGP SIGNATURE-----

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Subclassing dictionary

Paolo Bonzini-2
> Trying to port the Squeak JSON package I came across
> rather strange behaviour. One of the classes, JsonObject, is
> a subclass of dictionary. I noticed that subclassing Dictionary
> would throw an error:

This is the same that you get in Squeak if you use #subclass: instead
of #variableSubclass: etc.

You can put this in the body of the class:

    <shape: #inherit>

and it will fix the problem.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk