Garth Goldwater
08/13/2020, 8:34 PMthis = newObject
. that’s impossible in javascript—`this` is immutable and i’m not even sure how you’d update all the references in a coherent way (although i’m pretty sure it would make sense if you were doing enough pointer indirection). does anyone know of any cursed programming systems that let you do that kind of thing? i think there’s kind of an analogy in terms of replacing a server at a certain domain—all the hyperlinks stay pointing right at your new objectibdknox
08/13/2020, 8:40 PMDoug Moen
08/13/2020, 8:55 PM*this = newObject;
.Andrew F
08/13/2020, 8:57 PMMariano Guerra
Ivan Reese
Array.prototype.map
but that mutates the array rather than returning a new array?
Or are you thinking something like... arr[x] = fn(arr[x])
, but where the function somehow knows about the array so that you can just call it like fn(arr[x])
and it takes care of updating the array?
Or are you basically asking for become:
? Your domain / hyperlink example makes it seem like that's what you're after, and in this case the fact that arrays are involved is irrelevant.
Let me know what you want the calling context to look like, and I'll see if I have anything in one of my dustier tomes.Garth Goldwater
08/13/2020, 9:46 PMbecome
, i think.
specifically i’m experimenting with going all out on the idea of message networks (making up this vocab as i go along)—so instead of map
or cata
, i’m seeing if i can do stuff like have arrays “broadcast” messages to their children recursively. something like:
Array.prototype.broadcast = function(message) {
this.map(i => i.broadcast? i.broadcast(message) : i[message]())
}
so ideally the objects in an array would update themselves in-place without having to reassign at the array-level/parent-level abstraction, if that makes sense
turns out my mental model of references as “pointers with extras” was wrong lmao—thank you @ibdknox
@Mariano Guerra this is gold i had never heard of become
before thank youGarth Goldwater
08/13/2020, 9:47 PMwtaysom
08/14/2020, 3:32 AMbecome:
. Works well for state machines.