unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [Fwd: Req for help on objects and environments]
@ 2004-09-02 11:09 Alp Öztarhan
  2004-09-02 11:53 ` tomas
  2004-09-03 20:27 ` [Fwd: Req for help on objects and environments] Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Alp Öztarhan @ 2004-09-02 11:09 UTC (permalink / raw)


Maybe I should give more information:

1) I work on gentoo linux guile 1.6.4

2) I try to program in Scheme. I DO NOT use C or C++ in my project.
   Just pure Scheme.

3) I try to control the environment I "eval" my expression, but
   manipulating the environment is not described in my documentation.
   (which comes with guile-1.6.4)

4) I also want to use the (make-object-property) scheme procedure.
   Unfortunately, I cannot list the properties of a given object.

Could anybody please help me on these? Or at least tell me where I can
ask these again?

- alp

-----Forwarded Message-----
From: Alp Öztarhan <alp@uludag.org.tr>
To: guile-user@gnu.org
Subject: Req for help on objects and environments
Date: Wed, 01 Sep 2004 11:28:49 +0300

I have been digging the documentation to find answers to two questions,
but could not find any answers.

First, I want to play with the properties on objects.
I want to be able to serialize an object along with its properties.
I *can* make and retrieve properties of objects by use of
(make-object-property). But how do I get a list of the properties of a
given object?

Second, I want to manipulate the environment in eval.
I could not even do what the documentation tells.
I could not get a handle on (null-environment) etc. (undefined symbol
:-(
Besides, I want to manipulate it, giving extra symbols etc.
Could anybody give me any hint on these?

thanks.

- alp



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



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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fwd: Req for help on objects and environments]
  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
  2004-09-03 19:10   ` Req for help on objects and environments Andy Wingo
  2004-09-03 20:27 ` [Fwd: Req for help on objects and environments] Ludovic Courtès
  1 sibling, 2 replies; 10+ messages in thread
From: tomas @ 2004-09-02 11:53 UTC (permalink / raw)
  Cc: guile-user


[-- Attachment #1.1: Type: text/plain, Size: 1552 bytes --]

On Thu, Sep 02, 2004 at 02:09:05PM +0300, Alp ?ztarhan wrote:
> Maybe I should give more information:
> 
> 1) I work on gentoo linux guile 1.6.4
> 
> 2) I try to program in Scheme. I DO NOT use C or C++ in my project.
>    Just pure Scheme.
> 
> 3) I try to control the environment I "eval" my expression, but
>    manipulating the environment is not described in my documentation.
>    (which comes with guile-1.6.4)

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?

> 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?

Regards
-- tomás

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fwd: Req for help on objects and environments]
  2004-09-02 11:53 ` tomas
@ 2004-09-02 12:47   ` Alp Öztarhan
  2004-09-02 19:19     ` Stephen Compall
  2004-09-03 19:10   ` Req for help on objects and environments Andy Wingo
  1 sibling, 1 reply; 10+ messages in thread
From: Alp Öztarhan @ 2004-09-02 12:47 UTC (permalink / raw)
  Cc: tomas

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fwd: Req for help on objects and environments]
  2004-09-02 12:47   ` Alp Öztarhan
@ 2004-09-02 19:19     ` Stephen Compall
  0 siblings, 0 replies; 10+ messages in thread
From: Stephen Compall @ 2004-09-02 19:19 UTC (permalink / raw)
  Cc: guile-user

Alp Öztarhan <alp@uludag.org.tr> writes:

> 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" :-)

Object properties are kept in `scm_properties_whash'.  Properties are
not named; internally, they are just pairs, almost always (#f . ()).
They are identified by their uniqueness eq?-wise.  Only the returned
proc-with-setter has access to this pair, through its environment.

The only meaningful name is that which you assign to it.

If you want names, associate them with the proc-with-setters somehow.
Keep your own alist of names to values.  Whatever.

--
Stephen Compall or s11 or sirian

It is a human characteristic to love little animals, especially if
they're attractive in some way.
		-- McCoy, "The Trouble with Tribbles", stardate 4525.6

Dateline monarchist BLU-97 A/B passwd FTS2000 Delta Force MD4 Sears
Tower domestic disruption radar S Box ASLET JPL electronic
surveillance New World Order


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Req for help on objects and environments
  2004-09-02 11:53 ` tomas
  2004-09-02 12:47   ` Alp Öztarhan
@ 2004-09-03 19:10   ` Andy Wingo
  2004-09-06 22:34     ` macro documentation? (was: Re: Req for help on objects and environments) Richard Todd
  1 sibling, 1 reply; 10+ messages in thread
From: Andy Wingo @ 2004-09-03 19:10 UTC (permalink / raw)


Hi Tomas,

On Thu, 2004-09-02 at 13:53 +0200, tomas@fabula.de wrote:
> (Note as well that the properties get attached to the *value*, not to the
> *variable*):
> 
>  | guile> (object-property 42 'friends)
>  | (alfred bert carol)

I didn't realize this! Thanks for the tip. I guess it has to be this
way.

It trips up some documentation thoughts I had, though... I was using the
'documentation object-property to attach docs to variables, whereas it
actually puts it on the value. I wonder if there's a better way.

> Does this help?

It helped me ;)

Cheers,
-- 
Andy Wingo <wingo@pobox.com>
http://ambient.2y.net/wingo/


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fwd: Req for help on objects and environments]
  2004-09-02 11:09 [Fwd: Req for help on objects and environments] Alp Öztarhan
  2004-09-02 11:53 ` tomas
