<TwoNotes>
SeanTAllen, the message suggests that calling a function creates an alias of the receiver. I am wondering why it would do that. Passing it as a parameter I would understand
<TwoNotes>
foo.n=3 is OK, but foo.set_n(3) is not.
<TwoNotes>
Perhaps there is a "this" created inside the execution of the function? And that is a copy of the receiver?
<TwoNotes>
This makes it impossible to call multiple methods on an iso
<SeanTAllen>
I still dont understand what Foo.set_n is supposed to be doing
<TwoNotes>
I agree that 'consume this' is nonsensical.
<TwoNotes>
set_n is mutating the Foo object
<TwoNotes>
But putting in the nonsensical 'consume this' keeps the compiler happy. Ergo, I think the compiler needs to be smarter about 'this'
<TwoNotes>
'this' goes out of scope at the end of a fun call. It evaporates. Imagine if the function call was expanded in-line by the optimizer.
<SeanTAllen>
I don't understand why you wouldn't create a new Foo
<SeanTAllen>
but this is very off topic from your question
<TwoNotes>
"Foo" in my case is a massive object with lots of fields in it. I make multiple calls putting info in those fields. Then I want to send a 'val' version of it to another actor
<SeanTAllen>
looking at String.add in the standard library, I see why it's doing it. I still find it to be an odd API in that standard library case.
<SeanTAllen>
TwoNotes: I think you want a `trn`
<TwoNotes>
Ah, since the 'this' inside the function is only read from?
<SeanTAllen>
I don;t follow
<TwoNotes>
The receiver is used to locate the instance of Foo to be operated on. The "n=m" is really this.n = m
<TwoNotes>
It is reading from 'this'
<SeanTAllen>
Still don't understand. I'm looking at your gist and I don't see anything about locating instances.
<TwoNotes>
It is inherent in calling a method on an object!
<SeanTAllen>
I don't understand
<SeanTAllen>
If you want to create a mutable object that can later be made immutable and sent to another actor, `trn` is what you want.
<SeanTAllen>
dinner time for me though. stepping away.
<TwoNotes>
So the "trn" goes on the Foo constructor?
<TwoNotes>
So trn on the constructore, ref on the functions, and the other actor will get it as a val