unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* begin oddities
@ 2008-09-24 13:32 Bill Schottstaedt
  2008-09-24 23:54 ` Marijn Schouten (hkBst)
  0 siblings, 1 reply; 9+ messages in thread
From: Bill Schottstaedt @ 2008-09-24 13:32 UTC (permalink / raw)
  To: bug-guile

Is this a bug?

guile> (begin (define x 0) (+ x 1))
1

guile> (lambda () (begin (define x 0) (+ x 1)))
#<procedure #f ()>

guile> (let ((f (lambda () (begin (define x 0) (+ x 1))))) (f))

Backtrace:
In standard input:
   3: 0* (let* ((f (lambda () #))) (f))
   3: 1  [#<procedure #f ()>]

standard input:3:53: In procedure memoization in expression (f):
standard input:3:53: In file "standard input", line 2: Mixed definitions and expressio
ns in (begin (define x 0) (+ x 1)).
ABORT: (syntax-error)



Also,

guile> (let () (begin . 1))
Segmentation fault (core dumped)






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

* Re: begin oddities
  2008-09-24 13:32 begin oddities Bill Schottstaedt
@ 2008-09-24 23:54 ` Marijn Schouten (hkBst)
  2008-09-25 21:30   ` Neil Jerram
  0 siblings, 1 reply; 9+ messages in thread
From: Marijn Schouten (hkBst) @ 2008-09-24 23:54 UTC (permalink / raw)
  To: Bill Schottstaedt; +Cc: bug-guile

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill Schottstaedt wrote:
> Is this a bug?
> 
> guile> (begin (define x 0) (+ x 1))
> 1
> 
> guile> (lambda () (begin (define x 0) (+ x 1)))
> #<procedure #f ()>
> 
> guile> (let ((f (lambda () (begin (define x 0) (+ x 1))))) (f))

Weird thing is it seems to have no problem with
(let ((f (lambda () (define x 0) (+ x 1)))) (f))

> Backtrace:
> In standard input:
>    3: 0* (let* ((f (lambda () #))) (f))
>    3: 1  [#<procedure #f ()>]
> 
> standard input:3:53: In procedure memoization in expression (f):
> standard input:3:53: In file "standard input", line 2: Mixed definitions and expressio
> ns in (begin (define x 0) (+ x 1)).
> ABORT: (syntax-error)

- --
Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkja008ACgkQp/VmCx0OL2y5QACgwoLPRQNragAepVhYga20Xx9M
XiQAoIKe9Fotg489D0If0q8HnNghLDmR
=V3t9
-----END PGP SIGNATURE-----




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

* Re: begin oddities
  2008-09-24 23:54 ` Marijn Schouten (hkBst)
@ 2008-09-25 21:30   ` Neil Jerram
  2008-09-25 22:14     ` Bill Schottstaedt
  2008-09-25 22:16     ` Bill Schottstaedt
  0 siblings, 2 replies; 9+ messages in thread
From: Neil Jerram @ 2008-09-25 21:30 UTC (permalink / raw)
  To: Marijn Schouten (hkBst); +Cc: Bill Schottstaedt, bug-guile

2008/9/25 Marijn Schouten (hkBst) <hkBst@gentoo.org>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Bill Schottstaedt wrote:
>> Is this a bug?

No.  See the R5RS formal syntax.  Different things are allowed for
(begin ...) at top level and (begin ...) inside a definition.

> Weird thing is it seems to have no problem with
> (let ((f (lambda () (define x 0) (+ x 1)))) (f))

Right, because there's no begin there.

Regards,
      Neil




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

* Re: begin oddities
  2008-09-25 21:30   ` Neil Jerram
@ 2008-09-25 22:14     ` Bill Schottstaedt
  2008-09-25 22:16     ` Bill Schottstaedt
  1 sibling, 0 replies; 9+ messages in thread
From: Bill Schottstaedt @ 2008-09-25 22:14 UTC (permalink / raw)
  To: Neil Jerram, Marijn Schouten (hkBst); +Cc: bug-guile

