[Pharo-dev] [Pharo4] MetaLinks on Slots

Clara Allende clari.allende at gmail.com
Mon Jul 21 05:41:14 EDT 2014


Super cool, and then we have to integrate with the metaLink based
breakpoints (almost there), and we can start a party :D


2014-07-21 11:33 GMT+02:00 Tudor Girba <tudor at tudorgirba.com>:

> Man, this is exciting!
>
> A strong reason to already switch to Pharo 4 :)
>
> Doru
>
>
> On Mon, Jul 21, 2014 at 11:28 AM, Marcus Denker <marcus.denker at inria.fr>
> wrote:
>
>> Hello,
>>
>> One of the questions with having meta objects for variables (Slots and
>> Globals) is: For what is is good?
>>
>> Here is one example… in early stage but working.
>>
>> Imagine you want to “hook into” instance variable access. It can be done
>> with e.g. bytecode manipulation, or
>> on the AST level. But that is far from nice.
>>
>> With the new first class variables, there is now a fun way to do it:
>> MetaLinks.
>>
>> Make a class TT with an instance var “t” and add an accessor.
>>
>> Now we can define a MetaLink: it describes a call to a meta object that
>> we wan to do before, after or instead
>> of what our variable normally does. (default is #before):
>>
>> | link |
>> link :=  MetaLink new
>>         metaObject:  Halt;
>>         selector: #now.
>>
>> This link says: “do a Halt now before where I will get installed”.
>>
>> To install the link, just get the Slot meta object and set it using #link:
>>
>> (TT slotNamed: #t) link: link.
>>
>> This sets the link by replacing the Slot with a LinkWrapper Slot, and
>> then recompiles all using methods.
>>
>> Thus evaluating:
>>
>>         TT new t
>>
>> will get you a #halt.
>>
>> Lots of things are not yet implemented (multiple links, uninstall,
>> arguments,…)
>> but it starts to show how simple one can do quite powerful things.
>>
>>         Marcus
>>
>>
>>
>>
>
>
> --
> www.tudorgirba.com
>
> "Every thing has its own flow"
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20140721/bf04006a/attachment-0002.html>


More information about the Pharo-dev mailing list