About Smalltalk at: .... ifAbsent:/present:
Blake
blake at kingdomrpg.com
Wed Dec 1 00:11:15 UTC 2004
OK, humor me on this, I'm trying to follow along.
In Smalltalk, as in most other OO languages, when you describe a class
that requires another class, you do so with a specific, explicit reference:
myVar := SomeClass new.
Your object is now dependent on SomeClass. In compiled languages, this
isn't a big deal because, hey, your code ain't gonna compile if SomeClass
isn't available. (With some exceptions for dynamically loaded libraries, I
suppose.)
But in Smalltalk, where formal parameters are untyped and the called code
doesn't, in fact, care what's been passed to it as long as it can answer
the right messages. Smalltalk doesn't do anything to check this until
runtime, either.
So this sort of begs the question (to me) of why the class needs to be
dependent. We could, of course, allow the client to set myVar rather than
doing it in the code, but why couldn't SomeClass be defined as "any class
that supports the interface I need to operate"? That would really be more
Small-talky than what currently exists.
That might exacerbate the whole absent/present thing, dunno.
More information about the Squeak-dev
mailing list
|