unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Order of the evaluation of elements in a quasiquote list.
@ 2005-04-02 18:52 Kjetil Svalastog Matheussen
  2005-04-03  9:11 ` Neil Jerram
  0 siblings, 1 reply; 7+ messages in thread
From: Kjetil Svalastog Matheussen @ 2005-04-02 18:52 UTC (permalink / raw)



Hi, I have recently stumbled upon various bugs in my code
because the order of the evaluation of the elements in a quasiquote
list changes.

I know that the order of arguments aren't specified in r5rs, but I 
personally think it would have been very practicaly if they were...

Please, I don't want to start a flame war, I read comp.lang.scheme,
I just want to know if there is a quick way in Guile to get
left-to-right evaluation order for quasiquoted lists?



-- 


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


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

* Re: Order of the evaluation of elements in a quasiquote list.
  2005-04-02 18:52 Kjetil Svalastog Matheussen
@ 2005-04-03  9:11 ` Neil Jerram
  2005-04-03 11:38   ` Kjetil Svalastog Matheussen
  0 siblings, 1 reply; 7+ messages in thread
From: Neil Jerram @ 2005-04-03  9:11 UTC (permalink / raw)
  Cc: guile-user

Kjetil Svalastog Matheussen wrote:
> Hi, I have recently stumbled upon various bugs in my code
> because the order of the evaluation of the elements in a quasiquote
> list changes.

Changes how?  Can you give us an example, to make things concrete?

	Neil


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


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

* Re: Order of the evaluation of elements in a quasiquote list.
  2005-04-03  9:11 ` Neil Jerram
@ 2005-04-03 11:38   ` Kjetil Svalastog Matheussen
  2005-04-03 11:59     ` rm
  2005-04-03 13:01     ` Geoffrey Knauth
  0 siblings, 2 replies; 7+ messages in thread
From: Kjetil Svalastog Matheussen @ 2005-04-03 11:38 UTC (permalink / raw)
  Cc: guile-user, Kjetil Svalastog Matheussen

On Sun, 3 Apr 2005, Neil Jerram wrote:

> Kjetil Svalastog Matheussen wrote:
> > Hi, I have recently stumbled upon various bugs in my code
> > because the order of the evaluation of the elements in a quasiquote
> > list changes.
> 
> Changes how?  Can you give us an example, to make things concrete?
> 

Sorry, this is the stripped down version of the cause of the bug I'm 
finding various places:

(let ((a 1))
  `( ,(begin (set! a 2) a)
     ,a))
-> (2 1)


Wouldn't it be better if this one returned (2 2)?

