[squeak-dev] Re: Re: pragmas usage
Trygve Reenskaug
trygver at ifi.uio.no
Thu Mar 20 08:11:23 UTC 2008
Pragmas has given me a powerful hook into the Compiler/Parser complex. I
may be misusing them, but my experiment worked and gave me the insights
I needed into the relationships between static and dynamic variables.
A small and simple extension to the Parser made it generate in-line code
for special pragmas. (Thanks to Klaus for helping me with this). An
example method:
*animateStars *
" Add and remove stars randomly, trying to keep total number of
stars = 'numberOfStars' "
<Role: /#*Collab*> /<Role: /#*StarsCount*>/
[maestro currentState == #STARS] whileTrue:
/[*Collab */refresh.
/*StarsCount */>= maxNumberOfStars ifTrue: [self deleteStar].
/*StarsCount */<= maxNumberOfStars ifTrue: [self placeStar]]
The Parser extends role variable names such as /*StarsCount */into
self playerForRole: /#*StarsCount*/
which looks up the binding for /#*StarsCount */in a dynamic name space.
(The name space object lives on the stack)
This was just a step in a larger experiment; more later.
--Trygve
On 19.03.2008 14:57, itsme213 wrote:
> "Ramon Leon" <ramon.leon at allresnet.com> wrote in message
>
>
>> Pragmas are static and aren't nearly as flexible as
>> Magritte descriptors, which are real objects and don't face the
>> limitations
>> of pragmas.
>>
>
> Perhaps it need not be either-or? e.g. The pragma could be evaluated to
> record the "static" descriptions on the classes as any kind of real objects,
> including Magritte-like Descriptions:
>
> Foo>>x
> <setUpMeta: #bar>
>
> PragmaInterpreter>>setUpMeta: aSymbol for: aClass
> aClass recordMeta: aSymbol
>
>
> And there could still be instance-level access from objects, which by
> default just uses the "static" descriptions that PragmaInterpreter recorded
> on the classes, but has a hook for dynamic (instance-specific) behavior:
>
> Object>>getMeta: aSymbol
> (self class getMeta: aSymbol)
> overridenBy: (self dynamicGetMeta: aSymbol)
>
> Just a thought.
>
> - Sophie
>
>
>
>
>
>
--
Trygve Reenskaug mailto: trygver at ifi.uio.no
Morgedalsvn. 5A http://heim.ifi.uio.no/~trygver
N-0378 Oslo Tel: (+47) 22 49 57 27
Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080320/746537f1/attachment.htm
More information about the Squeak-dev
mailing list
|