Artyom,
On 2026-08-06 04:46 +0400, Artyom Bologov wrote:
> Thanks for the recommendations, these are all valid approaches and I no
> longer feel the necessity for an uh… unnecessary SRFI!
There may still be room for improvement here. ‘rec’ does the job, but
its purpose is to define recursive procedures. Thus the name given
with ‘rec’ is bound in the body of the procedure, which is irrelevant
if all you want is a name for error-reporting purposes.
I notice that some Schemes extract names from ‘let’ bindings for error
reporting, e.g. chibi:
> (let ((foo (lambda (x)
(/ 4 x))))
ERROR in foo on line 1: divide by zero
In this case, of course, the procedure has a name that isn’t bound in
its body. It seems you can abuse chibi’s behavior to create named,
non-recursive procedures:
(define-syntax named
(syntax-rules ()
((named name proc)
(let ((name proc)) name))))
> ((named foo (lambda (x) (/ 4 x))) 0)
ERROR in foo on line 5: divide by zero
Obviously this is implementation-dependent. Something like Peter’s
procedure-property solution seems much better.
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>