Common Lisp: avoid evaluation of a symbol in a function -


i have trivial problem in common lisp. need write function takes symbol parameter (i.e. name of function or name of variable), other things, , print symbol without evaluating it. quote doesn't work in case, how can this? example, suppose defined var integer 3 defparameter, function should have behavior:

(my-function var) repl: var symbol , value 3. 

how can print var? how can see var on repl, or other name gave input variable in my-function? can me?

the features seeking not possible functions since might have been compiled such parameters passed on stack , code looks @ memory indexes , not variables.

you looking sort of meta programming , macros for:

(defmacro info (expr)   (let ((compile-type (type-of expr)) (tmp (gensym "tmp")))     `(let ((,tmp ,expr))        (format t "repl: ~s ~a , it's value ~s~%" ',expr ',compile-type ,tmp)        ,tmp)))   (info "test") ; repl: "test" (simple-base-string 4) , it's value "test" ; ==>  "test" (info *print-circle*) ; repl: *print-circle* symbol , it's value nil ; ==> nil (info #'+) ; repl: #'+ cons , it's value #<system-function +> ; ==> #<system-function +> (info (+ 3 4)) ; repl: (+ 3 4) cons , it's value 7 ; ==> 7 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -