This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bad define placement?


On Fri, 27 Aug 1999, Richard Frith-Macdonald wrote:

> On 27 Aug 1999 08:43:19 -0500, james@tiger-marmalade.com wrote:
> > I've gotten a new error with 1.3.2 on some code that worked with 1.3.1:
> >
> > (define (foo bar)
> >   (display bar)
> >   (define c "World")
> >   (display c) )
> >
> > (foo "Hello ")
> >
> > This gives an error "Bad define placement".  Is the above code really
> > incorrect?
> 
> I have the same sort of problem - but in more complex situations - where I
> wasn't sure whether my code was correct or not (being more of an Objective-C
> programmer than a Guile programmer).  I wasn't going to report it as a bug
> until I was sure it wasn't my fault - but it seems I'm not the only one
> suffering...

The above code is incorrect due to the internal defines:

(define (foo bar)
  (display bar)
  (define c "World")   <<  illegal
  (display c) )

According to R5RS internal defines (i.e. defines that are not on the top
level) may only occur at the beginning of a <body>.  The following would
work:

(define (foo bar)
  (define c "World")
  (display bar)
  (display c) )

There is some information in the NEWS file about changes in the handling of
internal defines, but the example given there does not cover this specific
change in guile's behaviour.  Maybe the corresponding section of the NEWS file
should be extended to explain when and why the error message 'Bad define
placement' will appear.

Best regards,
Dirk Herrmann


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]