this = , and anObject.=

.= should replace all the internal pointers to an object with another, and this= should be like .= but it preserves this

var obj = {}
var o = obj
console.log(getAddress(obj) +''+ getAddress(o)) //address of obj twice
obj.={}
console.log(getAddress(obj) +''+ getAddress(o)) //different address twice
var obj = {}
var o = obj
console.log(getAddress(obj) +''+ getAddress(o)) //address of obj twice
obj={}
console.log(getAddress(obj) +''+ getAddress(o)) //different address, and then address of obj

should be preventable by Object.lockIdentity(anObject)

I'm not sure I understand how this is different from normal assignment. I believe your example code snippet would function exactly the same if you replaced ā€œ.=ā€ with just ā€œ=ā€.

1 Like

o isn't an alias

I'm not sure I follow still. And I'm wondering if there's perhaps a misunderstanding on how references work in JavaScript.

Do you think you could provide an example that uses the ā€œ.=ā€ operator and includes some console.log()s with comments explaining what that would output. I’d like to then be able to swap the ā€œ.=ā€ for a normal ā€œ=ā€, paste it in a JavaScript file and run it, and observe the console.log() behave differently then what you have commented (so it's clear this does behave differently). If I had something like that, I think it would be clearer, to me, what this operator does.

1 Like

What do you mean "address"? JS doesn't have those.

1 Like

the getAddress(anObject) is something I made up

There are no first-class "references" in JS, either. https://web.archive.org/web/20161005155047/http://www.jon-carlos.com/2013/is-javascript-call-by-value-or-call-by-reference/

2 Likes

I know, but by reference I mean pointer, it will be corrected

There are no first-class pointers in JS.

1 Like

internal pointers, I know there are no first class pointers. Please stop telling me stuff like that, I already know it

Then I'm really confused what you're trying to do. What would obj .= {} do? Can you explain without using a nonexistent API like getAddress?

2 Likes
var obj = {become(anObject){
    this=anObject;
    return this;
}};
var o = obj.become({})
console.log(obj===o) // false
var obj = {};
var isArr = Array.isArray(obj);//false
obj .= [];
Array.isArray(obj);//true

Object identities are forever immutable quite on purpose - also, that would be the first time that assignment inside a function affected a binding outside the function, which would be a horrific and fundamental change to the language.

What problem do you hope to solve?

1 Like

I might wanna be able to make a non array turn into an array and back

Why? That's a pretty important invariant you want to get rid of (that you can't do that).

1 Like

making my mod of Snap! super advanced (its ok if I can't because I can just port it to Smalltalk)

like proposal refs ?

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

2 Likes

but with the internal object pointers instead of references