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
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 248 seconds]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 240 seconds]
endformationage has quit [Quit: WeeChat 1.9]
vaninwagen has joined #ponylang
<vaninwagen> hi, quick question. i want to implement a generic method that works for all Int types. i am somehow unable to achieve this. I tried the following: http://playground.ponylang.org/?gist=4d2da0d1159e25ed8d5cdf0a28d3d38d without success
<vaninwagen> i used the union ``Int`` maybe i should have used the trait Integer but i was unable to get this working too
<vaninwagen> there must be an easy way
Matthias247 has joined #ponylang
Matthias247 has quit [Client Quit]
plietar has joined #ponylang
samuell has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar_ has joined #ponylang
<vaninwagen> ``fun int_method[T: Integer[T] val](t: T)`` this works \o/
<vaninwagen> it just can't handle literals
<vaninwagen> if i use ``t + 1`` the compiler says: main.pony:12:19: could not infer literal type, no valid types found.
<vaninwagen> does anyone have an idea for a workaround?
vaninwagen has quit [Ping timeout: 248 seconds]
vaninwagen has joined #ponylang
samuell has quit [Remote host closed the connection]
samuell has joined #ponylang
<SeanTAllen> vaninwagen: can you send code that runs into the t+1 issue?
tscho has quit [Ping timeout: 248 seconds]
catern has quit [Ping timeout: 248 seconds]
tscho has joined #ponylang
dtz has quit [Ping timeout: 246 seconds]
srenatus[m] has quit [Ping timeout: 246 seconds]
abeaumont has quit [Ping timeout: 240 seconds]
catern has joined #ponylang
srenatus[m] has joined #ponylang
dtz has joined #ponylang
_andre has joined #ponylang
<vaninwagen> my first guess is that inferring types for literal numeric expressions only works with concrete number types
<vaninwagen> but i don't understand the code for handling literals ヽ(。_°)ノ
<SeanTAllen> thats an interesting one
<vaninwagen> SeanTAllen should i create an issue in ponyc?
<SeanTAllen> im not sure how to solve it. there could be a way. i'd say sure, go for an issue. other option is email the user list.
<vaninwagen> whatever you prefer
plietar_ has quit [Remote host closed the connection]
<vaninwagen> i already feel guilty for opening that many issues and not getting my few ones done :/
<SeanTAllen> no need to feel guilty for open issues for things that need to be fixed
<vaninwagen> doublec this is exactly my example. wrong link?
<doublec> hmm, not sure why that didn't work
<doublec> vaninwagen: change to this fun int_shrink[T: (Int & Integer[T] val)](t: T): (T^, Seq[T]) =>
<doublec> vaninwagen: note the "(Int & Integer[T] val)"
<vaninwagen> doublec woah!!!
<doublec> I'd like to take credit but I grepped the pony library sources for Integer[T} usage and found one example that did it.
<doublec> in format.pony
<vaninwagen> you have some amazing grep skillz
<doublec> I live in grep for finding things in the codebases I use haha
<vaninwagen> so ``Int`` was not working because the concrete types have incompatible signatures, at least thats what the compiler says.
<vaninwagen> but i don't really get why i got those errors
<vaninwagen> using ``Integer[T] val`` does not work because literal inference needs the type to be some concrete integer type (and only with Integer[T] val it could be any new class implementing that, which is not handled)
<vaninwagen> ok, i think i slowly get it :)
<vaninwagen> thanks for bearing with me
<vaninwagen> SeanTAllen doublec i'd say not worth an issue. maybe some mark in the tutorial or language reference...
<doublec> np, I'm not entirely sure why it works myself - it's a good example for discussion
<doublec> I think it's worth discussing in an issue why it doesn't work
<doublec> or at least the mailing list
vaninwagen has quit [Ping timeout: 240 seconds]
<SeanTAllen> so what is your final solution vaninwagen?
isaac_ has joined #ponylang
abeaumont has joined #ponylang
vaninwagen has joined #ponylang
isaac_ has quit [Quit: Page closed]
<vaninwagen> SeanTAllen, doublecs suggestion worked out fine, using fun int_shrink[T: (Int & Integer[T] val)](t: T): (T^, Seq[T]) =>
<vaninwagen> i wrote to the user mailing list to ask about the hows and whys
<SeanTAllen> sounds good
theodus has joined #ponylang
vaninwagen has quit [Ping timeout: 248 seconds]
darkav has joined #ponylang
fluttershy_ has joined #ponylang
<fluttershy_> hello, What is position independent code in pony, and when should I use it ? I have a pony binding to a C shared library, is it necessary to use --pic when I include the binding and compile ? SeanTAllen I ve sean you use it when binding to SDL.
<SeanTAllen> --pic is specific to your OS and libraries fluttershy_
<SeanTAllen> if your OS/system libraries were compiled with PIC on then anyhting that links against them needs to be PIC
<fluttershy_> hemmm
<fluttershy_> well, any gain on performance ?
<fluttershy_> sorry I am not familiar with the concept position independent code.
<SeanTAllen> you will lose some performance
<SeanTAllen> not much but some
<SeanTAllen> in theory PIC is a security improvement
<fluttershy_> hemm, ok ty I will read more about it.
<SeanTAllen> i wouldnt worry about it beyond-- do i need to compile my application with --pic
<SeanTAllen> also note if you build the pony compiler from scratch and need to use --pic to compile applications, there is an option when building the compiler to have it turn --pic on my default
<fluttershy_> yes I read about the issue in the ponylang.org but I was confused about pic. ok then ty.
Praetonus has joined #ponylang
theodus has quit [Remote host closed the connection]
theodus has joined #ponylang
darkav has quit [Ping timeout: 260 seconds]
plietar has joined #ponylang
Guest62436 is now known as masteinhauser
masteinhauser is now known as Guest90302
Praetonus has quit [Quit: Leaving]
Guest90302 is now known as masteinhauser
TheNet has joined #ponylang
fluttershy_ has quit [Quit: Page closed]
amclain has joined #ponylang
endformationage has joined #ponylang
TheNet has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<SeanTAllen> i got some info from jemc, vaninwagen, doublec
<SeanTAllen> I think the issue is that Integer is a trait and thus could have an unbounded set of subtypes theoretically added (outside of stdlib)
<SeanTAllen> If for some reason you didn't want to use `& Int` another workaround is to use something like this for the literals: `T.from[U8](1)` (edited)
<SeanTAllen> IIRC, Int is a union type, and only includes types that the compiler has special case knowledge of.
<SeanTAllen> And the pony compiler doesn't seem to be able to do literal inference for those yet- unknown types
<SeanTAllen> thats the ^jemc quote
TheNet has joined #ponylang
Matthias247 has joined #ponylang
plietar has quit [Remote host closed the connection]
vaninwagen has joined #ponylang
<vaninwagen> SeanTAllen, jemc that sounds very reasonable, i suspected that
<vaninwagen> thanks for sharing
<vaninwagen> but what still puzzles me is why it didnt work with the Int-union type
<vaninwagen> union says the concrete type will be one of the ones listed, right? but the compiler still complained that: a member of the union type has an incompatible method signature: let min: T = T.min_value()
<vaninwagen> although the T's min_value() method should return a T^ - so the assignment should be just fine, right?
<vaninwagen> this assignment should be fine for each possible concrete type (e.g. U8)
<vaninwagen> sorry, i am surely wrong at some point, just want to know where
<vaninwagen> btw it is awesome that i can do T.some_constructor() on a type param
TheNet has quit [Read error: Connection reset by peer]
TheNet has joined #ponylang
_etc has joined #ponylang
_etc has quit [Client Quit]
_etc has joined #ponylang
<_etc> I've come across a bit of an awkward case: I have an actor that whose fields rely on a function call that may throw an error. I'd like to either exit the program or do nothing (basically not worry about it) if an error is thrown. So I could make each of these fields have an `| None` in their type in case an error takes place, but this is kind of a
<_etc> nuisance. Is there any better pattern to handle errors in the construction of actors? (Doesn't show up in classes because the create() function can return an error)
plietar has joined #ponylang
acarrico has quit [Ping timeout: 240 seconds]
acarrico has joined #ponylang
<vaninwagen> _etc a hacky workaround would be to create an intermediate class containing all the actor constructor arguments as fields and fail there and only create the actor using this class if its creation does not fail
<_etc> vaninwagen: Yeah that would definitely work
<_etc> thanks :)
acarrico has quit [Ping timeout: 248 seconds]
_andre has quit [Quit: leaving]
acarrico has joined #ponylang
<_etc> Haha that's exactly what I was describing - thanks!
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
_etc has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<vaninwagen> oops, this is actually a valid pattern, and i called it hacky (which it isn't) workaround
vaninwagen has quit [Ping timeout: 248 seconds]
samuell has quit [Quit: Leaving]
acarrico has quit [Ping timeout: 248 seconds]
TheNet has quit [Quit: Textual IRC Client: www.textualapp.com]
bbhoss has quit [Ping timeout: 255 seconds]
bbhoss has joined #ponylang
<SeanTAllen> yeah we use it all the time
tscho has quit [Read error: Connection reset by peer]
tscho has joined #ponylang