Closed algebraic-dev closed 1 year ago
@Derenash what do you think?
Can I use the get without assigning the value to a variable? Can I do this?
let a = Tup5.new 1 2 3 4 5
let b = Tup5.new 6 5 4 3 (!Tup5 a .snd)
or this?
let a = Tup5.new 1 2 3 4 5
let b = Tup5.new 5 6 7 8 9
let a = !Tup5 a .snd @= λx (+ (!Tup5 b .snd) x)
Yep. Both of these should work.
Can someone explain mutter
in more detail? This is the first time I hear about this concept next to setter
/getter
.
Is there anything like that in e.g. C++ or JavaScript?
let thing = !Thing thing .object .pos .x @= λx (+ x 1.0) // mut
This seems to be the same as += 1
, but also able to create more complex calculations without the tedious a.b.c.d.e.x = fn(a.b.c.d.e.x)
, simply a.b.c.d.e.x @= fn
?
Yep, the example I gave in the first comment is similar to thing.object.pos.x @= (x => x + 1)
or simply thing.object.pos.x += 1
. The difference is that we are in a functional language and therefore the data is immutable, so something like !Thing thing .a .b @= f
should be translated into a sequence of mutters like Thing.a.mut thing (value_ => OtherThing.b.mut value_ f)
instead of a local mutation that would happen in imperative languages.
Changed the setter syntax to:
!Thing thing .object .pos .x = 10
That was fast...