Why don't you just check it out yourself:
(macroexpand-1 '(my-macro 'foo))
; ==> (getf *some-variable* :|| 'foo) ;
T
The documentation for getf says that if you give it a 4th argument it is the value when the key is not found. Since :|| (the empty symbol in the keyword package) doesn't exist it returns the supplied default foo.
So here is a function that does what you want:
(defun get-field (name)
(getf *some-variable*
(intern (symbol-name name) "KEYWORD")))
(defparameter *test* 'foo)
(get-field *test*)
; ==> "fooval"
The only reason to make it a macro is to make it syntax and the main difference between syntax and a function is that the arguments are not evaluated.
(defmacro get-mfield (name)
`(get-field ',name))
(get-mfield foo)
; ==> "fooval"
(get-mfield *test*)
; ==> nil
You get to come with literals bare, but you loose the feature that *test* is regarded as a variable and not the key :*test*
:,xis, essentially, a syntax error. You can't use,to splice things inside the syntax of a symbol: this is as bogus as if you saidmake-,footo try and create some symbol. If you want to construct symbols in specific packages you have to do more work than that.