;;;(trace (get-macro-character #\`) ) ; i could'nt get this work
;;;(get-macro-character #\`) ; use this, to obtain the
; function name for your lisp
(trace SYSTEM::READ-BACKQUOTE)
works, but is implementation-dependent (here: lispworks)
CL-USER 7 : 1 > (get-macro-character #\`)
SYSTEM::READ-BACKQUOTE
NIL
2 return values.
(trace (get-macro-character #\`))
but it throws an error. why?
Error: The call
(#<function COMPILER::TRACE-FUNCTION 20AA1DE2> NIL (#\`))
does not match definition
(#<function COMPILER::TRACE-FUNCTION 20AA1DE2> DSPEC:DSPEC &REST
COMPILER::TRACE-INFO &KEY COMPILER::BEFORE COMPILER::AFTER
COMPILER::EVAL-BEFORE COMPILER::EVAL-AFTER BREAK COMPILER::BREAK-ON-EXIT
STEP WHEN COMPILER::ENTRYCOND COMPILER::EXITCOND COMPILER::TRACE-OUTPUT
COMPILER::PROCESS COMPILER::ALLOCATION COMPILER::INSIDE
COMPILER::BACKTRACE).
shoudn't simply the first return value (SYSTEM::READ-BACKQUOTE) be used?
i've tried:
(trace #'(get-macro-character #\`) )
but still an error.
ilias <·······@pontos.net> writes:
> (trace (get-macro-character #\`))
> ...
> (trace #'(get-macro-character #\`) )
ilias,
I'm sure somebody already told you this, but HyperSpec really is your
friend. If you would look TRACE up, you would see that the syntax is as
follows [*]:
trace function-name*
Notice that TRACE does not accept a form or a s-expression, only a
function name. So instead of your (trace (get-macro-character #\`)) all
you needed to do was what you did with (trace SYSTEM::READ-BACKQUOTE),
simply pass a function name to it, resulting in (trace
get-macro-character).
[*] http://www.lispworks.com/reference/HyperSpec/Body/m_tracec.htm
Good luck!
--
Richard Krushelnitskiy "I know not with what weapons World War III will
rkrush (at) gmx.net be fought, but World War IV will be fought with
http://rkrush.cjb.net sticks and stones." -- Albert Einstein
Richard Krush wrote:
> ilias <·······@pontos.net> writes:
>
>>(trace (get-macro-character #\`))
>>...
>>(trace #'(get-macro-character #\`) )
>
>
> ilias,
>
> I'm sure somebody already told you this, but HyperSpec really is your
> friend. If you would look TRACE up, you would see that the syntax is as
> follows [*]:
>
> trace function-name*
>
> Notice that TRACE does not accept a form or a s-expression, only a
> function name. So instead of your (trace (get-macro-character #\`)) all
> you needed to do was what you did with (trace SYSTEM::READ-BACKQUOTE),
> simply pass a function name to it, resulting in (trace
> get-macro-character).
>
> [*] http://www.lispworks.com/reference/HyperSpec/Body/m_tracec.htm
>
> Good luck!
>
i've maybe expressed things complicated.
how can i pass the function-name which returns as first value from the
function (get-macro-character #\`) to the function trace ?
(trace (get-macro-character #\`) ) ; does not work
ilias <·······@pontos.net> writes:
>
> i've maybe expressed things complicated.
>
> how can i pass the function-name which returns as first value from the
> function (get-macro-character #\`) to the function trace ?
>
> (trace (get-macro-character #\`) ) ; does not work
>
My apologies, I think what would work is something like this:
(trace #.(get-macro-character #\`))
The #. reader macro evaluates the expression which follows after it, but
during the read phase. For more information, check out the HyperSpec [*].
[*] http://www.lispworks.com/reference/HyperSpec/Body/02_dhf.htm
Here's what I get in CMUCL:
* (trace #.(get-macro-character #\`))
(#<Function COMMON-LISP::BACKQUOTE-MACRO {1012E791}>)
Hopefully that's what you need, if other more experienced Lispers believe
this is a wrong way of doing this, please correct me.
--
Richard Krushelnitskiy "I know not with what weapons World War III will
rkrush (at) gmx.net be fought, but World War IV will be fought with
http://rkrush.cjb.net sticks and stones." -- Albert Einstein
Richard Krush wrote:
> ilias <·······@pontos.net> writes:
>
>>i've maybe expressed things complicated.
>>
>>how can i pass the function-name which returns as first value from the
>>function (get-macro-character #\`) to the function trace ?
>>
>>(trace (get-macro-character #\`) ) ; does not work
>>
>
>
> My apologies, I think what would work is something like this:
>
> (trace #.(get-macro-character #\`))
>
> The #. reader macro evaluates the expression which follows after it, but
> during the read phase. For more information, check out the HyperSpec [*].
>
> [*] http://www.lispworks.com/reference/HyperSpec/Body/02_dhf.htm
>
> Here's what I get in CMUCL:
>
> * (trace #.(get-macro-character #\`))
> (#<Function COMMON-LISP::BACKQUOTE-MACRO {1012E791}>)
>
> Hopefully that's what you need, if other more experienced Lispers believe
> this is a wrong way of doing this, please correct me.
>
yes, this works.
although i'd like to know, if this is the only way.
ilias wrote:
>
> i've maybe expressed things complicated.
>
> how can i pass the function-name which returns as first value from the
> function (get-macro-character #\`) to the function trace ?
>
get-macro-character does not return a function name as its first value,
it returns a function.
http://www.lisp.org/HyperSpec/Body/fun_set-macro_ro-character.html
> (trace (get-macro-character #\`) ) ; does not work
That is because trace requires a function name as argument, and it is
being passed a function.
http://www.lisp.org/HyperSpec/Body/mac_tracecm_untrace.html
Joe
Joseph Dale wrote:
> ilias wrote:
>
>>
>> i've maybe expressed things complicated.
>>
>> how can i pass the function-name which returns as first value from the
>> function (get-macro-character #\`) to the function trace ?
>>
>
> get-macro-character does not return a function name as its first value,
> it returns a function.
>
> http://www.lisp.org/HyperSpec/Body/fun_set-macro_ro-character.html
>
>> (trace (get-macro-character #\`) ) ; does not work
>
>
> That is because trace requires a function name as argument, and it is
> being passed a function.
>
> http://www.lisp.org/HyperSpec/Body/mac_tracecm_untrace.html
>
> Joe
>
if it is as you say:
how can i convert a function to a funtion-name?
btw:
this version of the CLHS is 'vendor-independent'.
this version of the CLHS has a serch-function for symbols
http://www.lisp.org/HyperSpec/FrontMatter/Symbol-Index.html
In article <············@usenet.otenet.gr>, ilias <·······@pontos.net>
wrote:
> if it is as you say:
> how can i convert a function to a funtion-name?
If you define this function:
(defun name-of-function ( a-function)
(nth-value 2 (function-lambda-expression a-function)))
Then you can do things like:
? (name-of-function #'car)
CAR
? (name-of-function (symbol-function 'car))
CAR
Unfortunately, function-lambda-expression is not required to return a
usable name, so it may not return a name of (get-macro-character #\`)
that is usable by trace (it doesn't in OpenMCL, for example).
from the spec:
"The tertiary value, name, is the ``name'' of function. The name is
intended for debugging only and is not necessarily one that would be
valid for use as a name in defun or function, for example. By
convention, nil is used to mean that function has no name. Any
implementation may legitimately return nil as the name of any function."
As a broader issue, you should be aware that whatever the name of
(get-macro-character #\`) is in your implimentation - it happens to be
CCL::|` reader| in OpenMCL - may be inlined, and so not produce any
usable results from trace.
again, from the spec:
"If a function to be traced has been open-coded (e.g., because it was
declared inline), a call to that function might not produce trace
output."
So you might want to reconsider your broader goal here.
Raffael Cavallaro wrote:
[...]
> "If a function to be traced has been open-coded (e.g., because it was
> declared inline), a call to that function might not produce trace
> output."
>
> So you might want to reconsider your broader goal here.
i see.
basically i'd like to trace the expansion of `.
i could hook the macrofunction, too.
<store the function that returns> (get-macro-character #\`)
(set-macro-character #\` #'(lambda (stream char)
(format T "~% BACKQUOTE EXPANSION ~% ")
(<functioncall> <stored function> stream char))
something like that.
but maybe this runs into the same problems.
i don't know.