Skip to content

Conversation

@MattHeffron
Copy link
Contributor

This seems to fix the issue (#1375) with printing "control characters" in #\Name format.

It appears to be impossible to get the canonical STRING representing the NAME of a LITATOM/SYMBOL (without its PACKAGE). That isn't stored anywhere as a STRING. A new STRING is created every time.
However, (STRING "foo") will return the same instance of "foo", so it doesn't create a new STRING unless required.

This commit was on top of the recent master with Remake-CMLARITH-filemap merged (tag: medley-231029-e2d8c9e5).
I also deleted the .DFASL, and forcibly compiled to .LCOM.

Copy link
Contributor

@nbriggs nbriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in CL:CODE-NAME Looks good - but why is file CMLARITH in this branch? It's not involved in the fix and therefore I don't see why we should be changing it.

@nbriggs
Copy link
Contributor

nbriggs commented Oct 31, 2023

Ah, now I see your comment about CMLARITH - I guess that's OK, though it is not the way I would do it.

@rmkaplan
Copy link
Contributor

rmkaplan commented Oct 31, 2023 via email

@masinter masinter merged commit bdf03e0 into master Oct 31, 2023
@rmkaplan
Copy link
Contributor

This is essentially the IL:MKSTRING solution, it makes the error go away at the cost of creating a new string pointer but not a new pname) on each call if IL:CHARACTERNAMES is, as specified in IRM, an alist with litatom CAR's.

So if this is an inner-loop function, there may be a performance issue, as we talked about. But maybe that is small compared to all the other overhead of simply outputting a character.

@MattHeffron
Copy link
Contributor Author

MattHeffron commented Oct 31, 2023

@rmkaplan As I stated in the comment above, the internal data structure for a LITATOM (same as LISP:SYMBOL) doesn't store the pname as a STRING, all functions that get the pname for a LITATOM create a new string instance.

As far as any additional performance hit, the potential call to LISP:STRING is only for characters in the IL:CHARACTERNAMES list, which are extremely unlikely to occur.

Also, technically IL:CHARACTERNAMES isn't a true ALIST, because the character-code is not the CDR of the list entry, but it's the CADR. I suppose that means that the STRING representation of the name could be placed in the CADDR (or CDADR) of the list entry, and only require using the LISP:STRING function if that value wasn't present. We'd need to verify that nobody depends on any other shape of the entries in IL:CHARACTERNAMES.

@rmkaplan
Copy link
Contributor

rmkaplan commented Oct 31, 2023 via email

@nbriggs
Copy link
Contributor

nbriggs commented Oct 31, 2023

I haven't found any inner-loop uses of CL:CHAR-NAME -- doing a compilation (TCOMPL) with @MattHeffron's change seems to create one extra ONED-ARRAY object to get the name of Newline. So, I think this is just fine.

@masinter masinter deleted the Issue-1375-fix-CL_CHAR-NAME branch December 2, 2023 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants