JulioHerrlein Posted November 13, 2017 Share Posted November 13, 2017 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 Quote Link to comment Share on other sites More sharing options...
opmo Posted November 13, 2017 Share Posted November 13, 2017 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. JulioHerrlein 1 Quote Link to comment Share on other sites More sharing options...
JulioHerrlein Posted November 13, 2017 Author Share Posted November 13, 2017 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 Quote Link to comment Share on other sites More sharing options...
opmo Posted November 13, 2017 Share Posted November 13, 2017 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) Quote Link to comment Share on other sites More sharing options...
JulioHerrlein Posted November 13, 2017 Author Share Posted November 13, 2017 Got It ! You must take caution with previous evaluations. I was afraid it was a windows bug. Solved now. Thanks ! Julio Quote Link to comment Share on other sites More sharing options...
opmo Posted November 13, 2017 Share Posted November 13, 2017 Pleasure, Janusz JulioHerrlein 1 Quote Link to comment Share on other sites More sharing options...
torstenanders Posted November 17, 2017 Share Posted November 17, 2017 > 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 :) JulioHerrlein 1 Quote Link to comment Share on other sites More sharing options...
JulioHerrlein Posted November 17, 2017 Author Share Posted November 17, 2017 Thank You, Torsten! Best! Julio Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.