Page 1 of 1

Getting the name of a #<procedure>

Posted: Fri Dec 18, 2009 7:29 pm
by schoppenhauer
I am currently coding with either Petite Scheme or MZScheme (have to use one of these), following the r5rs. DrScheme is a good UI, but I want to use Emacs most of the time, and only use DrScheme if harder bugs occur. Petite mostly complains that there was some error in #<procedure>, mzscheme does something similar. Well, ok, in scheme, since its a lisp-1, there is no way to always tell the current name of a function. But it would be nice to at least get the function name in some cases, i.e. when it has been defined by a define-statement, etc.

In general, it would be nice to have named stack frames in the debugger - even though that would mean that the code will be ran a lot faster. But since DrScheme can do these types of stuff, it should be somehow possible.

Does anybody know anything about this?

Re: Getting the name of a #<procedure>

Posted: Sat Dec 19, 2009 5:45 pm
by elibarzilay
MzScheme will always give procedures a name according to the context that they were defined in -- either from a ‘define’ or a ‘let’ or any of their relatives. However, not all functions can be names in this way, for example, given

Code: Select all

(define (foo x) (lambda () x))
‘(foo 5)’ is a procedure that will not have a name.

And BTW, when you get a runtime error, DrScheme will generally give you much more information about where the error happened and draw arrows that represent the current stacktrace. You can get a similar kind of information in mzscheme if you run it with

Code: Select all

mz -lli errortrace scheme
but it will be more difficult to read through traces.