@ 2004-09-03 20:27 ` Ludovic Courtès
  2004-09-04 11:31   ` Marius Vollmer
  1 sibling, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2004-09-03 20:27 UTC (permalink / raw)
  Cc: guile-user

Hi,

One day, 9 hours, 9 minutes, 46 seconds ago, 
Alp Öztarhan wrote:
> 3) I try to control the environment I "eval" my expression, but
>    manipulating the environment is not described in my documentation.
>    (which comes with guile-1.6.4)

The following document describes the Guile API for manipulating
environments: http://www.gnu.org/software/guile/docs/env.html .  It
should provide you with answers to your questions related to modifying
an environment.

BTW, the document preface reads:

  I hope this text will eventually become a chapter of the Guile manual

However, it dates back to 1999 and it looks like it never happened.  Is
there any reason for it?

Thanks,
Ludovic.


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fwd: Req for help on objects and environments]
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Marius Vollmer @ 2004-09-04 11:31 UTC (permalink / raw)
  Cc: guile-user

Ludovic Courtès <ludo@chbouib.org> writes:

> However, it dates back to 1999 and it looks like it never happened.
> Is there any reason for it?

Guile does not (yet?) use the 'environment' data type described in
this draft proposal.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fwd: Req for help on objects and environments]
  2004-09-04 11:31   ` Marius Vollmer
@ 2004-09-04 13:07     ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2004-09-04 13:07 UTC (permalink / raw)
  Cc: guile-user

Hi,

Today, one hour, 13 minutes, 41 seconds ago, Marius Vollmer wrote:
> Guile does not (yet?) use the 'environment' data type described in
> this draft proposal.

Good reason.  ;-)

What fooled me is that Guile (1.6.4) seems to already implement most of
the operations described in the proposal:

  environment-bound?        environment-module        environment-set!
  environment-cell          environment-observe       environment-undefine
  environment-define        environment-observe-weak
  environment-unobserve
  environment-fold          environment-ref           environment?

Looking closer at what these functions do, it looks like they are
currently unusable:

  guile> (environment-ref (scheme-report-environment 5) 'append)
  <unnamed port>:33:1: In procedure environment-ref in expression (environment-ref (scheme-report-environment 5) (quote append)):
  <unnamed port>:33:1: Wrong type argument in position 1: #<interface (ice-9 r5rs) 8086720>

Whatever is returned by `scheme-report-environement',
`interaction-environment', `current-module' and the likes is suitable as
the `env' argument of `eval' but not as the `env' argument of the
aforementioned procedures.  Is it that the proposal _was_ implemented
but never got integrated into the rest of Guile?

Thanks,
Ludovic.



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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* macro documentation? (was: Re: Req for help on objects and environments)
  2004-09-03 19:10   ` Req for help on objects and environments Andy Wingo
@ 2004-09-06 22:34     ` Richard Todd
  2004-09-07 18:40       ` Andy Wingo
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Todd @ 2004-09-06 22:34 UTC (permalink / raw)
  Cc: Richard Todd, Guile Users

On Sep 3, 2004, at 2:10 PM, Andy Wingo wrote:
>
> On Thu, 2004-09-02 at 13:53 +0200, tomas@fabula.de wrote:
>> (Note as well that the properties get attached to the *value*, not to 
>> the
>> *variable*):
>>
>>  | guile> (object-property 42 'friends)
>>  | (alfred bert carol)
>
> I didn't realize this! Thanks for the tip. I guess it has to be this
> way.

A similar problem appears when trying to document syncase macros... 
they all (display) as:

#<macro! sc-macro>

When I apply the 'documentation property to one of these macros, all 
the sudden ALL my syncase macros have this documentation.  I don't 
suppose anyone knows of a way to add docstrings to individual macros?  
How does this sc-macro entity know which transformation to make?   I 
don't know anything about how syncase works internally...

Richard



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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: macro documentation? (was: Re: Req for help on objects and environments)
  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
  0 siblings, 0 replies; 10+ messages in thread
From: Andy Wingo @ 2004-09-07 18:40 UTC (permalink / raw)
  Cc: Guile Users

Hey Richard,

On Mon, 2004-09-06 at 17:34 -0500, Richard Todd wrote:
> On Sep 3, 2004, at 2:10 PM, Andy Wingo wrote:
> >
> > On Thu, 2004-09-02 at 13:53 +0200, tomas@fabula.de wrote:
> >> (Note as well that the properties get attached to the *value*, not to 
> >> the
> >> *variable*):
> 
> A similar problem appears when trying to document syncase macros... 
> they all (display) as:
> 
> #<macro! sc-macro>
> 
> When I apply the 'documentation property to one of these macros, all 
> the sudden ALL my syncase macros have this documentation.

That's what you get for using syncase ;-)

Seriously though, this is a problem. Perhaps we can make define-with-
docs set the object-property on the _variable_ rather than (in addition
to?) the value:

(define-macro-with-docs (define-with-docs sym docs val)
  "Define a variable with documentation."
  `(begin
     (define ,sym ,val)
     (set-object-property! (module-variable ,sym) 'documentation ,docs)
     *unspecified*))

Of course with the proper checks, etc. Then when we implement Marius's
Grand New Help Scheme (GNHS), we can make `help' look for documentation
on the variable first. In any case, we implement it in (texinfo
reflection).

> How does this sc-macro entity know which transformation to make?

Presumably because it is passed the whole expression, including the name
of the macro, which would then be looked up in the lexical environment
or in the global macro-table.

Regards,
-- 
Andy Wingo <wingo@pobox.com>
http://ambient.2y.net/wingo/


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-09-07 18:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).