Hi,

Volker wrote:

> If class:
...
> a more efficient way is to use a method-object, like
> faces do.
> then you have
> 
> a-handler: context [
> type: "a-handler"
> add: func [this increment] [this/value: this/value +
> increment]
> ; ^ note we pass 'this explicitely
> ]
> a-class: context [handler: a-handler a: none]
> a-object: make a-class [value: 5]
> a-object/handler/add a-object 3
> 
> the call-syntax is not very handy, 
> but complete /view-styles are based on this system.
> Usually there is a dispatch-function, so that one can
> write
> ao-add: func[this incr][this/handler/add this 3]
> ao-add a-object 4
> 
> see 'do-face in /view, 
> or 'show, which dispatches to face/feel/redraw and does
> some more work.

An universal dispatcher can be written as
follows:

msg: func [
    {simple message dispatcher}
    [throw]
    message [block!]
] [
    use [this method call] copy/deep [
        set [this message] do/next message
        method: first message
        message: next message
        if not path? method [method: to path! method]
        insert method 'this/handler
        call: make block! 2 + length? message
        insert/only call method
        insert tail call this
        insert tail call message
        do call
    ]
]

Instead of writing:

     a-object/handler/add a-object 3

we can use the above dispatcher and write:

    msg [a-object add 3]


-- 
Eurotel Data Nonstop - Neomezený přístup na internet již od 799
Kč měsíčně!
http://www.eurotel.cz/site/cz/servicesAndTariffs/specialOffer.html?list=34995



-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to