lilypond-devel
[Top][All Lists]
Advanced

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

Re: scheme: working in guile but not in lilypond?


From: David Kastrup
Subject: Re: scheme: working in guile but not in lilypond?
Date: Sun, 22 Apr 2012 00:59:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> Hi,
>
> the following code gives me the expected output in guile:
>
> (define-public lst `())
> (define (set-new-alist! ls-1 ls-2 proc)
>   (for-each (lambda (x) (set! ls-1 (acons x proc ls-1))) ls-2)
>   ls-1)
> (set-new-alist! lst '(1 2 3) "X")
>
> ==> ((3 . "X") (2 . "X") (1 . "X"))
>
> trying similiar in lily:
>
> \version "2.15.36"
>
> #(define-public lst `())
> #(define (set-new-alist! ls-1 ls-2 proc)
>   (for-each (lambda (x) (set! ls-1 (acons x proc ls-1))) ls-2)
>   ls-1)
> #(set-new-alist! lst '(1 2 3) "X")
> #(display lst)
>
> returns: ()
>
> What am I missing?

There is no discrepancy.  If you write
(display lst)
after the first case, it will also show just ().

In either case, set-new-alist! returns the value shown above, and lst is
left unchanged.

Lisp is call-by-value.

-- 
David Kastrup




reply via email to

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