Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Mutable strings #2358

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

[wip] Mutable strings #2358

wants to merge 3 commits into from

Conversation

hmdne
Copy link
Member

@hmdne hmdne commented Nov 12, 2021

tl;dr: How to implement mutable Strings while preserving compatibility

For boxed strings we are allowed to declare toString and valueOf properties on them. Not length though. So what if we made those methods actually return a different string?

This is an early work in progress.

@hmdne hmdne changed the base branch from master to hmdne/dont-get-self November 12, 2021 03:07
@hmdne
Copy link
Member Author

hmdne commented Nov 14, 2021

The issue with this is that all String methods and alike should return a mutable string value and none of them do - which, on the other hand, is good for performance and JS library compatibility - JS libraries often check for typeof arg === 'string' - and boxed strings would give us object, not string. Boxed values are in general a little known feature that some people think should be deprecated.

There are also a lot of issues with boxed values in JavaScript. Eg.

> "hello" === new String("hello")
false
> new String("hello") == new String("hello")
false
> 

@hmdne hmdne force-pushed the hmdne/dont-get-self branch 5 times, most recently from 340b6fa to 5202526 Compare November 14, 2021 14:18
Base automatically changed from hmdne/dont-get-self to master November 24, 2021 12:01
@elia elia added this to the v2.0 milestone Aug 26, 2022
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.

2 participants