Getting the name of a #<procedure>

Discussion of Scheme and Racket
Post Reply
schoppenhauer
Posts: 99
Joined: Sat Jul 26, 2008 2:30 pm
Location: Germany
Contact:

Getting the name of a #<procedure>

Post by schoppenhauer » Fri Dec 18, 2009 7:29 pm

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?
Sorry for my bad english.
Visit my blog http://blog.uxul.de/

elibarzilay
Posts: 1
Joined: Sat Dec 19, 2009 5:29 pm
Contact:

Re: Getting the name of a #<procedure>

Post by elibarzilay » Sat Dec 19, 2009 5:45 pm

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.

Post Reply