chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] External procedures at runtime


From: felix winkelmann
Subject: Re: [Chicken-users] External procedures at runtime
Date: Tue, 24 Jul 2007 08:32:14 +0200

On 7/24/07, John Cowan <address@hidden> wrote:
felix winkelmann scripsit:

> What exactly do you mean with "externally callable". Do you mean
> that it should be possible to recognize procedures defined with
> "define-external"?  This shouldn't be too hard: the lolevel unit has
> some functions for decorating procedures with arbitrary data and a
> custom variant macro of "define-external" could then expand into the
> normal define-external + decorator code.

That sounds good.  (BTW, there doesn't seem to be any way for a
extended procedure to get hold of its *own* data, unless of course
you pass it to itself as an argument.  This would be a good thing
to fix.)

You could also use "letrec" to refer to the procedure itself from inside
the procedure.


Okay, then the next issue is that there is no obvious way, given
a procedure, to pass it through the C interface: there is no
procedure type.

But a type of generic, unconverted Scheme data. The "scheme-object"
type passes the procedure directly (see also [1]). The actual extension
data is stored in the closure slots:

; loading library posix ...
; loading library srfi-1 ...
; loading library srfi-13 ...
#;1> (define (foo) 1)
#;2> ,d foo
procedure with code pointer b7c258d3 of length 3
0: #<procedure (f_4077 . v377)>
1: ()
2: #<lambda info (foo)>
#;2> (use lolevel)
; loading library lolevel ...
#;3> (extend-procedure foo "hello")
#<procedure (foo)>
#;4> ,d #
procedure with code pointer b7c258d3 of length 4
0: #<procedure (f_4077 . v377)>
1: ()
2: #<lambda info (foo)>
3: (#(extended) . "hello")
#;4>


cheers,
felix


[1] http://chicken.wiki.br/Data%20representation




reply via email to

[Prev in Thread] Current Thread [Next in Thread]