jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang | Please consider participating in our mailing lists => https://pony.groups.io/g/pony
atk has quit [Quit: Well this is unexpected.]
atk has joined #ponylang
autodidaddict has joined #ponylang
<autodidaddict> if I have a "non-sendable" field inside an actor, how do I send that to another actor?
<autodidaddict> field is declared as "let _coll: Array[String]"
<autodidaddict> I get an error trying to send "recover _coll end"
<autodidaddict> "can't access field of non-sendable object inside of a recover expression"
<SeanTAllen> you don't
<autodidaddict> ok..so how do I give an actor a list of values?
<SeanTAllen> so you have a mutable array that you want to send to another actor?
<SeanTAllen> you'd need to send an immutable copy
<SeanTAllen> OR
<autodidaddict> it is mutable at the time, I want to send an immutable value
<autodidaddict> yeah, I know I need immutable
<autodidaddict> it's the syntax to produce it that I can't get
<SeanTAllen> do you need access to it after you send the immutable list?
<SeanTAllen> or can you start over with a new empty list?
<autodidaddict> no
<SeanTAllen> ok
<SeanTAllen> if you can start over with a new empty list
<SeanTAllen> you want to do a destructive read of an iso
<SeanTAllen> take a look at how readbuf is used in TCPConnection
<SeanTAllen> i should really write this up as a pony pattern
<SeanTAllen> so we have
<SeanTAllen> ` var _read_buf: Array[U8] iso`
<SeanTAllen> then line 782
<SeanTAllen> ` let data = _read_buf = recover Array[U8] end`
<SeanTAllen> what we have done there is assign the old value of _read_buf to `data`
<SeanTAllen> and reinitialized the field `_read_buf` to a new empty array
<SeanTAllen> then we can consume data and send it to the notify object which in turn can send to other actors
<SeanTAllen> ` if not _notify.received(this, consume data, received_called) then`
<SeanTAllen> make sense autodidaddict?
<autodidaddict> yes, that's what I've been trying to do for about an hour ;)
<autodidaddict> let output = _coll = recover Array[String] end _target.receivecollection(output)
<autodidaddict> Array[String val] ref is not a subtype of Array[String val] val: ref is not a subcap of val
<autodidaddict> if I do "consume output" as a parameter to receivecollection, I get:
<autodidaddict> "Array[String val] ref is not a subtype of Array[String val] val: ref is not a subcap of val"
<autodidaddict> same error
<autodidaddict> I've just been going in circles trying to get this syntax right
<SeanTAllen> what is _coll defined as?
<SeanTAllen> should be `Array[String] iso`
<SeanTAllen> got to run
<SeanTAllen> dinner
<autodidaddict> got it. That was super counter-intuitive
<autodidaddict> :(
<autodidaddict> Thanks for clearing that up
<autodidaddict> trying to convert an actor that works on an array of strings to an actor that works on an array of "T" as a generic actor is giving me fits
<autodidaddict> Tried [A: Any #share!], [A: Any #read!] for the "var _coll: Array[String] iso" field
<autodidaddict> I figure if I eventually try all possible permutations I'll find the right one.. but again docs and code are not giving me any hints on how to narrow down the right constraint
<autodidaddict> looks like "[A: Any #send!]" is the magic combo
<SeanTAllen> I get asked that question at least once a month. Really need to find time to write up a pattern for it
<SeanTAllen> it should be #send not #send! autodidaddict
<SeanTAllen> you want any shareable thing
<autodidaddict> #send doesn't compile
<SeanTAllen> do you have a small snippet?
<autodidaddict> be receive(s: A) => _coll.push(s) //_env.out.print("collector:" + s) if _coll.size() == _max then _env.out.print("collector is full") let output = _coll = recover Array[A] end _target.receivecollection(consume output) end
<autodidaddict> this receive function is where the compilation failure happens if I don't include the !
<SeanTAllen> can you put the smallest example you can in a playground gist?
<SeanTAllen> right
<SeanTAllen> so your problem is here:
<SeanTAllen> _coll.push(s)
<SeanTAllen> s might be an iso
<SeanTAllen> so i made one small change autodidaddict :
<SeanTAllen> the change is on line #19
<SeanTAllen> as well as changing #send! to #send
<autodidaddict> gotcha
<autodidaddict> ok.. consume/recover is still very much black magic to me. I don't know (definitively) what it does, when I should use it.. I just wait until I see a compiler error that hints at me needing it
<SeanTAllen> consume "destroys" an alias
<SeanTAllen> its how you indicate to the compiler that you are giving up access to an alias such as an iso
<SeanTAllen> when you consume an iso
<SeanTAllen> there are no more aliases so you can do what you want with it
<SeanTAllen> including making it a val, ref etc
<SeanTAllen> recover allows you to lift a reference capabality to a new one (assuming is allowable)
<autodidaddict> yeah, I get the definitions
<autodidaddict> it's more the "when/why" do I need to consume an alias or an iso
<SeanTAllen> you should never alias a trn or an iso
<autodidaddict> I suppose that'll just come as a result of the "frustration over time" function
<SeanTAllen> so anytime you find yourself doing that, you want to consume
<SeanTAllen> it will come
<SeanTAllen> the hard part is in the beginning you are thinking about this new thing
<SeanTAllen> rather than what those new things represent
<SeanTAllen> i knew what iso was but i didnt put that into my thinking when i first started
<SeanTAllen> i was too focused on the "new"
<SeanTAllen> and not thinking "right iso means only 1 alias"
<autodidaddict> Good news is I figured out the pattern for my "interrogate data from a collection of actors" problem ;) Blog post forthcoming
<SeanTAllen> most folks usually start to get the hang of it in 2 to 4 works of running into it a lot
<SeanTAllen> awesome!
<SeanTAllen> if you can PR it to the website and add it to the "last week in pony" issue, that would be awesome
<autodidaddict> forewarning: I will be using puns
<SeanTAllen> i wont hold it against you
<SeanTAllen> also
<SeanTAllen> if you could eventually turn your post into something that conforms to the "pony patterns" format and PR it there... that would be awesome
<autodidaddict> I'll put all that on my todo list after writing the actual content ;)
<SeanTAllen> Sounds good
<SeanTAllen> ok i am off to watch game of thrones
<SeanTAllen> ttyl
<autodidaddict> valar dohaeris
autodidaddict has quit [Ping timeout: 260 seconds]
<cquinn> luck east cost HBO person :)
<cquinn> s/luck/lucky/
aceluck has joined #ponylang
<SeanTAllen> i think its available on HBO now on an east coast schedule. ¯\_(ツ)_/¯.
obadz has quit [Ping timeout: 260 seconds]
obadz has joined #ponylang
jemc has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 255 seconds]
aceluck has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 276 seconds]
aceluck has joined #ponylang
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
vaninwagen has joined #ponylang
aceluck_ has joined #ponylang
aceluck_ has quit [Ping timeout: 240 seconds]
vaninwagen has quit [Ping timeout: 240 seconds]
plietar has joined #ponylang
papey_lap has joined #ponylang
jemc has quit [Ping timeout: 268 seconds]
plietar has quit [Ping timeout: 240 seconds]
aceluck has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
plietar has joined #ponylang
plietar has quit [Ping timeout: 255 seconds]
plietar has joined #ponylang
plietar has quit [Ping timeout: 276 seconds]
plietar has joined #ponylang
plietar has quit [Ping timeout: 240 seconds]
oldmanmike has joined #ponylang
oldmanmike has quit [Ping timeout: 248 seconds]
aceluck has joined #ponylang
aceluck has quit [Ping timeout: 260 seconds]
plietar has joined #ponylang
fluttershy_ has joined #ponylang
plietar has quit [Ping timeout: 255 seconds]
aceluck has joined #ponylang
jemc has joined #ponylang
aceluck has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
plietar has joined #ponylang
fluttershy_ has quit [Quit: Page closed]
aceluck has joined #ponylang
plietar_ has joined #ponylang
plietar has quit [Ping timeout: 258 seconds]
TheNet has joined #ponylang
vak has joined #ponylang
<vak> hi all. Guys, i spent already almost one hour to get simple Map[MyActor, PrimitiveOrTypes] to get compiled. Don't know how to pass this message in a positive way (I understand that staying positive is very important)
<vak> i am still not able to add simple map to my Pony code and am puzzled by the compiler
<vak> could someone please add a simlple 10 lines example on how to create a Map-member of the class, initialize it, add and remove key-pairs?
<vak> it is such a basic thing and is still not much motivating when so much time is lost :-/
<vak> also, if "type Worker2State is Map[IWorker tag, Response]" then it would be so great to have at least "var _worker2state: Worker2State = Worker2State" working for a empty map
<vak> or at least "var _worker2state: Worker2State = recover Worker2State end" if it is needed
<vak> albeit if it is just an empty Map initialization then why not to allow it just be "var _worker2state: Worker2State" ? it would have been so much natural!
TheNet has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<vak> the central point of difficulty with Pony is definitely rcap. That is any simplicity around it would be a GREAT helping factor for newcomers
<jemc> vak: when it comes to rcaps, to a certain extent that's just a steep learning curve that has to be climbed to get the benefits of understanding the concepts and being able to communicate with the language about them
<jemc> probably the best effort we can do to ease that process is to improve any confusing compiler error messages
<jemc> if you're having trouble with maps, feel free to ask your questions here
<vak> oh, if compiler would have just give some hints (not olny dry statement in its inner semantics it would be great)
<vak> well my question is not only mine: https://github.com/ponylang/pony-tutorial/issues/190
<jemc> based on what bits and pieces you've shared, the issue you're probably having is that your `IWorker tag` is not `Hashable`
<vak> oh, ok...
<jemc> to be Hashable means to expose a `fun hash(): U64` method - however, you'll never be able to call that on a `tag` reference, since it requires a readable (`box`) receiver, and a `tag` is not readable
<vak> jemc: does it mean, that all the time if one maps from their custom interface, trait, actor or class then one needs to implement hash()?
<jemc> as I mentioned to you last week (https://irclog.whitequark.org/ponylang/2017-07-17#1500304560-1500304525;), you'll want to use `MapIs` instead of `Map`, since you need to compare based on identity (which can be done on an opaque reference) rather than structural equality (which cannot be done on an opaque reference)
<jemc> vak: any class that you want to support structural equality in collections should implement an `eq` method (`Equatable`), and a `hash` method (`Hashable`)
<jemc> but you don't need to implement anything to support identity equality
<vak> jemc: Map is probably one of the best containers to make a show case for rcaps. Honestly, after reading the whole tutorial I do belive that "containers" is the most important counterpart for the rcaps.
<jemc> and an actor can never support structural equality, since you'll never have the ability to read from the fields of two actors at the same time
<vak> jemc: MapIs, oh true... I stuck to the wrong one... thank you!
<vak> jemc: understood.
<vak> thank you!
<vak> damn... MapIs indeed immediatelly compiled...
vaninwagen has joined #ponylang
<vak> jemc: if keys of the Map are of the tag rcap, then there is no way any more to recover-end it to something on which a fun-method or be-method could be called?
<SeanTAllen> tag is opaque vak, you can't ever go from tag to something else
<vak> (i understand that Map is quite irrelevant in this question)
<SeanTAllen> tag allows comparing identity and sending messages
<SeanTAllen> nothing more
<vak> SeanTAllen: thank you!
<SeanTAllen> so
<SeanTAllen> you can call be-methods
<SeanTAllen> you can't call fun-methods
<vak> i see
<jemc> (well, you can call `fun tag`-methods, but those cannot access any fields, or do anything but call `be` methods or other `fun tag` methods)
amclain has joined #ponylang
<vak> wow....
<SeanTAllen> ?
<SeanTAllen> wow vak?
TheNet has joined #ponylang
<vak> SeanTAllen: i didn't realize this rcap consequences for 'fun tag'-methods etc.
TheNet has quit [Client Quit]
<SeanTAllen> fun tag can be useful but its an "advanced feature"
<vak> i guess it is exactly what i need when i work with workers and communicating with them via be-messages...
<vak> oh
<vak> stop :)
<vak> you said "fun tag" :)
<vak> i mean that rcap "tag" per se is the adequate rcap for storing references to workers and sending messages to them via be-messages :)
<SeanTAllen> yes
<SeanTAllen> tag is very handy for that
<cquinn> "fun tag"s are fun too. Nice for class methods, or convenience methods to do work on the caller side before invoking behaviors.
_andre has quit [Read error: Connection reset by peer]
_andre has joined #ponylang
<jemc> yeah, one trick I like for `fun tag` is creating a promise that gets passed to the behaviour to fulfill, and returned to the caller to chain onto
<jemc> a `be` cannot have a return value, so you have to pass in the promise as an argument, but the caller probably doesn have to create the promise, so you
<jemc> *doesn't want the burden of having to create the promise and pass it, so you add a `fun tag` as a convenience method to do that work, and return the promise to the caller
TheNet has joined #ponylang
<vaninwagen> hi, again i need some help :/ :)
<vaninwagen> i have some code to convert anything to a string, but it wont work the way i want it:
<vaninwagen> 1) with "as": https://is.gd/RbkEc5
<vaninwagen> 2) with pattern match: https://is.gd/rvAYV2
<vaninwagen> both fail with: "this pattern can never match for ``List[USize val] ref`` as ``Stringable box``"
<vaninwagen> is there any other way for achieving this
TheNet has quit [Quit: Textual IRC Client: www.textualapp.com]
<jemc> vaninwagen: here's an example of a modification that works: http://playground.ponylang.org/?gist=9b762fa2e4332baf2423d30e47643e45
<jemc> the compiler knows that `List` is not `Stringable`, so it won't allow you to do a pattern-match that can be known statically to never match (the two types are disjoint)
<vaninwagen> jemc thank you very much
<vaninwagen> man, i love you guys, you never let me down with my many problems :)
<jemc> however, if you "degrade" the reference to an `Any box`, the compiler doesn't see `Any box` as disjoint with `Stringable`
<vaninwagen> just wanted to ask for an in depth explanation :)
<vaninwagen> awesome
<vaninwagen> tricky trick
<jemc> vaninwagen: also, you may be interested to know I have a small package that does the think of thing you're doing: https://github.com/jemc/pony-inspect
<jemc> *kind of thing
<vaninwagen> jemc it does no digestof, does it?
<vaninwagen> but hell, it looks good
<vaninwagen> good opportunity to go crazy with pony-stable
<vak> jemc: thank you for explaining about promises-trick!
<jemc> yeah, adding `digestof` would be a nice touch to add - right now it only prints them as `<uninspectable>` - something like `<uninspectable:23efa78>` would be better
<jemc> so you could at least see the identities
<vaninwagen> jemc, https://github.com/jemc/pony-inspect/pull/1/files i do hit a compiler assertion locally, i have to admit
<vaninwagen> src/libponyc/codegen/genbox.c:15: gen_box: Assertion `t != NULL` failed.
<vaninwagen> 0.15.0-c628283 [release] - compiled with: llvm 3.9.1 -- gcc-6 (Ubuntu/Linaro 6.3.0-18ubuntu2~14.04) 6.3.0 20170519
<jemc> vaninwagen: ah right, this issue popped up recently with some changes that Praetonus did to `gen_box`, and I haven't had time to debug it with him yet - sorry
<vaninwagen> nevermind, pr is there - i will include pony-inspect once it is merged :)
<vaninwagen> for now i have a workaround for my problem, everything is awesome
<vaninwagen> life is good
<jemc> if you have a small repro for the compiler crash, that would be nice to see
<jemc> er.. nevermind
<jemc> it's present on running the test suite, so no need to reduced it futhere
<vaninwagen> jemc ok, cool
<vaninwagen> or not cool, but at least reproducible
dougmacdoug has joined #ponylang
<vaninwagen> jemc, fyi i came up with this now for my use case (i only have a generic T, no Any box): http://playground.ponylang.org/?gist=178078edea94a2f7e4c1809668d9b1f1
<jemc> vaninwagen: note that the RFC you mentioned ("subtype checking") is partially implemented, but it hasn't been really documented yet because it's not complete, and still somewhat experimental
<jemc> however it does provide a rather elegant solution to your problem: http://playground.ponylang.org/?gist=89af158f8e644714eddfcd070c9f7ecd
<jemc> the part of the RFC that isn't implemented is putting the `iftype` condition on a method signature - right now it can only appear as a conditional branch in a method body
<vaninwagen> neat!
<jemc> the performance will be better than your runtime match, because the subtype relationship is checked at compile time
obadz has quit [Ping timeout: 260 seconds]
obadz has joined #ponylang
endformationage has joined #ponylang
plietar_ has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 240 seconds]
papey_lap has quit [Ping timeout: 240 seconds]
vak has quit [Ping timeout: 260 seconds]
Matthias247 has joined #ponylang
aceluck_ has joined #ponylang
aceluck_ has quit [Ping timeout: 260 seconds]
plietar has joined #ponylang
_andre has quit [Quit: leaving]
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 255 seconds]
vaninwagen has quit [Ping timeout: 240 seconds]
adam_ has quit [Quit: Page closed]
oldmanmike has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
oldmanmike has quit [Ping timeout: 255 seconds]
plietar has joined #ponylang
aceluck has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]