[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme question on strict substitution
From: |
Erik Sandberg |
Subject: |
Re: Scheme question on strict substitution |
Date: |
Fri, 1 Dec 2006 19:58:47 +0100 |
User-agent: |
KMail/1.9.5 |
On Thursday 30 November 2006 21:32, address@hidden wrote:
> Hello,
>
> > . . . one problem is that this [giving the syntax of each keyword] would
> > still just tell a small part of the full syntax.
>
> I think it would give a big part of the full syntax, even if not the whole
> picture. It would enable a user to know
> (1) what type of "arguments" have to follow the keyword;
> (2) whether (s)he has accidentally omitted one of the required
> arguments (when debugging);
> (3) whether (s)he should write a macro definition or a function
> definition to specify a "\whatever" construct involving the
> keyword;
> (4) what the types should be in the event that (s)he winds up writing a
> function definition.
> "Full" or not, that's a lot of useful information. And I'm talking about
> just a list of the syntax for each keyword, *not* the semantics. A syntax
> specification can be short but still tremendously useful. Specification
> of the semantics takes a lot of blah-blah, and nobody would have the time
> to write up all the semantics.
>
> > Another problem is that the
> > rule I gave really was too simple. For example, you cannot say
> > ^"some text" in a .ly file
> > without having a note in front of it, still you can define a macro
> > mytext = ^"some text"
> > and then use it as c \mytext
>
> That's a general problem in LilyPond, knowing what kind of expression
> constitutes a valid right-hand side of a macro definition. (I'm amazed
> that the above definition works.)
>
> A different but related problem concerns something I don't know the right
> term for, something like "context-free equivalence" maybe: for example,
> I can say
>
> foo = \markup { \bold "Zanzibar" }
> bar = \markup { "Stand on" \foo }
>
> but I can't say
>
> bar = \markup { "Stand on" \markup { \bold "Zanzibar" } }
>
> You will object that I would have no *reason* to say that anyway,
> but it nevertheless constitutes a toy example of non-transferability:
>
> \foo is not equivalent to \markup { \bold "Zanzibar" }
>
> despite the "=" sign in the macro definition, and that's surprising.
The reason for this is that foo is not a macro; it's a variable. Similarly, in
C you can write
int i = 5+9;
foo(&i);
which is _not_ the same as the (invalid) expression
foo(&(5+9));
(this example is not exactly analogous to what you're trying, but it
illustrates that variables and macros are different things).
The special thing about 'markup' is that it isn't a function; it's rather a
special token that marks that the following code should be interpreted as
markups.
--
Erik