November 13, 20178 yr 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
November 13, 20178 yr Because you have evaluated the expression before. If you use the same name it should be in this score. If you quit the App and restart and evaluate the score you will see an error.
November 13, 20178 yr Author Great ! Thanks you Janusz 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 ;) Best, Julio
November 13, 20178 yr This is how lisp works Any variable you use in your score needs to be evaluated first. simple test (setf var '(1 2 3 4)) var => (1 2 3 4) (setf var '(a b c d) var => (a b c d) Now the var result is (a b c d)
November 13, 20178 yr Author Got It ! You must take caution with previous evaluations. I was afraid it was a windows bug. Solved now. Thanks ! Julio
November 17, 20178 yr > 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 :)
Create an account or sign in to comment