Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to create Array'val literals #336

Open
mneumann opened this issue Aug 28, 2022 · 1 comment
Open

Make it easier to create Array'val literals #336

mneumann opened this issue Aug 28, 2022 · 1 comment

Comments

@mneumann
Copy link
Contributor

When I write e.g. [Pair(String).new("a", b"), ...] I get an Array'ref, but how do I turn this into a Array'val? On the callee side, I can use an argument type Array'box which works fine, though just curious, if the argument type would be Array'val, how would I create an Array literal asArray'val?

@jemc
Copy link
Contributor

jemc commented Aug 30, 2022

We do not yet have "recover" blocks as in Pony, or proper region analysis that would be used to construct such a feature.

As a result, the only way to create an Array'iso or Array'val literal, is to ensure that each element has a sendable cap. If that condition is met, then any array literal which is being "assigned to" something of a val or iso type will be automatically lifted to a val or iso array literal.

In this case, your example failed only because Pair.new creates ref objects.

In lieu of recover blocks, this problem can be sidestepped by adding a val and/or iso constructor to the Pair type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants