Closed cursorweb closed 3 years ago
Why can't you just store this as a normal type in the regular variable store, and have that type be
Ref(Arc<Type>)
so when an assign is made to a type of Ref
, it will instead mutate the inner type? There are a lot of problems with doing this, and I'd also like to note that Rust allows mutation of &mut T
's with this syntax: (untested, probably some kind of error)
let mut foo = 1;
let foo_ref = &mut foo;
*foo_ref = 2; // note the * here
assert_eq!(foo, 2);
This is important because it distinguishes between mutating the (mutably) borrowed data (of foo
) and changing what foo_ref
is pointing to. I suppose the equivalent would be
ref a = t_a;
?
You'll need to ponder the implications of this syntax.
Amazingly, that Rust code worked first try :D
amazing, I'll look into it!
good bye stupid bug
Hahahah
As arrays and maps become increasingly hard to implement due to a big problem: references.
Take this example:
(figure 1)
at the moment with what we have, implementing this will be pretty much impossible, albeit I haven't implemented it yet.
Also take this planned example:
(figure 2)
Proposed solutions
References is a 'type', and it is:
where
Token
is the variable where the original data is stored.Pros: figure 2 Cons: figure 1
References are in a new HashMap called the 'heap'. They include values that can get mutated.
Pros: Solves both figures 1 and 2 if implemented correctly. Cons: Very very hard to implement correctly
We make a mutable reference of the environment and just mutate them around Pros: Solves both figures 1 and 2 if implemented correctly. Cons: The ref type still might be needed