<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