dougmacdoug has quit [Remote host closed the connection]
dougmacdoug has joined #ponylang
endformationage has joined #ponylang
gokr has left #ponylang [#ponylang]
jemc has joined #ponylang
codec1 has quit [Read error: Connection reset by peer]
codec1 has joined #ponylang
jemc has quit [Ping timeout: 256 seconds]
jemc has joined #ponylang
ficl has joined #ponylang
milisarge has joined #ponylang
<rirc_187A>
codec1: you still here?
ficl has quit [Ping timeout: 240 seconds]
<rirc_187A>
thats not how recover works, if you think about it: if you were allowed to do that then you could create a val from any ref which is clearly not safe
<rirc_187A>
it will work if you create the ref inside the recover expression
codenoid has quit [Read error: Connection reset by peer]
codenoid has joined #ponylang
<rirc_187A>
codec1: I don't really know why bytes is an iso! there. I gtg now, I will look at this again tomorrow.
codenoid has quit [Quit: Leaving]
<SeanTAllen>
codec1: a_byte and bytes.values() return different values
bimawa2 has joined #ponylang
<codec1>
SeanTAllen what do you mean?
<SeanTAllen>
a_byte is not the same type as the iterator returned by bytes.values()
<SeanTAllen>
bytes.values returns an Iterator of some type A
<SeanTAllen>
a_byte is some type A
<codec1>
ok, but the thing I am trouble with is in the other part
<codec1>
basically I want to fill an array before giving it to the reader
<codec1>
the for loop does the trick but before that I tired with the concat (or append for that matter) methods
<codec1>
and couldn't get them working
<codec1>
I understand that concat need a ref receiver in order to mutate the array and append expect a val
<codec1>
so my best guess was that I could start with an iso array, fill it using concat, and then consume it in the call to rb.append
<codec1>
but the compiler tell me that the receiver for concat is an iso! and not an iso, which I don't understand since for me there is no alias there
<codec1>
*tried (instead of tired)
<SeanTAllen>
what did you do with append @codec1?
<codec1>
just trying to call it with the array as a receiver
<SeanTAllen>
can you paste some code for what you did specifically?
<codec1>
basically the not commented code is fine to me, and I am fighting the compiler when un commenting the line
<codec1>
and for context I went with the for loop instead only because it was the only thing that did both compiled and did what I wanted (filling the array)
<SeanTAllen>
sorry, that is still concat not append
<SeanTAllen>
can you post what you did where append didnt work?
<codec1>
well I just tried to replace concat by append
<codec1>
and it didn't worked either
<codec1>
I thought the parameter were the same, but I am not so sure of it now
<SeanTAllen>
they arent the same.
<SeanTAllen>
concat takes an iterator
<SeanTAllen>
append takes an A
<SeanTAllen>
sorry it takes a ReadSeq[A]
<codec1>
yeah right, so with append my attempt would be that
<SeanTAllen>
nevermind there is the "if everything was sendable" down at the bottom
<SeanTAllen>
i thought that was missing
<jemc>
yeah, the important part is "this would be possible if the arguments and return value were all sendable"
<SeanTAllen>
i think the message could definitely be improved
<SeanTAllen>
i missed that it was there
<SeanTAllen>
and thought it was an awful message because that info was missing
<SeanTAllen>
is there any way to get a sendable Iterator?
<codec1>
in my case even after re-reading that I don't understand it either
<jemc>
iterators have to be mutable because they need to change their "next"-related state
<jemc>
theoretically you could have an iso iterator over a val collection
<SeanTAllen>
yeah
<jemc>
which you could arrive at using recover
<SeanTAllen>
ill just say it again
<SeanTAllen>
i hate iterators
<vaninwagen>
i have to admit that i like them, because it is a good way to define some operations lazily on a collection without applying them immediately
<vaninwagen>
together with itertools from stdlib they are quite fun
_andre has quit [Quit: leaving]
vaninwagen has quit [Ping timeout: 240 seconds]
dougmacdoug has quit [Quit: dougmacdoug]
mahmudov has joined #ponylang
jemc has quit [Ping timeout: 256 seconds]
jemc has joined #ponylang
gregrc has joined #ponylang
<gregrc>
Hi, I was hoping someone might be able to give me some guidance on something. I'm used to functional programming where higher-order functions are common, and it's common to create and pass named functions into them or into a lambda. In Pony it seems I can't capture a method in a closure, and can only pass methods by partially applying them with no arguments. Is it just not idiomatic in Pony like it might be in Ruby?
<jemc>
gregrc: welcome!
<jemc>
we do indeed have lambdas/closures
<jemc>
there are a couple pitfalls we are working to smooth over with them, but other than those, they work quite well for what you're talking about
<jemc>
lambdas and partial application are both syntax sugar for object literals
<jemc>
which is in turn syntax sugar for defining a new class, primitive, or actor with a so-called "hygienic" name that you don't have to see
<gregrc>
Yeah, after reading through the tutorial I understand that it's making a new object was helpful. Again, I have to get used to primarily OO stuff.
<gregrc>
So if I wanted to capture a method in a lambda, could I make a variable by partially applying the method, then close over that variable?
<gregrc>
Ah, yeah trying that out works as I expect. Thank you. Now I just have to ruminate on capabilities some more to get where I feel comfortable with Pony
<SeanTAllen>
gregrc: pop by anytime you have capabilities questions, if i'm around, i'll try and help. if i'm not, i'm always logged in and try to respond eventually. check the logs if you don't get an answer immediately.
<SeanTAllen>
out of curiosity, what languages are you most familiar with?
<gregrc>
Probably Elixir, Rust and Python. Which sort of explains my interest in Pony :)
<gregrc>
The Rust gives me a little toe hold in capabilities, but it's different enough to still be kind of confusing.
<SeanTAllen>
Well the basic ideas are there though.
<SeanTAllen>
isolated data, immutable data, mutable data
<SeanTAllen>
did you read the "learning reference capabilities" section on the website?
<gregrc>
Yeah I'm working through it now. I skimmed it once, then looked through when I ran into an issue, but now I'm re-reading it more thoroughly
<gregrc>
I ran into some confusion with recovering capabilities
<SeanTAllen>
recover might be a bad word.
<SeanTAllen>
ive often wondered if a different keyword would have been better
<SeanTAllen>
like
<SeanTAllen>
`safe ... end`
<SeanTAllen>
or
<SeanTAllen>
`sterile ... end`
<gregrc>
I think I just don't fully understand the concept. I tried using it essentially where I would .clone() in Rust but I don't know that it translates
<SeanTAllen>
so
<SeanTAllen>
i will try to explain what helped me
<SeanTAllen>
and maybe it will help you
<SeanTAllen>
or maybe confuse you
<SeanTAllen>
so...
<SeanTAllen>
recover i think, is really about having a safe zone to do things with mutable things in a safe way
<SeanTAllen>
you can reference any external mutable variables/data structures inside a recover block
<SeanTAllen>
that means, you can create a mutable data structure inside of recover, mutate it
<SeanTAllen>
then return a non-mutable or otherwise different capability version of it
<SeanTAllen>
and the compiler can know its safe
<SeanTAllen>
because nothing "unsafe" can escape
<SeanTAllen>
this can be used in many different way
<SeanTAllen>
for example, a really simple way
<SeanTAllen>
by default, arrays are mutable, so what if i want to create an array with a few items and then have it be mutable...
<SeanTAllen>
here's a silly example of that... but you can get the idea...