Ciao, Gabriele,

you wrote:

To create simpler methods, why not binding them to the right
object at the right time?

Something like:

!: func [
    object [object!]
    'method [word!]
    /local mth
] [
    ; let's skip error checking for clarity
    mth: get in object/methods method
    bind second :mth in object 'self
    return :mth
]

- a nice idea. The problem here is that this approach is static, i.e.
non-re-entrant, because it uses only static storage for object parameter,
namely the code block of method, so your code wouldn't work for something
like this too:

a: make object! [
    num: 1
    methods: make object! [
        sumnum: func [other number] [
            switch number [
                1 [self/num]
                2 [ (do ! other sumnum self 1) + (do ! self sumnum other
1) ]
                ]
            ]
        ]
    ]

Ladislav




Regards,
    Gabriele.
--
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC     \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o



Reply via email to