[Top][All Lists]

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

Placement of defines

From: Sebastian Tennant
Subject: Placement of defines
Date: Thu, 18 Dec 2008 17:00:35 +0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

Hi all,

Having read this interesting thread:

I understand that internal definitions may not occur anywhere other than
at the beginning of the body of the enclosing expression, which explains
why this works:

 ((lambda (x) (define bar x) (display bar)) "foo\n")

while this doesn't:

 ((lambda (x) (set! x "baz\n") (define bar x) (display bar)) "foo\n")

Firstly, perhaps this could/should be mentioned in the manual?

(info "(guile) Internal Definitions") currently reads:

"A `define' form which appears inside the body of a `lambda', `let',
 `let*', `letrec' or equivalent expression is called an "internal

May I suggest this reads:

"`Define' forms may only appear at the beginning of the body of a
 `lambda', `let', `let*', `letrec' or equivalent expression, and when
 they do they constitute what are known as "internal definitions"."

or words to that effect.

Secondly, there is some talk in the above-mentioned thread of an
extension to R5RS Scheme that allows define forms to occur anywhere
within the body of the enclosing expression, making for much more
readable code.

The thread is approx 8.5 years old now, and I was just wondering why the
extension never made it into Guile, the readable code argument being a
pretty compelling one IMHO.


reply via email to

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