unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Alp Öztarhan" <alp@uludag.org.tr>
Cc: tomas@fabula.de
Subject: Re: [Fwd: Req for help on objects and environments]
Date: Thu, 02 Sep 2004 15:47:46 +0300	[thread overview]
Message-ID: <1094129266.4098.25.camel@kuzgun> (raw)
In-Reply-To: <20040902115316.GB30187@www>

Thank you very much for caring to write. But I still do not have the
answers yet.

On Thu, 2004-09-02 at 14:53, tomas@fabula.de wrote:
> AFAIK eval takes an expression and a module (which is an environment)
> to eval the expression in. I don't quite understand your problem.
> Could you give some examples?

The question about environments is this: I have an alist that contains
my "variables". Say '((a . 3) (b . 5)). T want to be able to "eval" an
expression, say '(+ a b), in an environment where a has value 3, b has
value 5. For that, I have to manipulate an environment (null-environment
maybe?) and put a and b as variables, with values 3 and 5 respectively.
How can I manipulate the environment?

Second, how do I get a null-environment? (Or any environment I can
manipulate) It is in R5RS, but guile initially does not have it. I
suspect it may be in an ice-9 module, but how can I find out which one?
(Or maybe in SLIB?)

How do I find out which variables an environment contains. Maybe I
should ask: what is an "environment"? It is _not_ an alist. How can I
play with it?

> > 4) I also want to use the (make-object-property) scheme procedure.
> >    Unfortunately, I cannot list the properties of a given object.
> 
> Like this?
> 
>  | guile> (define x 42)
>  | guile> (set-object-property! x 'colour 'green)
>  | green
>  | guile> (set-object-property! x 'size 42)
>  | 42
>  | guile> (set-object-property! x 'friends '(alfred bert carol))
>  | (alfred bert carol)
>  | guile> (object-properties x)
>  | ((friends alfred bert carol) (size . 42) (colour . green))
>  | guile> (object-property x 'friends)
>  | (alfred bert carol)
> 
> (note that the object properties is an alist, the key being the car of the
> sublists, the value the cdr. But you can (and usually should) ignore that
> and use object-property, object-properties and so on).
> 
> (Note as well that the properties get attached to the *value*, not to the
> *variable*):
> 
>  | guile> (object-property 42 'friends)
>  | (alfred bert carol)
> 
> Does this help?

Well, in a way it does. But the documentation says that this way of
giving properties is "the old way". They say "the new way" is using
(make-object-property). It seems nicer at least:
|guile> (define var 'value)
|guile> (define color (make-object-property))
|guile> (set! (color var) 'green)
|guile> (color var)
=> green

Now this is a different way of giving properties. After these, 
object-properties gives an empty alist. So given the documentation, I 
thought I should use "the new way". If I cannot find out how, then 
maybe I should use "the old way" :-)

Thank you again for answering. I will be very happy if you can answer 
the environment questions.

PS: I thought I should CC this to the guile-user list just in case 
someone else may need the answer to these questions more than some spam :-)



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


  reply	other threads:[~2004-09-02 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-02 11:09 [Fwd: Req for help on objects and environments] Alp Öztarhan
2004-09-02 11:53 ` tomas
2004-09-02 12:47   ` Alp Öztarhan [this message]
2004-09-02 19:19     ` Stephen Compall
2004-09-03 19:10   ` Req for help on objects and environments Andy Wingo
2004-09-06 22:34     ` macro documentation? (was: Re: Req for help on objects and environments) Richard Todd
2004-09-07 18:40       ` Andy Wingo
2004-09-03 20:27 ` [Fwd: Req for help on objects and environments] Ludovic Courtès
2004-09-04 11:31   ` Marius Vollmer
2004-09-04 13:07     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1094129266.4098.25.camel@kuzgun \
    --to=alp@uludag.org.tr \
    --cc=tomas@fabula.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).