This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Getting the name of a #<procedure>

2 posts · 3648 views

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/

Re: Getting the name of a #<procedure>

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
(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
mz -lli errortrace scheme
but it will be more difficult to read through traces.