guile-user
[Top][All Lists]
Advanced

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

define - any name


From: Egil Moeller
Subject: define - any name
Date: Sat, 19 Apr 2003 09:22:05 +0200 (CEST)

At the moment, I have a function (list-entry type name), that given a
"type-definition" (a binary tree with names in), and a name, constructs a
function that will extract the entity at the position corresponding to
that name in the type, in a binary tree given as argument. The
"type-definition" i often constructed from other such definitions:

(define fride-vote-msg-type
  `(list
    (id:         ,fride-id-msg-type)
    (referendum: ,fride-id-reference-msg-type)
    (date:       int)
    (vote:       int)))

I use the list-entry function, then to construct a set of
"access-functions", e.g.

(define fride-vote-list.id (fride-list-entry fride-vote-msg-type 'id))
(define fride-vote-list.referendum (fride-list-entry fride-vote-msg-type 
'referendum))

This is both quite some extra work, and also makes the code clumsier, than
if those functions could be automatically created. I'd like to write
something like

(define-type fride-vote-msg-type
  `(list
    (id:         ,fride-id-msg-type)
    (referendum: ,fride-id-reference-msg-type)
    (date:       int)
    (vote:       int)))

and have them all created. For this purpose I have created a function that
finds all names in a type-definition that can be used to create such
access-functions.

The question i, how do I go on from here? I'd like to make a macro, but
that would not let the backqoute be evaluated in the correct
environment... What I would need is a (define-unquoted-in-toplevel name
value), that would work like an ordinary funcion, evaluating its
arguments, and bind the value of name to the value of value, in the
top-level surrounding environment... Is this really not something people
have wanted before?

My idea about environments in quile is that they, due to speed
considerations or something, are a bit too limited... For example, an
eval-closure is _not_ an ordinary environment/can't be treated like one,
and one can not do (eval) with such an object as environment...

Regards,
Egil

-- 
http://redhog.org
GPG Public key: http://redhog.org/PGP%20Public%20key.asc
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!





reply via email to

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