<cquinn>
I am writing an API and want to make sure the caps are friendly for users to pass array literal directly without any extra syntax. I guess box is the most flexible cap for method args.
<doublec>
cquinn: generally you can leave the caps out and just leave it at the defaults in function arguments
<doublec>
cquinn: if you make them box then the function can't modify them
<cquinn>
In my case the args are maps that I will copy the elements out of. Although I guess in some cases I could just keep the original when I won't modify it.
nyarum has joined #ponylang
nyarum has quit [Ping timeout: 240 seconds]
<cquinn>
it would be nice if there was an easy notation for making val literals.
<cquinn>
Another ad hoc capabilities question: should new methods return ephemeral forms of caps? E.g. Array.create(n) should return a ref^ ? Since that is normally the only alias of the new object
<doublec>
cquinn: create is a constructor so it returns the ephermeral type by default
<jordan_>
hi folks im a beginner and i am wondering if ponylang has a "std::cin" equivalent of C++ and if so where I can learn more about implementing it
<jemc>
jordan_: as of right now, there does not exist a common interface for input streams, which is something I'd like to change, but it's complicated by the fact that most input stream notifier objects also need stream-specific error handling methods
amclain has joined #ponylang
<jordan_>
@jemc ok thats fine thanks!
<jemc>
for example, a `TCPConnectionNotify` must implement `fun ref received(conn: TCPConnection ref, data: Array[U8] iso)`, but it also has to implement error handling methods like `connect_failed`
<jemc>
cquinn: the pain point you're hitting with array literal caps is one I intend to solve by improving inference
<jemc>
that is, an array literal is a `ref` by default, just because that was determined to be the most likely cap that you want when declaring it
<jemc>
but in cases where you are passing an array literal directly to a method as an argument (or assigning it to a reference with an explicit type), the array literal could/should just use the cap that is expected by the right hand side
<jemc>
(if it is possible, that is)
<jordan_>
i have another pattern-based question: if in actor Main i call a behaviour of an actor A1 (which leads to a series of behaviours of A1_children for.e.g), and then call a behaviour of actor B2, is there a way to pattern to guarantee the behaviour of B2 is executed after all A1 (and its children) have completed?
<jemc>
jordan_: in general, in Pony if you want to have a "happens before" relationship between event X and event Y, you have to create a causal link from X to Y
<jemc>
there's different ways to do it, but one option in your case might be:
<jordan_>
ic, i figured i have to make the link explicit (such as calling B2 from the last terminating A1 child behaviour)
<jemc>
yeah, basically that's what I was going to suggest
<jemc>
there are different ways to accomplish that, and I think it depends on how coupled you want the design of Main to be with A1, and A1 with its children
<jemc>
if you don't mind being coupled, the most straightforward way is to pass Main to A1, and pass A1 to its children
<jemc>
if you don't want the inner parts to be coupled to the outer parts, you could pass a lambda `val` inward that represents "what to do when the task is finished"
<jemc>
or you could potentially use the `promises` package if that suits your use case better
<jordan_>
thanks @jemc i will look into ur suggestions and promises package
<cquinn>
yes, @jemc, that would be a nice addition. Would it help at all if array literals were ref^ (if they aren't already)?
Matthias247 has joined #ponylang
<jemc>
they should be ephemeral already
jordan_ has quit [Quit: Page closed]
gornikm_ has joined #ponylang
pcarrier_ has joined #ponylang
BlackYoup_ has joined #ponylang
BlackYoup has quit [*.net *.split]
gornikm has quit [*.net *.split]
pcarrier has quit [*.net *.split]
katafrakt[m] has quit [*.net *.split]
kempe has quit [*.net *.split]
gornikm_ is now known as gornikm
pcarrier_ is now known as pcarrier
kempe has joined #ponylang
katafrakt[m] has joined #ponylang
obadz has quit [Ping timeout: 240 seconds]
obadz has joined #ponylang
nyarum has joined #ponylang
nyarum has quit [Remote host closed the connection]