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
endforma1 has joined #ponylang
endformationage has quit [Ping timeout: 240 seconds]
endforma1 has quit [Ping timeout: 264 seconds]
endforma1 has joined #ponylang
svenskunganka has joined #ponylang
<svenskunganka> Hi! I've decided to try to learn pony, and started reading the tutorial for three hours ago or so. My project for learning new languages is always to build a filetype matching library that matches by magic numbers. However I'm not sure what the pony way is to do multiple expressions in a single if. This is what I got so far: https://playground.ponylang.org/?gist=88314b25eb154bcf45b7240e39abf5d5
<svenskunganka> I want to check an arbitrary-sized Array[U8] at specific indices for a value
khan has joined #ponylang
khan_ has joined #ponylang
khan has quit [Ping timeout: 256 seconds]
khan_ is now known as khan
<vaninwagen> Looks good, you can combine multiple if conditions with and and or
<vaninwagen> For your use case it might be interesting to use buffered.Reader to read your magic Numbers as integer values from a byte array https://stdlib.ponylang.org/buffered-Reader/
khan has quit [Quit: khan]
khan has joined #ponylang
khan_ has joined #ponylang
<svenskunganka> That looks more like what I need. I understand that I can have multiple conditions inside an if, but the precedence thing would make the code quite unreadable.
<vaninwagen> You can wrap the condition over multiple lines, if that helps
<vaninwagen> The precedence thing might seem strange at first but it saved my ass more than once already
khan has quit [Ping timeout: 264 seconds]
khan_ is now known as khan
<svenskunganka> How'd that look like? I tried breaking it into multiple lines but I got the "syntax error: unterminated if expression"
<svenskunganka> brb, gonna buy some breakfast
<vaninwagen> You need to put the single comparisons in parens, otherwise they might be mixed up with the and operators. Also dont forget the 'then' at the end of your if condition.
<vaninwagen> I am at the phone right now, and the playground is pretty much unusable here, i will post an example later
<svenskunganka> I see, that makes sense. Thanks for your pointers, I'll try my way forward and see how I can apply them. The goal is to have an API where you do something like this: https://gist.github.com/Svenskunganka/c7dc715ded00704205b30bb4869d58fd
<svenskunganka> Does that look like "idiomatic" pony or is there something I'm misunderstanding from the tutorial?
<vaninwagen> That makes very much sense, looks nice
<svenskunganka> That is awesome, Pony seems like a really nice language so far!
khan has quit [Ping timeout: 240 seconds]
khan has joined #ponylang
dave24 has quit [Ping timeout: 255 seconds]
CcxWrk has quit [Ping timeout: 240 seconds]
CcxWrk has joined #ponylang
CcxWrk has quit [Excess Flood]
CcxWrk has joined #ponylang
txdv has quit [Ping timeout: 240 seconds]
<svenskunganka> Is it possible to reopen a type alias across packages? Say I have
<svenskunganka> type Audio is (Mp3 | Midi)
<svenskunganka> In a package
<svenskunganka> Is it possible to add another to that alias from another package/main program? E.g
<svenskunganka> type Audio is Ogg then becomes type Audio is (Mp3 | Midi | Ogg)
<vaninwagen> No, that is not possible
<vaninwagen> But what you describe looks like you want to use a trait or Interface for that
<svenskunganka> I thought those only were able to be applied to classes?
<vaninwagen> They are applicable to everything, classes, actors, primitives, object literals...
atk has quit [Quit: Well this is unexpected.]
atk has joined #ponylang
dlowe has quit [Ping timeout: 244 seconds]
<SeanTAllen> vaninwagen: why are you thinking svenskunganka wants a trait?
jmiven has quit [Ping timeout: 244 seconds]
dlowe has joined #ponylang
khan has quit [Ping timeout: 240 seconds]
PrsPrsBK has joined #ponylang
jmiven has joined #ponylang
<vaninwagen> A trait or interface Instead of a union if he wants it to be extendable. A union is a closed type
<vaninwagen> If he wants something that includes all possible values that can be Audio e.g.
<svenskunganka> I got it to work with traits! Should be extendable: https://playground.ponylang.org/?gist=78f09c1d10ba636e54254cae728a3528
<svenskunganka> So users of the library can add their own matchers and categorize them with `primitive Wow is (Audio & FiletypeMatcher)`
<svenskunganka> If `Wow` were an audio filetype
<svenskunganka> Now I've got a lot of tidying up and looking over the capabilities
khan has joined #ponylang
khan has quit [Ping timeout: 240 seconds]
khan has joined #ponylang
khan has quit [Remote host closed the connection]
endforma1 has quit [Quit: WeeChat 1.9.1]
endformationage has joined #ponylang
svenskunganka has quit [Ping timeout: 264 seconds]
brainproxy has quit [Ping timeout: 264 seconds]
brainproxy has joined #ponylang
jmiven has quit [Quit: co'o]
jmiven has joined #ponylang