Re: [Ann] Class meta annotations
Posted by
Henrik Sperre Johansen on
Oct 04, 2017; 9:56am
URL: https://forum.world.st/Ann-Class-meta-annotations-tp4971966p4976211.html
Denis Kudriashov wrote
> 2017-10-04 9:48 GMT+02:00 Guillermo Polito <
> guillermopolito@
> >:
>
>> I'd even call them First class pragmas from that point of view :P
>>
>
> Yes.
> But we decided avoid pragma related names here. Because in future it can
> be
> possible to add normal pragmas into the class definition.
>
>
>>
>> I wonder what are the side-effects of instantiating the annotation
>> yourself in a method.
>>
>> specialAnnotationExample
>>
> <classAnnotation>
>> ^MySpecialAnnotation new
>>
>
> I not understand the question. You supposed to return an *instance* of the
> annotation from the "annotating method".
>
>
>>
>> I mean, I understand we can use the class state to initialize the
>> annotation. But the fact that the annotation is cached after its first
>> instantiation means that the annotation will not necessarily evolve as
>> the
>> class evolves.
>>
>
> Cache is updated after related class changes: method added, removed and so
> on (driven by PragmaCollector logic). So outdated annotations should not
> exist.
> Is it what you ask?
>
>
>> Do we want annotations to be stateless? Or depend only in literals?
>>
>
> I want annotations to be any object with any state inside. Of course you
> will be restricted by what is visible from the class side. But in
> "annotating method" you can create any complex object (see below).
>
>
>> I wonder then what is the main difference with
>>
>> specialAnnotationExample
>>
> <classAnnotation: MySpecialAnnotation>
>>
>> And what is the impact of having an annotation with parameters.
>>
>
> Generally it is same like having pragma with parameters.
> But with annotation you are not restricted by literal objects. So
> annotation parameters can be anything.
>
> And it is important feature for Commander.
> For example I need instance of KMKeyCombination to define shortcut for
> command. So I just use normal expression for this:
>
> RenamePackageCommand class>>packageBrowserShortcutActivation
> <classAnnotation>
> ^CmdShortcutCommandActivation by: *$r meta* for: ClyPackageBrowserContext
>
>
> It will be very complicated to express it with method pragma and it will
> be
> restricted anyway.
Would it?
With pure method tags, you'd do something like:
SomeClass >> #renamePackage: aPackage
<command: 'Rename package'
category: 'Package'
order: 25
shortcut: #($r meta)>
... method renaming package here ...
Then have different pragma traversers capable of creating the actual menus /
commands invoking such methods.
(And yes, all caching/invalidation would be the responsibility of the
traverser(s) if necessary, as usual)
Cheers,
Henry
--
Sent from:
http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html