Also, I'm seeing different behaviour in the order of evaluation between
1.6.4 and 1.7 (doesn't have the code available now). I think that is
really bad actually...

-- 



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


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

* Re: Order of the evaluation of elements in a quasiquote list.
  2005-04-03 11:38   ` Kjetil Svalastog Matheussen
@ 2005-04-03 11:59     ` rm
  2005-04-03 12:09       ` Kjetil Svalastog Matheussen
  2005-04-03 13:01     ` Geoffrey Knauth
  1 sibling, 1 reply; 7+ messages in thread
From: rm @ 2005-04-03 11:59 UTC (permalink / raw)
  Cc: guile-user, Neil Jerram

On Sun, Apr 03, 2005 at 01:38:04PM +0200, Kjetil Svalastog Matheussen wrote:
> On Sun, 3 Apr 2005, Neil Jerram wrote:
> 
> > Kjetil Svalastog Matheussen wrote:
> > > Hi, I have recently stumbled upon various bugs in my code
> > > because the order of the evaluation of the elements in a quasiquote
> > > list changes.
> > 
> > Changes how?  Can you give us an example, to make things concrete?
> > 
> 
> Sorry, this is the stripped down version of the cause of the bug I'm 
> finding various places:
> 
> (let ((a 1))
>   `( ,(begin (set! a 2) a)
>      ,a))
> -> (2 1)
> 
> 
> Wouldn't it be better if this one returned (2 2)?

Why do you think that "(2 2)" would be _better_? (How do you define
"better" ?)

> Also, I'm seeing different behaviour in the order of evaluation between
> 1.6.4 and 1.7 (doesn't have the code available now). I think that is
> really bad actually...

You get what you ask for: did you do a "manual" expand of your code?
This result in the following form:

     (list (begin (set! a 2) a) a)
                 
 =>  (list 2  1) | (list 2 2)

depending on the order of evaluation of function arguments, and, please,
since you read c.l.scheme: there's not to be argued about here :-/
So guile changed the order of evaluation for function arguments - that's not
good or bad. There is no reason why the implementors shouldn't do this, after
all, that's the whole point of leaving evaluation order unspecified (so implementors
can safely do this).

hth Ralf Mattes

> -- 
> 
> 
> 
> _______________________________________________
> 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] 7+ messages in thread

* Re: Order of the evaluation of elements in a quasiquote list.
  2005-04-03 11:59     ` rm
@ 2005-04-03 12:09       ` Kjetil Svalastog Matheussen
  0 siblings, 0 replies; 7+ messages in thread
From: Kjetil Svalastog Matheussen @ 2005-04-03 12:09 UTC (permalink / raw)
  Cc: guile-user, Neil Jerram, Kjetil Svalastog Matheussen

On Sun, 3 Apr 2005 rm@fabula.de wrote:

> On Sun, Apr 03, 2005 at 01:38:04PM +0200, Kjetil Svalastog Matheussen wrote:
> > On Sun, 3 Apr 2005, Neil Jerram wrote:
> > 
> > > Kjetil Svalastog Matheussen wrote:
> > > > Hi, I have recently stumbled upon various bugs in my code
> > > > because the order of the evaluation of the elements in a quasiquote
> > > > list changes.
> > > 
> > > Changes how?  Can you give us an example, to make things concrete?
> > > 
> > 
> > Sorry, this is the stripped down version of the cause of the bug I'm 
> > finding various places:
> > 
> > (let ((a 1))
> >   `( ,(begin (set! a 2) a)
> >      ,a))
> > -> (2 1)
> > 
> > 
> > Wouldn't it be better if this one returned (2 2)?
> 
> Why do you think that "(2 2)" would be _better_? (How do you define
> "better" ?)


It just feels more logical, left to right, top to bottom.

Thanks for the information, I had a small hope
that this was a bug in guile, or that the behaviour could be
changed with a switch. I'll fix up my code.

-- 



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


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

* Re: Order of the evaluation of elements in a quasiquote list.
  2005-04-03 11:38   ` Kjetil Svalastog Matheussen
  2005-04-03 11:59     ` rm
@ 2005-04-03 13:01     ` Geoffrey Knauth
  1 sibling, 0 replies; 7+ messages in thread
From: Geoffrey Knauth @ 2005-04-03 13:01 UTC (permalink / raw)


By comparison:
   PLT 299.100 and scsh 0.6.6 return (2 2).
   JScheme 7.1 and sisc 1.9.7 return (2 1).

Geoffrey
--
Geoffrey S. Knauth | http://knauth.org/gsk

On Apr 3, 2005, at 07:38, Kjetil Svalastog Matheussen wrote:

> On Sun, 3 Apr 2005, Neil Jerram wrote:
>
>> Kjetil Svalastog Matheussen wrote:
>>> Hi, I have recently stumbled upon various bugs in my code
>>> because the order of the evaluation of the elements in a quasiquote
>>> list changes.
>>
>> Changes how?  Can you give us an example, to make things concrete?
>
> Sorry, this is the stripped down version of the cause of the bug I'm
> finding various places:
>
> (let ((a 1))
>   `( ,(begin (set! a 2) a)
>      ,a))
> -> (2 1)
>
> Wouldn't it be better if this one returned (2 2)?



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


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

* Re: Order of the evaluation of elements in a quasiquote list.
       [not found] <cmu-lmtpd-25765-1112693521-1@mail-imap5.uio.no>
@ 2005-04-05 14:23 ` Kjetil Svalastog Matheussen
  0 siblings, 0 replies; 7+ messages in thread
From: Kjetil Svalastog Matheussen @ 2005-04-05 14:23 UTC (permalink / raw)




Geoffrey Knauth:

>By comparison:
>   PLT 299.100 and scsh 0.6.6 return (2 2).
>   JScheme 7.1 and sisc 1.9.7 return (2 1).

Just for the record...:
Actually, after taking a quick peek in the guile source,
the reason for the inconsistency for the result of the
mentioned code, is because the order of arguments
isn't specified in C either. So its because of different
behaviour between C compilators I sometime have got
(2 1) and sometimes (2 2) with Guile.


-- 


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


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

end of thread, other threads:[~2005-04-05 14:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cmu-lmtpd-25765-1112693521-1@mail-imap5.uio.no>
2005-04-05 14:23 ` Order of the evaluation of elements in a quasiquote list Kjetil Svalastog Matheussen
2005-04-02 18:52 Kjetil Svalastog Matheussen
2005-04-03  9:11 ` Neil Jerram
2005-04-03 11:38   ` Kjetil Svalastog Matheussen
2005-04-03 11:59     ` rm
2005-04-03 12:09       ` Kjetil Svalastog Matheussen
2005-04-03 13:01     ` Geoffrey Knauth

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