Example A-SIGNATURES Re: A Way to express Standard multi-argument
Method Signatures in Smalltalk Re: [ANSI-Smalltalk] Next STEPs
Panu Logic
panulogic at gmail.com
Wed Mar 12 08:26:02 GMT 2008
Paolo Bonzini wrote:
>
>> 2. A result type written as 'self'
> That should be #self for obvious reasons. Misunderstanding the
> scoping of variables (special variables like self included) is one of
> the most common mistakes in design Smalltalk DSLs.
If you take the example (about "Message") and embed it in a method
of the
class Message, you'll see that even 'self' within it compiles correctly.
This is because in (most?) ST-class-browsers you can evaluate 'self'
within a method,
and it will refer to the current class. This makes sense because the
method is defined
by that class, not by its instance.
Thus, I should have been more precise about the interpretation of 'self'
in "A-Signatures": It refers to the class whose method-signatures OR
whose meta-class signatures we are specifying.
You could expect that in a class-side method 'self' should evaluate to
the meta-class, not the class, but this seems not to be the case.
Therefore I believe it's best to abide by this convention - because
it makes it possible to evaluate these signatures in any standard
browser easily.
I can see a system where the method-signatures of a class could actually be
coded into a method called #SIGNATURES by the programmer. Upon saving
such a method, the system could automatically generate a set of unit-tests
that verify the class indeed is in conformance with its declared types.
BTW. For the standards effort, I think it is definitely a good thing if
we can provide a Standard from which a large portion of the unit-tests
can be automatically generated, easily (i.e. no need to write a parser
for that).. There's still a plenty of 'semantic' tests left to write by
hand.
Smalltalk doesn't require type-declarations, which is good, but I think
they
are a great optional tool for generating unit-tests, as well as for
specifying
the protocols of abstract (and Standard-) classes - plus for programmer-
communication in general.
The Romans had it hard because they didn't have a language for
expressing ZERO, whereby their language for communicating
any large numbers became ridiculously difficult. We Smalltalkers
have been hindered for some time by the fact that there hasn't
been a standardized, succinct language for expressing method-
signatures in Smalltalk. I can only conjecture that this must be
one of the reasons why there haven't been real convergence
between the different ST-dialects.
>> 4. Each class used within the expressions is part of the standard.
> The biggest problem is that the standard talks about instance
> protocols and factory protocols (accessed with global variables), not
> about classes and metaclasses.
If that's the biggest problem, we're lucky. Simply change the words we
use, either way.
Thanks
-Panu Viljamaa
More information about the ANSI-Smalltalk
mailing list