Hi Doru,

> On Jun 27, 2016, at 3:52 AM, Tudor Girba <tu...@tudorgirba.com> wrote:
> 
> Hi,
> 
> The CompiledMethod already has a way to retrieve Pragma instances:
> 
> CompiledMethod>>pragmas.
> 
> However, the Pragma instance does not have a meta-object associated with it. 
> So, I would first start from adding that one and linking such a PragmaType to 
> its instances. The important thing here would be that all Pragma instances 
> with a certain selector should reference the same PragmaType.

Let me express a dissenting opinion.  Our pragma system is minimal yet 
powerful. By using Message instances (with literal arguments) to represent 
pragmas we get
- executable pragmas that can be applied using perform: or wrappers such as 
sentTo:
- we can use conventional browsing queries (implementors and senders) to 
discover which methods are marked by a specific pragma and what 
pragma-processing tools implement a specific pragma.
- a rich pragma language that can have many, named parameters
- a system which doesn't need its own language, but reuses the existing 
Smalltalk parsing facilities, and so is easier to learn and to implement

So its parsimony is an important part of its virtues.  It is minimal.

One thing missing from the Squeak/Pharo implementation is the set of legal 
pragmas a class accepts.  In VisualWorks a class implements the <pragma: 
#pragma:selector:> (it might be <pragmas: #(pragma:selector:one: 
pragma:selector:two:)>) to define the legal set of pragmas.  [Implementation 
note, these are /not/ searched for ahead of compilation; instead, the parser 
delays searching for class-side methods containing pragma: pragmas until it 
encounters a pragma, and it searches for all class side methods, including in 
superclasses).

This scheme allows pragmas to be checked; only pragmas in the set of allowed 
pragmas are accepted, and it allows collision-free extensibility; any package 
can add a set of legal pragmas to a class merely by choosing a method selector 
that won't collide with any other containing pragma: pragmas, eg
kernelPragmas
    <pragma: #primitive:>
    <pragma: #primitive:error:>
    <pragma: #primitive:module:>
    <pragma: #primitive:module:error:>

We're missing this, which means our compilers don't safely check for valid 
pragmas and can't reject invalid or unrecognized ones, which is error prone.

If we implemented this then we would have a natural place to comment pragmas in 
the method that defines a particular pragma, one that would be found using 
senders.

None of this requires a meta object.  It is perfectly recursive; using itself 
to implement itself.  I find this very elegant (I didn't invent pragma: 
pragmas; Steve Dahl did, and it's a cool idea).

So as an inventor of pragmas I'd like to ask for the minimal implementation 
outlined above.  I'd like that we didn't j tricycle a specific meta object, 
with all the additional tools that implies, and instead stick to the minimalist 
and parsimony of the original design and use pragmas to comment pragmas.

> Cheers,
> Doru

Thanks for reading.
Cheers, Eliot

>> On Jun 27, 2016, at 12:34 PM, Denis Kudriashov <dionisi...@gmail.com> wrote:
>> 
>> 
>> 2016-06-27 12:12 GMT+02:00 Tudor Girba <tu...@tudorgirba.com>:
>> Hi,
>> 
>> That is my proposal as well: introduce a first class entity that describes a 
>> Pragma instance. Who would be interested to play with this?
>> 
>> How it could be done? 
>> Probably compiler could search preferred Pragma class for given selector. 
>> And then we will have collection of real pragma instances inside 
>> CompiledMethod. What do you think?
> 
> --
> www.tudorgirba.com
> www.feenk.com
> 
> "Be rather willing to give than demanding to get."
> 
> 
> 
> 
> 

Reply via email to