Sorry, I don't see what you're referring to -- if the preceding
(lambda () (begin ...)) doesn't get an error, then there's no
difference that I can see in the formal syntax between it and
the same thing sitting in a let. 






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

* Re: begin oddities
  2008-09-25 21:30   ` Neil Jerram
  2008-09-25 22:14     ` Bill Schottstaedt
@ 2008-09-25 22:16     ` Bill Schottstaedt
  2008-09-25 22:24       ` Neil Jerram
  1 sibling, 1 reply; 9+ messages in thread
From: Bill Schottstaedt @ 2008-09-25 22:16 UTC (permalink / raw)
  To: Neil Jerram, Marijn Schouten (hkBst); +Cc: bug-guile

oh -- it's the (f) that triggers the silly error, not the preceding stuff.







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

* Re: begin oddities
  2008-09-25 22:16     ` Bill Schottstaedt
@ 2008-09-25 22:24       ` Neil Jerram
  2008-09-25 22:40         ` Bill Schottstaedt
                           ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Neil Jerram @ 2008-09-25 22:24 UTC (permalink / raw)
  To: Bill Schottstaedt; +Cc: bug-guile

2008/9/25 Bill Schottstaedt <bil@ccrma.stanford.edu>:
> oh -- it's the (f) that triggers the silly error, not the preceding stuff.

Yes.  This particular error isn't picked up until the code is actually executed.

     Neil




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

* Re: begin oddities
  2008-09-25 22:24       ` Neil Jerram
@ 2008-09-25 22:40         ` Bill Schottstaedt
  2008-09-25 22:56         ` Bill Schottstaedt
  2008-09-25 23:12         ` Bill Schottstaedt
  2 siblings, 0 replies; 9+ messages in thread
From: Bill Schottstaedt @ 2008-09-25 22:40 UTC (permalink / raw)
  To: Neil Jerram; +Cc: bug-guile

Hmm -- gauche and stklos are happy with the first version,
and guile is happy with this version:

guile> (let ((f (lambda () (begin (define x 0)) (+ x 1)))) (f))
1

This is basically taken from Jaffer's r4rstest.html. 






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

* Re: begin oddities
  2008-09-25 22:24       ` Neil Jerram
  2008-09-25 22:40         ` Bill Schottstaedt
@ 2008-09-25 22:56         ` Bill Schottstaedt
  2008-09-25 23:12         ` Bill Schottstaedt
  2 siblings, 0 replies; 9+ messages in thread
From: Bill Schottstaedt @ 2008-09-25 22:56 UTC (permalink / raw)
  To: Neil Jerram; +Cc: bug-guile

I've stared at the formal syntax, and read it as:

lambda is (lambda <formals> <body>)
<body> is <definition>* <sequence>
<definition>* is 
        (define <variable> <expression>)
      | (define (<variable> <def formals>) <body>)
      | (begin <definition>*)

so (lambda () (begin (define ...) ... in both forms looks legal to me.






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

* Re: begin oddities
  2008-09-25 22:24       ` Neil Jerram
  2008-09-25 22:40         ` Bill Schottstaedt
  2008-09-25 22:56         ` Bill Schottstaedt
@ 2008-09-25 23:12         ` Bill Schottstaedt
  2 siblings, 0 replies; 9+ messages in thread
From: Bill Schottstaedt @ 2008-09-25 23:12 UTC (permalink / raw)
  To: Neil Jerram; +Cc: bug-guile

These things are hard to read!  I think there are 2 kinds of
begin, and if it's the definition kind, the spec wants just
definitions, so I think now that Guile is technically correct,
but the whole thing is way too subtle.







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

end of thread, other threads:[~2008-09-25 23:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-24 13:32 begin oddities Bill Schottstaedt
2008-09-24 23:54 ` Marijn Schouten (hkBst)
2008-09-25 21:30   ` Neil Jerram
2008-09-25 22:14     ` Bill Schottstaedt
2008-09-25 22:16     ` Bill Schottstaedt
2008-09-25 22:24       ` Neil Jerram
2008-09-25 22:40         ` Bill Schottstaedt
2008-09-25 22:56         ` Bill Schottstaedt
2008-09-25 23:12         ` Bill Schottstaedt

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