profile
viewpoint

Ask questionsAdd test case for string `eq?` behavior

Strings should have the following equality behavior:

> (eq? (list->string '(#\a #\b)) (list->string '(#\a #\b)))
#f
> (string=? (list->string '(#\a #\b)) (list->string '(#\a #\b)))
#t

Because strings are represented as JavaScript objects, we might be accidentally getting value equality instead of reference equality for eq? on strings. We should add a test case to make sure we have the right behavior, and fix it if we don't.

google/schism

Answer questions eholk

Thanks for the clarifications!

You make a compelling case for being willing to break from the standards as it makes sense. I haven't closely followed the standards process, but I gather that R6RS was contentious, and R7RS-large seems unlikely to finish.

There may not be much reason to do this, but I don't think making list->string create a new object necessitates also supporting mutable strings. For example, I might want some kind of unique tag that I can test with eq?, but not want to use gensym for some reason.

I have "list->string makes a new string" pretty firmly embedded in my mental model for Scheme, so my vote would still be to keep that.

I haven't really had any use for mutable strings yet in Schism, or other Scheme implementations that I can think of, so I think it makes sense to hold off on adding them until there's a clear use, if ever. If Schism gets some kind of custom data type support in the future, we might be fine to just add a mutable string library that defines its own parallel string type.

useful!

Related questions

First class procedures hot 1
Add a command to compile a file to .wasm hot 1
Github User Rank List