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 <[email protected]>
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"

Reply via email to