<fluttershy_>
Hello, If I can't recover ref to iso, then what should I do to send the variable, should I create another box alias and recover to val to send ? https://is.gd/6otf1g
<fluttershy_>
still having trouble there.
<fluttershy_>
SeanTAllen: you told me there are multiple errors, but I can't find them.
virtual_lark has joined #ponylang
<doublec>
fluttershy_: did you solve your problem?
<fluttershy_>
no
<fluttershy_>
:(
<fluttershy_>
can you help me please ?
<doublec>
fluttershy_: what are you trying to do?
<doublec>
fluttershy_: you can't convert a ref to an iso, unless you created that ref inside a recover block and are returning it as an iso from it
<doublec>
fluttershy_: in your code you have a 'dosomething' that gets a 'ref' and tries to recover it to an iso which can't be done.
<doublec>
fluttershy_: why do you want to make an iso from a ref in the first place?
<fluttershy_>
well to send it later
<fluttershy_>
in that case how to chage the code to make the function return sendable
<doublec>
fluttershy_: To make what function return sendable?
<doublec>
fluttershy_: dosomething?
<doublec>
fluttershy_: or give_me_ref?
<fluttershy_>
give_me_ref
<doublec>
fluttershy_: unfortunately you can't. if give_me_ref gets a 'ref' as an argument, you can't make that sendable.
<doublec>
This makes sense - if there's a ref for it there's possibly multiple aliases to the object and it's unsafe to send, therefore unsafe to convert to an iso.
<fluttershy_>
because I have a primitive that have almost a thousand of functions, that do almost the same thing
<doublec>
fluttershy_: can you make the 'matrix' field in 'Foo' an iso?
<doublec>
fluttershy_: then it's sendable automatically
<doublec>
fluttershy_: or can you copy the matrix? Then you can copy it to a val or iso.
<fluttershy_>
actually I don't want to do any copies
<fluttershy_>
the matrix field can stay ref no ?
<doublec>
fluttershy_: Not if you want to send it anywhere. the matrix field needs to be val or iso.
<fluttershy_>
because a ref can consume an iso
<fluttershy_>
hemmm
<doublec>
Just make the matrix field an iso and then consume it when you send it.
<fluttershy_>
so in the return of the function what should I put
<doublec>
using the destructive read syntax to replace it with someting after consuming it
<doublec>
I don't understand why you'd need give_me_ref in this case
<doublec>
If it's an iso you can send it automatically
<doublec>
Why do you need to get a ref from it?
<fluttershy_>
no just forget the name
<fluttershy_>
in general
<doublec>
fluttershy_: in general what you are doing makes no sense
<fluttershy_>
when I have a function in a primitive like that one
<doublec>
fluttershy_: so you'd really need to explain exactly what you want to do
<doublec>
eg. give_me_ref - why do you want a ref if you want to send it?
<doublec>
If you have a function in a primitive that returns a ref you can't send it
<doublec>
Unless you call that function in a recover block
<fluttershy_>
so I change the return type to iso or val
<doublec>
That won't work for other reasons, but that's why I mean by calling it in a recover block.
<doublec>
Presumably 'give_me_ref' copies it or creates some other object that it returns as the ref
<doublec>
If so, return it as an iso is another alternative
<fluttershy_>
it doesn't compile
<doublec>
fluttershy_: I know - that's what I meant by "that won't work for other reasons"
<doublec>
fluttershy_: Without knowing your actual problem I can't really provide a working solution.
<doublec>
Currently, if your problem is "I want to send to another actor the result of a function that returns a ref" then there is no solution.
<doublec>
Unless you call that function in a recover block
<doublec>
But you also pass a field to that function which you can't do in a recover block if that field is a ref
<doublec>
So I changed the field to an iso. But then you need to consume it when calling the function, which is what my example doesn't do.
<doublec>
Since to consume a field you have to replace the field with some other value using destructive read.
<doublec>
And I don't know if that's what you want.
<fluttershy_>
well I understand what you say, my problem is how to make that function in the primitive return a spendable
<fluttershy_>
doublec: thank you.
<doublec>
fluttershy_: yes, that sounds right.
jemc has joined #ponylang
nyarum has joined #ponylang
<fluttershy_>
doublec: one more question please, why isn't it possible to recover to iso when I pass to the function a ref field, as I am recovering the reference returned by the function not the field ?
aav has quit []
<doublec>
fluttershy_: it's the same underlying pointer
<doublec>
fluttershy_: which means you have multiple writeable aliases
<doublec>
fluttershy_: You can only convert a ref to an iso if the compiler can prove there are no other aliases of that ref
<doublec>
fluttershy_: and the only way it can do that is if the ref is created in a recover block.
<fluttershy_>
I see, thanks.
<doublec>
fluttershy_: The "aha" moment for me was when I realised how everything was the same underlying pointer when converting from iso/ref/val/etc.
<doublec>
fluttershy_: suddenly it becomes clear why you can't convert a ref to an iso - because if you have multiple pointers to the same object (ref) then you can't have an iso which guarantees a single pointer to an object.
<doublec>
fluttershy_: And from that viewpoint adaption becomes intuitive - if you can only have a single pointer to an object, it restricts what pointers you can pass out to fields of that object.
<doublec>
etc
<fluttershy_>
yes, sounds reasonable
fluttershy_ has quit [Quit: Page closed]
aav has joined #ponylang
virtual_lark has quit [Read error: Connection reset by peer]
nyarum has quit [Remote host closed the connection]
nyarum has joined #ponylang
wintermoo has joined #ponylang
nyarum has quit [Ping timeout: 245 seconds]
wintermoo has left #ponylang ["Leaving"]
TheLemonMan has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
nyarum has joined #ponylang
nyarum has quit [Ping timeout: 240 seconds]
vaninwagen_ has joined #ponylang
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]