[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: procedure-source availability
From: |
Ludovic Courtès |
Subject: |
Re: procedure-source availability |
Date: |
Sun, 07 Oct 2012 22:36:58 +0200 |
User-agent: |
Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) |
Hello!
Panicz Maciej Godek <address@hidden> skribis:
> Well, the problem is that I don't yet know what I am doing, so I'm
> trying to keep the system as general as possible. One of the features
> that is certainly going to be needed anyway, is a way to store and
> restore lambdas, because this is the essential abstraction mechanism
> of Scheme. Maybe some separate layer for GUI description will emerge
> later on, but the task that I assigned to myself seems worth exploring
Yeah. Scheme allows you to create the “essential abstraction mechanism”
that you like best anyway. :-)
[...]
>> The (oop goops save) module implements parts of a serialization
>> framework. When GOOPS is loaded, any Scheme object is a GOOPS instance,
>> so one could define methods to serialize any type of object.
>
> It looks interesting, but I somehow can't get it to run, even for very
> simple cases:
[...]
> Besides this, it looks similar to the thing I'm working on, so if I
> get far enough, then perhaps my results could be incorporated into
> that framework? (It requires some labour though, as there are many
> types to be considered
Yes, that’s what I had in mind. :-)
[...]
>> Note that this doesn’t make ‘self’ a reserved keyword; instead, it’s
>> just a local variable that cannot be referred to by name in BODY, thanks
>> to the macro hygiene rules.
>
> Yes, you're right.
> I even went a little further with that and now I also capture lexical
> environment:
> (use-modules (system syntax) (ice-9 local-eval))
>
> (define-macro (function args . body)
> `(let ((environment (the-environment))
> (lexical-names (lexical-names))
> (procedure (lambda ,args ,@body)))
> (set-procedure-property! procedure 'source '(function ,args ,@body))
> (set-procedure-property! procedure 'environment environment)
> (set-procedure-property! procedure 'lexical-names lexical-names)
> procedure))
>
> (where ``lexical-names'' returns the car-s of ``lexicals'', as defined
> at the bottom of
> http://www.gnu.org/software/guile/manual/html_node/Syntax-Transformer-Helpers.html#Syntax-Transformer-Helpers
> )
>
> So in addition to the source of the procedure, the lexical environment
> can also be retrieved:
>
> (define (procedure-lexicals proc)
> (map (lambda(symbol)
> (cons symbol
> (local-eval symbol (procedure-property proc 'environment))))
> (procedure-property proc 'lexical-names)))
I don’t want to sound too dogmatic, but I think you really don’t want to
take that route. ;-)
The issues with ‘local-eval’ have been discussed at length a year ago or
so on guile-devel. Basically, the problem is that it plays badly with
compilation, and there are usually nicer way to achieve what you want.
HTH,
Ludo’.
- Re: procedure-source availability, Panicz Maciej Godek, 2012/10/01
- Re: procedure-source availability, Ludovic Courtès, 2012/10/02
- Re: procedure-source availability, Panicz Maciej Godek, 2012/10/02
- Re: procedure-source availability, Daniel Hartwig, 2012/10/02
- Re: procedure-source availability, Panicz Maciej Godek, 2012/10/03
- Re: procedure-source availability, Ludovic Courtès, 2012/10/04
- Re: procedure-source availability, Panicz Maciej Godek, 2012/10/06
- Re: procedure-source availability,
Ludovic Courtès <=
- Re: procedure-source availability, Panicz Maciej Godek, 2012/10/08
- Re: procedure-source availability, Mark H Weaver, 2012/10/08
- Re: procedure-source availability, Ludovic Courtès, 2012/10/04