Hi Gianmaria,

 

It’s time to stop and take stock here. It’s clear you have some background in 
programming, but it is even more clear that you have not studied Lisp and 
Scheme, except in a passing manner. The Lisp family of languages is 
fundamentally different from languages like C. It takes a considerable mental 
effort to grasp the fullness of Lisp and Scheme, but the effort is repaid as 
there will come a day when you suddenly realise how it all hangs together, and 
you will never program the same way again. There’s a long history of 
programmers reporting such an epiphany after studying Lisp for a while, and 
your outlook is changed forever. It is often said that learning Lisp makes you 
a better programmer even if you never program in Lisp.

 

At this point, rather than engaging in long winded corrections of your 
approach, I would really like you to ‘reset’ (after all, this topic started 
about resetting lists…) and read SICP, Structured Interpretation of Computer 
Programs by Abelson and Sussman of MIT. It is the definitive introductory text, 
and I have a hard copy at my desk always. You can study the online version 
here, the second edition.

 

https://mitpress.mit.edu/sites/default/files/sicp/index.html

 

The book beautifully typeset here:

 

https://web.mit.edu/alexmv/6.037/sicp.pdf

 

At the language level in Lisp and Scheme, there are no pointers. It’s critical 
to realise this, and important. Obviously the language uses pointers and memory 
locations internally, because that’s what computers are, but it’s vital that 
you don’t try to second guess how Scheme works internally, because you will 
certainly be wrong. The point of Scheme and Lisp is that they increase the 
level of abstraction we are dealing with, and this is their power. The low 
level machine issues are abstracted away from you, in order to give you vastly 
greater power. C is very low in the level of abstraction hierarchy, and is 
closer to assembler in spirit, with all the access to memory you want, and all 
the consequent disasters. Scheme relieves you of this.

 

I’d just like to direct you to the answer here in this post on Stack Overflow:

 

https://stackoverflow.com/questions/38277997/what-does-location-means-in-r6rs-of-scheme

 

“The crucial point here is that in languages like Lisp pointers are (and should 
remain) “invisible” to the user (the programmer).”

 

Your questions may actually be better addressed on Stack Overflow, as they are 
mostly about Scheme rather than lilypond specific – the point being, there is a 
lot of help there on languages.

 

Next, and I think this is even more important than chat about pointers. You 
would benefit from studying Functional Programming. Scheme supports imperative 
programming but it is also a good functional programming language. Studying 
this style of computer language will again change the way you think forever. 
You will study immutable data and how that completely changes the way you 
program. Haskell is the most pure functional language and every object in 
Haskell is immutable. Think about that for a minute. You cant change variables 
but you can actually write programs? Indeed. [I’d recommend studying Haskell 
too as it will inform you Scheme programming.]

 

Next, I detected a hint in your thread that you would like Scheme to be object 
oriented. It’s not. Don’t go there. OO is not the panacea it was once thought 
to be. So it is also wise not to attempt to mould Scheme into an OO model. 
[Yes, there are dialects that provide OO, but in the context of lilypond, we 
have Scheme.]

 

Another great learning resource with truly superb documentation is Racket, a 
Scheme variant. Now at release 7.2 and very mature. It’s a really good 
environment for learning Scheme, even though it is a greatly extended language.

 

There’s a lot to be said here Gianmaria. I think the outcome here is you will 
either abandon completely or go on to be a really master Scheme programmer. 
Hopefully the latter!

 

In my next mail, I will outline an approach to your original question in a way 
that uses Scheme in an idiomatic way.

 

Andrew

 

 

 

 

 

 

 

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to