Posted by
Henrik Sperre Johansen on
Oct 04, 2017; 12:34pm
URL: https://forum.world.st/Ann-Class-meta-annotations-tp4971966p4976289.html
Denis Kudriashov wrote
> 2017-10-04 11:56 GMT+02:00 Henrik Sperre Johansen <
> henrik.s.johansen@
>>:
>
>> Denis Kudriashov wrote
>> > 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.
>>
>
> So instead of simple subclassing of ClassAnnotation you would suggest me
> to
> implement pragma traversal/interpreter?
> I would prefer first. It gives me for free the object with any structure
> without any tricky literal interpretation logic.
> For me annotation is just obviously simpler solution.
A traverser doesn't have to be a lot of work;
http://forum.world.st/Having-comments-for-pragma-tp4902987p4903058.htmlDenis Kudriashov wrote
> Also try to think how to support blocks in parameters with pragma
> approach.
> And how fun would be to debug them.
> It is for the question about
> "restricted anyway".
You wouldn't need them. What to do with the tag, is up to the traverser.
For instance, #perform'ing one of the literal args on the domain class
traverser creates, returning an appropriate block, if strictly necessary.
Denis Kudriashov wrote
> Really, with annotations you have normal smalltalk
> code for annotating classes. No magic. And implementation is really
> simple.
Same with a traverser; the normal smalltalk code to create your domain
objects is simply in a different place; the traverser part of the package
defining said domain, rather than as an extension method marked with a tag.
I guess it's best to just agree to disagree, and since you're the one
implementing... ;)
Looking forward to trying it out!
Cheers,
Henry
--
Sent from:
http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html