为什么示例使用 "iso" 参数?
Why is an example use of an "iso" parameter?
在 tutorial 中,一个 iso
变量被别名为 trn
:
fun test(a: Wombat iso) =>
var b: Wombat tag = a // Allowed!
但我想知道如果您无法从中读取 iso
变量,那么获取该变量的实际用例是什么?
说,我可以做这样的事情吗?
fun test(a: Wombat iso) =>
var b: Wombat tag = a // Allowed!
env.out.print(a.name())
Isolated, written iso. This is for references to isolated data
structures. If you have an iso variable then you know that there are
no other variables that can access that data. So you can change it
however you like and give it to another actor.
这意味着从 iso 参考中读取完全没问题。
您可以在 Pony sandbox 中测试示例代码并亲自查看。
在 tutorial 中,一个 iso
变量被别名为 trn
:
fun test(a: Wombat iso) =>
var b: Wombat tag = a // Allowed!
但我想知道如果您无法从中读取 iso
变量,那么获取该变量的实际用例是什么?
说,我可以做这样的事情吗?
fun test(a: Wombat iso) =>
var b: Wombat tag = a // Allowed!
env.out.print(a.name())
Isolated, written iso. This is for references to isolated data structures. If you have an iso variable then you know that there are no other variables that can access that data. So you can change it however you like and give it to another actor.
这意味着从 iso 参考中读取完全没问题。
您可以在 Pony sandbox 中测试示例代码并亲自查看。