Last active
May 25, 2018 23:18
-
-
Save pzel/fef1416c2d29532257898e4640579283 to your computer and use it in GitHub Desktop.
Returning internal state as a val to a promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This works | |
actor Router | |
let _env : Env | |
var _notifiers : Map[String val, ChatSession tag] | |
new create(env: Env) => | |
_env = env | |
_notifiers = Map[String val, ChatSession tag].create(10) | |
fun ref _user_list() : Array[String] val => | |
var result : Array[String] iso = recover Array[String] end | |
for k in _notifiers.keys() do result.push(k) end | |
recover val result end | |
// This fails: | |
fun ref _user_list() : Array[String] val => | |
recover val Iter[String](_notifiers.keys()).collect(Array[String]) end | |
// Error: | |
// (..)/chat/chat.pony:169:30: can't access field of non-sendable object inside of a recover expression | |
// recover val Iter[String](_notifiers.keys()).collect(Array[String]) end | |
// ^ | |
// Info: | |
// (..)/chat/chat.pony:160:3: this would be possible if the field was sendable | |
// var _notifiers : Map[String val, ChatSession tag] | |
// ^ | |
// This fails as well: | |
fun ref _user_list() : Array[String] val => | |
var result : Array[String] ref = recover Array[String] end | |
Iter[String](_notifiers.keys()).collect(result) | |
recover val result end | |
///chat.pony:172:5: can't recover to this capability | |
// recover val result end | |
// ^ | |
// Info: | |
// ...chat.pony:172:17: expression type is Array[String val] tag^ | |
// recover val result end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment