Champion Needed (Proposal) — Pass-By-Ref for Primitives

Looking for a champion for my proposal:

GitHub - jason-ford-x/proposal-ref-class: A Javascript wrapper class that provides control and management of pass-by-reference behavior for all data types

I am not a low-level Javascript expert and that may be painfully noticeable from my proposal, so any technical feedback would be appreciated.

I’m also looking for advice on how to develop the POC transpiler etc.

Your repo doesn't explain why it's a problem that JS is explicitly and always pass by value.

Each of the Use Cases is sort of implicitly stating ‘not being able to do it this easily is an ergonomics problem/not currently possible at all’.

I will update to more explicitly state what obvious/subtle problem(s) exist that the proposal addresses.

Right, but why? What are you able to accomplish in return for making the language massively more complex?

Hi,

Each of the Use Cases is sort of implicitly stating ‘not being able to do it this easily is an ergonomics problem/not currently possible at all’.

Not being able to do this is a good thing, not a problem.

Transparent syntax for assigments makes it ambiguous what will happen,
since it now depends on the current value of the variable (if I
understand your proposal correctly).

I really don't want my primitive bindings changed from a different
scope, explicit or not - it's spooky action at a
distance

and makes code harder to understand.

It’s opt-in, that primitive would have to be set up as a Ref in the first place.

You can’t change the value of a Ref via assignment, only by using Ref.set(theRef,theNewValue). Syntax like n++/n += 1 is a special case since it’s sort of a self-update/shorthand and not a traditional assignment.

Working with Ref is not that different from working with Proxies; that type was chosen probably for the set/get traps as a way to trigger changes elsewhere.

The entire Use Cases section demonstrates what becomes possible/easier. Plenty of enhancements are about ergonomics and/or providing a built-in way to do something old/new for the purposes of removing common boilerplate/workarounds across the web. For example, Symbol/Reflect are indispensable for some developers, but most won’t ever need them.

You can already just pass an array or an object (or a userland class) holding a pointer to whatever you want, and if you're comfortable with requiring .set to change it, why not also require .get to access it? Then you don't need any language change at all. (this is also how React's pre-hooks "context" works)

like proposal refs ?

rbuckton/proposal-refs: Ref declarations and expressions for ECMAScript

I’ve been sent this before; that proposal is untouched for ~8 years and is quite different, it’s specifically about decorator closure references (if I’m understanding it correctly)

I’m writing up a library to see how close I can get to my desired syntax/functionality. I will then create a robust gallery of before/after code examples.

It is true that if I compromise and provide get/set methods, it’s mostly doable today, but I’m not satisfied with the ergonomics of that.

It is not specifically about decorators. That is just one use case.