Subject: bug#48448: 'procedure-name' returns #f if name is #{}# (the empty symbol)

From: Taylan Kammer <[email-masked]>
Date: Sun, 16 May 2021 01:33:00 +0200

On 15.05.2021 20:27, Maxime Devos wrote:
> guile --version: 3.0.5
> In a REPL:
> 
> (let ((#{}# (lambda () 0)) (something-else (lambda () 0)))
>   (map procedure-name (list #{}# something-else)))
> --> $20 (#f someting-else)
> 

The problem seems to be that once the compiler produces bytecode,
there is no distinction anymore between a missing name and a name
that is the empty string.

See the procedure link-symtab in module/system/vm/assembler.scm
line 2345.  For every piece of metadata (this includes the names
of procedures), it puts it into the string table, and conflates
a missing name (name = #f) with the empty string:

  (string-table-intern! strtab (if name (symbol->string name) ""))

I'm guessing that changing this would not be worth the effort,
although this isn't my area of expertise.  (I spent more than an
hour trying to figure out the source of the issue, though it was
a great learning experience.)

One could even argue that if you name a procedure after the empty
string... it has no name, right? ;-)

I'm marking this as a minor bug.

--
Taylan