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
inoas has quit [Quit: inoas]
kai3x5 has quit [Ping timeout: 240 seconds]
kai3x5 has joined #ponylang
gokr has quit [Ping timeout: 265 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
gokr has joined #ponylang
khan has quit [Quit: khan]
Pyrrh has quit [Ping timeout: 256 seconds]
gokr has quit [Ping timeout: 240 seconds]
khan has joined #ponylang
jmiven has quit [Quit: co'o]
jmiven has joined #ponylang
khan has quit [Quit: khan]
gokr has joined #ponylang
codec1 has joined #ponylang
samuell has joined #ponylang
nisanharamati has quit [Quit: Connection closed for inactivity]
<dave24> hello, how do I properly use the reader? If I receive some data from a network, append it to a reader and then a decoder reads from it and fails because there is not enough data yet
<dave24> then can I reset the cursor? or does the decoder need to be able to return some partial result it can resume later?
gokr has quit [Ping timeout: 264 seconds]
khan has joined #ponylang
<emilbayes> Is it possible to use higher-order functions for defining methods or behaviours? I guess not, but I wanted to make sure I'm wrong
Praetonus has joined #ponylang
<dave24> emilbayes: what do you mean exactly? functions can have objects as parameters and those can have apply functions, is that what you want?
<dave24> emilbayes: see section on lambdas here: https://tutorial.ponylang.org/expressions/object-literals.html
<emilbayes> dave24: I was thinking more of a templating or macro like functionality
<dave24> oh.. no, I don't think anything like that exists
<emilbayes> but maybe all I want is to have some default parameters in my case
gokr has joined #ponylang
<SeanTAllen> dave24: you add data as it arrives to the Reader. you attempt to read whatever it is out of it that you expect. if there isn't enough data, you get an error, add more data as you get it, try again. that's one possible strategy.
<SeanTAllen> emilbayes: pony has default parameters. fun my_method(foo: String = "default") for example
<SeanTAllen> emilbayes: see https://tutorial.ponylang.org/expressions/methods.html and "default parameters"
<emilbayes> SeanTAllen: Yeah I'm think it is probably old habits I have to unlearn for pony
<dave24> SeanTAllen: do you mean read everything I expect in one go?
<emilbayes> in the cases where I'd juse higher order functions to set defaults and such
<SeanTAllen> dave24: i cant answer that as i dont know your use case.
<SeanTAllen> if you expect to read a U16, and you only have 1 byte... then yes "one go" as in, you have to be able to read the U16.
<dave24> SeanTAllen: Its a decoder that reads bits of data and depending on what it read it might read some more
<dave24> so I don't know how much I want in advance
<SeanTAllen> emilbayes: im not sure how you are using HOFs in that case so its hard for me to comment. Pony has lambdas/object literals so what you want to do might be possible.
<SeanTAllen> dave24: can you gist/pastebin some pseudocode?
<emilbayes> SeanTAllen: I'm thinking something like this where the HOF `auth` is used to decorate / composing functionality: https://gist.github.com/emilbayes/df7f25567014a9d54cd301e293e7c857
<dave24> fun decode(r: Reader): U32 ? => if r.u8()? == 0 then 9000 else r.u32_be()? end
<dave24> does that explain the concept? I don't really know what you want me to put in a gist
<emilbayes> SeanTAllen: I was thinking in the case of where you may want to abstract some functionality
<dave24> emilbayes: It looks like you just have to get used to a bit different style of programming, I would suggest to not try to copy idioms from js
<emilbayes> dave24: Yes, that's what I have to "unlearn"
<dave24> emilbayes: solve the problem in pony rather than solving it in js and then trying to translate to pony
<emilbayes> dave24: Reading a lot of lisp recently too where all abstraction is done through HOF
<dave24> emilbayes: yes, lisp and js have much more in common with each other than with pony
<SeanTAllen> emilbayes: the "notifier" pattern is how that is generally done in Pony. You can find it throughout the standard library.
<SeanTAllen> dave24: if that's your use case then I'm not sure what your question is.
<SeanTAllen> but that is missing larger context
<SeanTAllen> i was hoping for pseudocode to understand what you are trying to accomplish
<dave24> SeanTAllen: if I append data to the reader as I receive it from the network then everytime I try to decode I will loose everything in the reader
<dave24> Do I have to duplicate it all maybe?
<dave24> or should I use peek everywhere?
<dave24> those don't seem right
<dave24> let me try to write a gist that is broken to illustrate the problem
<SeanTAllen> o i see
<SeanTAllen> so you are reading a U8 but its value isnt 0
<SeanTAllen> so you want it to still be in the Reader
<dave24> yes
<dave24> I read a U8(2) but then there is only one more byte so the next call fails for example
<SeanTAllen> you can use peek
<SeanTAllen> its not the most efficient thing
<SeanTAllen> peek to see if its there an a 0
<SeanTAllen> if it is read it to remove the data
<SeanTAllen> that's basically doubling up
<SeanTAllen> i think you might want to write your own custom reader that understands your special needs
<SeanTAllen> that is assuming you are worried about performance
<SeanTAllen> otherwise
<SeanTAllen> peek is your friend
<dave24> hmm, ok
<SeanTAllen> i would go with peek.
<SeanTAllen> and then if its a performance issue, you can write the whiz bang custom streaming parser.
<dave24> ok thanks, thats fine I guess
<dave24> SeanTAllen: Can I ask about your message-pack implementation? How does it handle this case? Because that does not use peek
khan has quit [Quit: khan]
alxs has joined #ponylang
khan has joined #ponylang
<SeanTAllen> It doesnt handle that case. I think your case is rather specific.
<SeanTAllen> There's no "it might be a U8 if it has a magic value, otherwise its U32" concept in that message pack implementation.
<dave24> oh
<SeanTAllen> some message pack formats do try to use smaller sizes when available
<dave24> damn, im bad at explaining
<dave24> thats not what I meant
<SeanTAllen> so you said "this is a u128" and it will encode as "u8"
<SeanTAllen> but not all of them do
<SeanTAllen> which is... problematic
<SeanTAllen> i have an issue open to consider adding it
<SeanTAllen> but apparently that isnt what you meant...
khan has quit [Client Quit]
<dave24> for example you have a `u32` function in the MessagePackDecoder. What if the `_read_type` call is successful but then the stream ends and therefore the `b.u64_be()?` call fails
khan has joined #ponylang
<dave24> then next time, when there is more data in the reader, the initial byte will be gone
<dave24> I'm sorry, I am notorious for being the worst at explaining anything
<SeanTAllen> why do you say the initial byte will be gone?
<SeanTAllen> o
<dave24> because _read_type will have consumed it, right?
<SeanTAllen> hmm
<SeanTAllen> good point
<SeanTAllen> the assumption i wrote that will is you arent doing it streaming
<SeanTAllen> you have the complete message
<SeanTAllen> that's an interesting case
<SeanTAllen> i will update the README to note that its not safe for streaming cases at this time
<dave24> I think I will try partial results + peek + skip.
samuell has quit [Remote host closed the connection]
<dave24> Thanks SeanTAllen!
<SeanTAllen> your welcome
<SeanTAllen> and thanks for pointing out the oversight in my message pack documentation
<dave24> do the builtin _ArithmeticConvertible functions cast the raw bits, or do they convert them to be the same numeric value in the result type?
<Praetonus> dave24: They do numeric conversions
Praetonus has quit [Quit: Leaving]
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
alxs has joined #ponylang
jemc has joined #ponylang
xllndr[m] has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
alxs has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
alxs has joined #ponylang
codec2 has joined #ponylang
samuell has joined #ponylang
codec1 has quit [Read error: Connection reset by peer]
<SeanTAllen> that seems like a good PR to add as information somewhere
user10032 has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
alxs has quit [Quit: Bye y'all!]
alxs has joined #ponylang
gokr has quit [Ping timeout: 260 seconds]
nisanharamati has joined #ponylang
dipin has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
Praetonus has joined #ponylang
jemc has quit [Ping timeout: 264 seconds]
jemc has joined #ponylang
khan has quit [Quit: khan]
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
kai3x5 has quit [Quit: ZNC - http://znc.in]
samuell has quit [Remote host closed the connection]
gokr has joined #ponylang
jemc has quit [Read error: Connection reset by peer]
jemc has joined #ponylang
user10032 has quit [Remote host closed the connection]
inoas has joined #ponylang