lilypond-devel
[Top][All Lists]
Advanced

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

Re: proposals for LM B. Scheme tutorial


From: Carl D. Sorensen
Subject: Re: proposals for LM B. Scheme tutorial
Date: Sun, 21 Jun 2009 00:12:12 -0600



On 6/20/09 3:18 PM, "Mark Polesky" <address@hidden> wrote:

> 
> 
> Nicolas Sceaux wrote:
>>>    #(begin
>>> 
>>>    (define foo 0)
>>>    (define bar 1)
>>> 
>>>    )
>> 
>> The formatting is bad.
>> 
>>> #(begin
>>>    (define foo 0)
>>>    (define bar 1))
>> 
>> Parentheses are never left alone on a line.
> 
> I respectfully* disagree:
> http://community.schemewiki.org/?scheme-style#H-189ddlj

When I followed the link, it agreed with Nicolas, with one exception, which
is the creation of a list that may be extended.

I don't think of a (begin ... ) as a "list that may be extended", but rather
as a sequence of statements.

Also, the exception should be used *rarely*.  And a rare exception should
not be shown in the Learning Manual.  This is a place for the rules.

The syntax you've used is a c structure in Scheme; as much as c programmers
think it's right, Scheme programmers think it's wrong.
> 
> Though I think it might depend on the size of the code within the
> #(begin ...). When I have many screens worth of consecutive scheme
> expressions lumped into a #(begin ...), the extra indenting (even
> just 2 spaces) seems unnecessary.

Scheme programmers are very unlikely to have many screens worth lumped into
a (begin ...); again, that's not very Schemey

> But even more to the point, when
> the last expression is a large procedure, and I want to block-
> comment it out for debugging, I don't want to accidentally remove
> the terminal parenthesis of the (begin ...).
> 
> #(begin
>   (define foo 0)
> #!
>   (define large-procedure ...))
> !#

It would generally be preferred (IMO, of course) to do

#(define foo 0)

#(define (large-procedure baz)
 ....
  foobar)

That is, in your .ly file, I think it's better to put each Scheme definition
in it's own #, rather than putting a huge Scheme file inside of a #(begin ).


Also, if you're commenting out stuff, it's easy with a parenthesis-matching
editor* to find the right place, insert a newline and a comment termination,
and go on your way.  And because you're not going to leave debugging stuff
in when you submit the code, it's easy to delete the comment and the newline
to get you back to good Scheme style.

Of course, even though Scheme has block comments, I can't remember *ever*
seeing them used by an experienced Scheme programmer.  The more typical way
to do a block comment for debugging is (if #f ....)

Just my opinion,

Carl 

*and a parenthesis-matching editor is a *REQUIREMENT* for Scheme.  If you
don't have one, you'll go crazy.







reply via email to

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