lilypond-devel
[Top][All Lists]
Advanced

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

Re: problem with constants in scheme-text-spanner.ly


From: David Kastrup
Subject: Re: problem with constants in scheme-text-spanner.ly
Date: Mon, 22 Jul 2013 19:06:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

David Nalesnik <address@hidden> writes:

>  All spanners appear when I replace the variable definition
> (event-drul '(() . ()))
>
> with
>
> (cons (list) (list))
>
> and later (line 157):
>
> (set! event-drul '(() . ()))
>
> with
>
> (set! event-drul (cons (list) (list)))
>
> I'd like to fix the problem, but I have several questions:
>
> (1) Would (cons '() '()) be acceptable?  The problem is fixed, but I wonder
> about the
> usage of the literal expression '() since there are multiple usages of
> set-car! and set-cdr! applied to the variable.

That's a misconception.  You can't apply set-car! or set-cdr! to '()
since '() has neither car nor cdr, not being a pair.

> (2) Should '() in all variable definitions, set! expressions be changed to
> (list) ?

No, '() is just fine and safe.  It is a constant like 7, #t or #f and
can't be modified at all.  '(() ()) however is a pair.  Both its car and
cdr are the constant '() (which can't be changed), but you can replace
its car and cdr.  Which is undefined behavior: Scheme is free to throw
an error or actually change the code in every instance or do other
nasties.

So with (cons '() '()) you should be fine.

IIRC, completize-grob-entry running on all-grob-descriptions also
commits this kind of sacrilege.

-- 
David Kastrup




reply via email to

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