Jump to content

Crazy behavior


Recommended Posts

Dear Friends

I´m working on sketches for a piano piece.

I declared some variable setf´s for manipulating pitches, rhythms, etc.

In the def score instance below, almost in the end of script, OM is evaluating

 a non-declared variable pat-pitches2. "pat-pithes2" or "pat-pitches" is not in any place of this

 script, altought I used this in other file. Can OM pick variables from other files ? 

 

Why OM is behaving like this ? Seems crazy.

 

Best,

Julio

 

:pitch (ambitus '(g1 g3)(chordize-list (gen-divide '(1 1 1 1 1 1 1 1) (pitch-transpose-n '(0 0 -12 0) pat-pitches2))))
;;; HOW OM IS EVALUATING the variable pat-pitches2 - IT is NOT declared in any place of this file !!!!
   :velocity velocity2

 

 

 

 

Link to comment
Share on other sites

> Maybe a good idea would be some kind of FLUSH function that cleans the environment,

> so we don't need to close and reopen the program ;)

 

Setting (and overwriting!) "global variables" with setf results in side effects, which can be difficult to control. 

 

Because of that, experienced Lisp programmers use side effects like overwriting "global variables" only rarely and when really necessary, and instead work with constants and "local variables". 

 

For quick hacking or testing using setf is very convenient and should not be dismissed, but if you are looking for a way to avoid restarting to create a clean slate then use "local variables".

 

Best,

Torsten 

 

In Lisp parlance, these are dynamic and lexical variables, not quite the same thing as local and global variables in other languages, but perhaps these terms are more easy to understand :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy