I am looking for some good examples of using pragmas to learn how to use
them well. Found some good ones in Ramon's code, but few others in the 3.9 image. Looking for some more. Any pointers appreciated. Thanks - Sophie |
> I am looking for some good examples of using pragmas to learn how to use
> them well. Found some good ones in Ramon's code, but few others in the 3.9 > image. Looking for some more. Any pointers appreciated. <primitive:> and <primitive:module:> are (a bit special) examples and they come with every image. If the Compiler/Parser encounters such pragmas in the source code it dispatches the pragma to the Parser class to create a primitive method. In short the strategy is like this: - You query for some Pragma using the class-side protocol of the Pragma class. - You iterate over these objects and dispatch them to some handler/interpreter object. aCollectionOfPragma do: [ :each | each message sendTo: handler ] HTH, Lukas -- Lukas Renggli http://www.lukas-renggli.ch |
"Lukas Renggli" <[hidden email]> wrote in message
> - You iterate over these objects and dispatch them to some > handler/interpreter object. > > aCollectionOfPragma do: [ :each | each message sendTo: handler ] Thanks! |
In reply to this post by Lukas Renggli
"Lukas Renggli" <[hidden email]> wrote in message
> - You query for some Pragma using the class-side protocol of the Pragma > class. If pragmas were available when you started developing Magritte, I am curious if and why you might have used them (or not)? Sophie |
2008/3/16, itsme213 <[hidden email]>:
> "Lukas Renggli" <[hidden email]> wrote in message > > > - You query for some Pragma using the class-side protocol of the Pragma > > class. > > > If pragmas were available when you started developing Magritte, I am curious > if and why you might have used them (or not)? MAPragmaBuilder Cheers Philippe |
In reply to this post by Sophie424
> > - You query for some Pragma using the class-side protocol of the Pragma
> > class. > > If pragmas were available when you started developing Magritte, I am curious > if and why you might have used them (or not)? Certainly I would have used them. This could have avoided those ugly naming conventions for the descriptions. The problem is that there is still a lot of industrial code in Squeak 3.7 and 3.8 that depends on Magritte. As Philippe pointed out there was MAPragmaBuilder. I never used it in Pier, due to backward compatibility concerns. Lukas -- Lukas Renggli http://www.lukas-renggli.ch |
> > If pragmas were available when you started developing
> Magritte, I am > > curious if and why you might have used them (or not)? > > Certainly I would have used them. This could have avoided > those ugly naming conventions for the descriptions. The > problem is that there is still a lot of industrial code in > Squeak 3.7 and 3.8 that depends on Magritte. > > As Philippe pointed out there was MAPragmaBuilder. I never > used it in Pier, due to backward compatibility concerns. > > Lukas You'd have used them for pointing to descriptions to avoid naming conventions, but I think what Sophie's getting at is what you think of pragmas as a meta layer instead of descriptions to embed the metadata directly into accessors. Sophie, if you haven't already, I'd recommend you read his thesis on Magritte, it'd probably answer many questions about why Magritte made certain design choices. Pragmas are static and aren't nearly as flexible as Magritte descriptors, which are real objects and don't face the limitations of pragmas. Ramon Leon http://onsmalltalk.com |
"Ramon Leon" <[hidden email]> 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 |
> "Ramon Leon" <[hidden email]> 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 I'm sure you could, but I wouldn't, I prefer my metadata to be static. It's a cross language approach that allows me to use the same techniques in .Net (still the majority of my job), which also has pragmas (called attributes). I also prefer the ad-hoc nature of pragmas, I can just make them up as I need them without the need to try and fit them into a big description hierarchy. Ramon Leon http://onsmalltalk.com |
In reply to this post by Sophie424
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: animateStarsThe Parser extends role variable names such as StarsCount into self playerForRole: #StarsCountwhich 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" [hidden email] wrote in messagePragmas 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: [hidden email] Morgedalsvn. 5A http://heim.ifi.uio.no/~trygver N-0378
Oslo Tel: (+47) 22 49 57 27 Norway |
Free forum by Nabble | Edit this page |