Why is an example use of an "iso" parameter?

350 Views Asked by At

In the tutorial, an iso variable gets aliased as trn:

fun test(a: Wombat iso) =>
  var b: Wombat tag = a // Allowed!

But I am wondering what is the actual use case for getting an iso variable, if you can't read from it?

Say, can I do something like this?

fun test(a: Wombat iso) =>
  var b: Wombat tag = a // Allowed!
  env.out.print(a.name())
1

There are 1 best solutions below

1
On BEST ANSWER

Reference capabilities explains:

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.

It means it's perfectly fine to read from iso reference.

You can test your example code in Pony sandbox and see for yourself.