[gambit-list] How to handle and access and interact with object members host code

Dimitris Vyzovitis vyzo at hackzen.org
Sun Dec 13 06:39:23 EST 2015


Or you can do what we use in gerbil:
{print o "hello"}

reader translates to (call-method 'print o "hello")

-- vyzo

On Mon, Dec 7, 2015 at 5:13 PM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
> At the Scheme level, you can express the OO style in various ways.  Here are 2 that come to mind:
>
> 1) Your “new” operator could return a closure which receives as a first parameter the name of the method to be called.  So you could:
>
> (define o (new Lib))
> (o print: "hello")
>
> or
>
> (define .print '.print)
> (o .print "hello")
>
> 2) You could make .print a function that receives as a first parameter the object on which the method applies.  For example:
>
> (define .print (lambda (self text) …))
> (define o (new Lib))
> (.print o "hello")
>
> You can of course use macros to automate these styles.
>
> Marc
>
>> On Dec 7, 2015, at 8:31 AM, ben yakawp <ben.lists at yakawp.com> wrote:
>>
>> hi
>> Sorry if this too obvious, but I don't understand how gambit handles
>> objects from the hosts backend.
>>
>>
>> For example: if one would like to construct a 'Node' library for the JS
>> backend, how would you do that? The whole node api seems to be object
>> oriented.  But also the Python standard libaries (batteries) are layed
>> out class based. You had to do something like
>>
>> (define o (new Lib))
>> (o.print "hello")
>>
>> This looks wrong. What am I missing?
>>
>> Regards
>> ben
>> _______________________________________________
>> Gambit-list mailing list
>> Gambit-list at iro.umontreal.ca
>> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list



More information about the Gambit-list mailing list