Rename to identifier with spaces, yay

Today, just for fun, I used DrRacket's "rename identifier" to rename the identifier "foo" to "foo 123". It cheerfully did the replacement, including spaces. I should file this as a bug, yes?

3 Likes

It's legal to use space in identifiers. For example:

#lang racket
(define |foo 123| 5)
(displayln |foo 123|)  ;==> 5
(displayln '|foo 123|) ;==> foo 123

(Anyway, I can't imagine when it's a good idea.)

1 Like

I think that renaming should use |foo 123| as @gus-massa says; the fact that it doesn't is a bug.

3 Likes

If this is changed in DrRacket does racket-langserver automatically get the enhancement?

S.

No, they won't since langserver new text is given from LSP client, so the fix should be in the server(I would send a PR to fix it)

Track wrap identifier with `|` to get valid renaming by dannypsnl · Pull Request #80 · jeapostrophe/racket-langserver · GitHub

1 Like

Thank you :star_struck:

So does DrRacket use the langserver now?

S.

No, I think the situation is DrRacket and racket-langserver both use syncheck-annotations<%>, but due to client's difference they need to separately dealing this problem.

1 Like

TO GUS-MASSA

(Anyway, I can't imagine when it's a good idea.)

I can, for example as the first argument of procedure error.

Jos

DrRacket used to do that, but it doesn't now because that is making assumptions about the syntax of identifiers that don't seem right in our LOPy world. In other words, it is on purpose that it puts just the characters there for you.

It might make sense to allow languages to specify how to turn some string into the syntax of an identifier, I suppose, and then read-based languages can do the needful. But doing it all the time is probably a bad idea.

6 Likes

Shamefully, I use this feature to add new arguments to functions.

7 Likes

awesome! Or maybe right parens?

3 Likes

“Shamefully, I use this feature to add new arguments to functions."

+1

3 Likes

A syntax property on identifiers with a regex that says what the legal characters are would at least be a minor LOP-aware improvement here, since then DrRacket could reject the replacement (or just warn about it) instead of doing the wrong thing. A similar property for how to escape characters would also work but I don't have a clear idea of what that would look like.

3 Likes

No shame in that!

Would this be a good quickscript?

S.