GnuCash reports via eguile - probably not

Derek Atkins warlord at MIT.EDU
Tue Jan 27 09:59:38 EST 2009


Chris Dennis <cgdennis at btinternet.com> writes:

> I'm making progress with this, but I've hit another snag with 
> local-eval.  The following code gives an error (note the extra "(define 
> x 42)":
>
> ------
> ;#! /usr/bin/guile
> (define fred "This is Fred")
> (define (foo bar)
>    (let ((string1 "(begin (display fred) (newline) (display bar) \
>            (newline) (define x 42) (display x) (newline))"))
>      (with-input-from-string string1 (lambda () (local-eval (read) 
> (the-environment))))))
> (foo "Actual parameter")
> ------
> gives
> ------
> ERROR: Bad define placement
> ------
>
> I found a mention of this issue at 
> http://www.opensubscriber.com/message/guile-user@gnu.org/9617568.html
> but I'm not sure whether to give up on local-eval, or just make a rule 
> that the template code can't include 'define', which would be a bit 
> limiting.
>
> Any ideas?

Strangely this code works:

;#! /usr/bin/guile
(define fred "This is Fred")
(define bar "Actual parameter")
(begin
  (display fred)
  (newline)
  (display bar)
  (newline)
  (define x 42)
  (display x)
  (newline))


Whereas this does not:

;#! /usr/bin/guile

(let ((fred "This is Fred")
      (bar "Actual parameter"))
  (begin
    (display fred)
    (newline)
    (display bar)
    (newline)
    (define x 42)
    (display x)
    (newline)))

The problem is the define inside the let.

But note that this does work:

(let ((fred "This is Fred")
      (bar "Actual parameter"))
  (begin
    (display fred)
    (newline)
    (display bar)
    (newline)
    (let ((x 42))
      (display x)
      (newline))))

So....

Where are you hitting a problem where you need a (define) in a
template?  I'm trying to understand the use-case.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list