Something like
(define abcproperty-accessor (native-lambda (native-object) int "___result = ___arg1.abcproperty;"))
(define o (new Object))
(define abcproperty (abcproperty-accessor o))
?
2015-12-08 0:44 GMT+08:00 ben yakawp ben.lists@yakawp.com:
Just to be a little more precise. Expressing OO style in Scheme was not my primary concern here. The problem I see is that the all of the host languages (except the original C backend) access their library functions through an OO interface. It's not like the library approach in scheme were you can directly use a function after you imported it.
That means if you want to use a function from a host language you first have to create an object. But now what is this object in Scheme and what can it do? In the best case, it would check the member calls at compile time. In the worst case it add runtime cost in the backend.
But thats just stuff I was thinking about.
What I wanted to know in the first place is how I should accessing backing library functions / ffing that are "hidden" behind OO apis. How is this done?
On Mon, Dec 7, 2015, at 05:13 PM, Marc Feeley wrote:
At the Scheme level, you can express the OO style in various ways. Here are 2 that come to mind:
- 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")
- 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@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@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list