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
jemc has quit [Read error: Connection reset by peer]
jemc has joined #ponylang
jemc has quit [Ping timeout: 265 seconds]
hanshoi has joined #ponylang
sheerluck has joined #ponylang
Shorttail has joined #ponylang
sheerluck has quit [Remote host closed the connection]
vaninwagen has joined #ponylang
<dave24> Is order of evaluation in function arguments/infix operators always left to right, or is there no guarantee?
<Candle> dave24: For non-identical operators, pony forces you to use parenthesis: i.e. 'a * b + c' is not allowed, you have to do either '(a * b) + c' or 'a * (b + c)'. For 'a - b - c' I would expect it to evaluate L-to-R as ((a - b) - c) != (a - (b - c)).
<Candle> (Not all infix operators are transitive)
<dave24> Candle: yes, but I'm more concerned about order of evaluation rather than precedence. So, in `a + b + c` will the side-effect of `a` always come before the side-effect of `b` and `b` before `c`?
<dave24> Actually, I'm guessing not since the tutorial states "Expressions for arguments in function calls are evaluated before the expression for the function receiver." Since `a + b` is sugar for `a.add(b)` it seems b would be evaluated first.
<Candle> 'proof' by example ;)
<dave24> :D
khan has joined #ponylang
khan has quit [Client Quit]
Shorttail has quit [Ping timeout: 260 seconds]
hateful_moron has joined #ponylang
ExtraCrispy has joined #ponylang
hateful_moron has quit [Client Quit]
hateful_moron has joined #ponylang
<hateful_moron> hello, is it possible for generic methods to behave similarly to c++'s templates? as in you don't have to manually specify the type parameters, they're deduced from the arguments?
<dave24> hateful_moron: I don't think so, can you tell me what the use case is? Perhaps there is another nice way of doing what you want.
<dave24> Possibly you can make your code more concise with type aliases if that is the issue.
<hateful_moron> I just wanted a cleaner way of using a method that accepts a ByteSeq, there's no practical issue
<hateful_moron> reusing the type before using it as an argument annoys me a little is all
<dave24> Accepting a ByteSeq? Are you sure you need a generic class, perhaps just using interfaces is what you want.
<dave24> s/generic class/generic method
<vaninwagen> hateful_moron: inference of generic type arguments is not yet implemented. there has been an RFC for that: https://github.com/ponylang/ponyc/issues/1184
<vaninwagen> i would love to see it happen, but didn't have time and brain capacity yet to tackle it
<hateful_moron> i'm writing a method as "fun compress[T: ByteSeq #read] ..." where T is the sequence of bytes being compressed
<hateful_moron> do you mean writing an interface that has some of ByteSeq's methods?
<hateful_moron> thanks vaninwagen
<hateful_moron> dave24: I want to be able to read directly from the ByteSeq types, is an interface still possible?
<dave24> hateful_moron: can you show a small example of what sort of thing the function needs to do?
<hateful_moron> dave24: sorry, that works exactly, thanks
<dave24> nice!
<hateful_moron> I have size and cpointer in an interface and it works fine
<dave24> Alternatively you could accept a straight ByteSeq and convert to an array whenever you get a string.
<dave24> thats what the buffered reader from stdlib does
sheerluck has joined #ponylang
<sheerluck> I never worked with Array[(A | None)] before :(
ashu has joined #ponylang
<vaninwagen> if i am not mistaken this was introduced lately because it is not safe/correct - A could also be instantiated to None
<vaninwagen> it was forbidden in this PR https://github.com/ponylang/ponyc/pull/2499 - the discussion there might be a little enlightening
ashu has quit [Quit: Leaving]
_andre has joined #ponylang
<hanshoi> is there already a curses -like implementation for Pony?
<sheerluck> vaninwagen: thank you but iftype won't create new name a' out of a: (A | None) so I still can't return A, that example in #2499 is just nameless print("val") :(
<vaninwagen> but inside the iftype i think you can treat a as `Any val` (to use the type of that example)
vaninwagen has quit [Ping timeout: 260 seconds]
vaninwagen has joined #ponylang
acarrico has quit [Ping timeout: 248 seconds]
Rachel has joined #ponylang
Rachel is now known as Guest62643
vaninwagen has quit [Ping timeout: 255 seconds]
<hanshoi> apparently there is this https://github.com/jtfmumm/ncurses-pony will check out if that would fit my needs
aturley has joined #ponylang
khan has joined #ponylang
khan has quit [Remote host closed the connection]
hateful_moron has quit [Quit: leaving]
khan has joined #ponylang
pzel has quit [Ping timeout: 276 seconds]
khan_ has joined #ponylang
jemc has joined #ponylang
khan has quit [Ping timeout: 260 seconds]
khan_ is now known as khan
<srenatus> I feel a bit like I'm spamming `pony-stable`, but please bear with me, it's all well-intentioned. If you'd like to direct my _I want to get my feet wet with pony_ impulse some other way, let me know 😆
pzel has joined #ponylang
<jemc> don't sweat it - we appreciate your contributions
sheerluck has quit [Quit: .]
<srenatus> :)
jemc has quit [Ping timeout: 260 seconds]
jemc has joined #ponylang
jaro has joined #ponylang
endformationage has joined #ponylang
jemc has quit [Read error: Connection reset by peer]
jemc has joined #ponylang
pzel has quit [Quit: leaving]
irx[m] has quit [Remote host closed the connection]
M-hrjet has quit [Read error: Connection reset by peer]
Miikka[m] has quit [Remote host closed the connection]
dtz has quit [Remote host closed the connection]
bb010g has quit [Remote host closed the connection]
srenatus has quit [Read error: Connection reset by peer]
khan has quit [Ping timeout: 264 seconds]
khan has joined #ponylang
bb010g has joined #ponylang
khan_ has joined #ponylang
khan has quit [Ping timeout: 240 seconds]
khan_ is now known as khan
<SeanTAllen> Srenatus: you aren't spamming. Love what you are doing. Thank you.
Guest62643 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<emilbayes> Do I remember wrong, or was there a section in the tutorial at some point about compiling pony programs into shared libraries so I could call pony from other languages? (FFI or some ABI)
Miikka[m] has joined #ponylang
irx[m] has joined #ponylang
srenatus has joined #ponylang
M-hrjet has joined #ponylang
dtz has joined #ponylang
<SeanTAllen> emilbayes: there wasn't
<SeanTAllen> It's a doublec blog post
<emilbayes> SeanTAllen: Ah, will google
<SeanTAllen> You can find it in community then planet pony section of the website
<emilbayes> SeanTAllen: Thanks! found this: https://github.com/doublec/pony-clib-example
bimawa1 has quit [Read error: Connection reset by peer]
bimawa1 has joined #ponylang
<emilbayes> Can someone chime in on what the difference between this is and making a new String https://github.com/jemc/pony-sodium/blob/master/sodium/crypto_hash.pony#L9-L11
<SeanTAllen> emilbayes: in the pony source code, check the doc string for from_cpointer
<emilbayes> SeanTAllen: Thanks!
nisanharamati has joined #ponylang
<SeanTAllen> It has all the details. I'd look them up but I'm on my phone
<SeanTAllen> Waiting for a train
<emilbayes> SeanTAllen: No worries, this is much better :) Getting points to where to look is great, then you also get to have a look at the source
<jemc> emilbayes: it's basically a workaround for the fact that the standard library String.create assumes you want an extra byte allocated for the null pointer
<emilbayes> jemc: Ohhh
<emilbayes> jemc: Any reason not to use Array[U8] instead?
<emilbayes> also sorry if you have explained me this before, i come back to it every couple of months
<jemc> yeah, I was getting a feeling of deja vu :) - I don't remember the specific reason why I made this choice, as it was several years ago - but I can say in general that `String` is more flexible than `Array[U8]`
<jemc> for example, `String.clone` produces an `iso^`, while `Array.clone` produces a `ref`
<emilbayes> jemc: ah ok, I was just holding it up against what the stdlib digest functions do
<emilbayes> jemc: Do you know how I would pass "null" to C FFI?
<jemc> it can depend on what you're doing - what's the normal type you would pass there?
<emilbayes> jemc: unsigned char pointer in C
<jemc> yeah, so for that
<jemc> I'd do `Pointer[U8]` as the type
<jemc> and `Pointer[U8].create` will return a null pointer
<emilbayes> Ah ok!
<emilbayes> jemc: Hmm, I think I'm doing it wrong. How would I make key optional? https://gist.github.com/emilbayes/af42ba9bae79d71cc06d9e989173c194
<jemc> the issue is that your `if` statement doesn't actually interact with the type system to narrow the type of the `key` argument
<jemc> you need to use a `match` statement there instead
<emilbayes> jemc: Ah ok, will try!
<jemc> something like `match key | let k: Array[U8] => k.cpointer() else Pointer[U8].create() end`
<jemc> err.. sorry - `ByteSeq` instead of `Array[U8]`
<emilbayes> jemc: Hmm, I'm getting an error that None does not have a .cpointer and a .size: https://gist.github.com/emilbayes/af42ba9bae79d71cc06d9e989173c194#file-error
khan has quit [Quit: khan]
khan has joined #ponylang
<jemc> you need to use the `let k: ByteSeq` syntax instead of just `ByteSeq`
khan has quit [Client Quit]
khan has joined #ponylang
<SeanTAllen> Key is byteseq or none
<SeanTAllen> K would be just byteseq
<SeanTAllen> Does that make sense emilbayes ?
<emilbayes> jemc: Ah thank
<emilbayes> SeanTAllen: Yeah that makes sense
<emilbayes> and it works! Thanks heaps!
<jemc> there are some gotchas to `match` statement syntax - I'd recommend reviewing the `match` page in the tutorial
<SeanTAllen> You're welcome emilbayes
vaninwagen has joined #ponylang
<emilbayes> jemc: Why is the Array.clone not a "real" clone, but rather a clone of the "container"?
<emilbayes> jemc: The current clone behaviour seems more like a new view into the data than a proper clone
<dlowe> Deep copies have uncertain semantics.
<emilbayes> dlowe: How so?
<emilbayes> dlowe: Ah, I think I see it if the elements are not primitives themselves
rob has joined #ponylang
<rob> what does SetIs do?
rob is now known as Guest34019
<Guest34019> I see SetIs is an alias for HashSet[A, HashIs[A!] val] ref
<Guest34019> but I can't figure out how to use it properly
<vaninwagen> Guest34019: did you have a look at the stdlib docs already? https://stdlib.ponylang.org/collections-HashSet/
<vaninwagen> there is add for adding elements, contains for checking if an element is in a set, apply for checking for containment and getting the value if it exists, ...
<vaninwagen> what are you trying to to with your set?
<Guest34019> just learning :-)
<vaninwagen> you can tinker here: https://playground.ponylang.org/
<SeanTAllen> Set is
<SeanTAllen> SetIs compares elements by identity
<jemc> The generic `HashSet` doesn't presume to know how you want to hash and compare elements, so it expects you to provide a hash-and-compare implementation
khan has quit [Read error: Connection reset by peer]
khan has joined #ponylang
<jemc> `Set` and `SetIs` are convenience aliases that set up the hash-and-compare implementation for you (by structural equality and identity equality, respectively)
<vaninwagen> full #ponylang op support power to the rescue!
<jemc> emilbayes: yeah, you got the right idea - generic `Array` function signatures don't know that they're dealing with a primitive like `U8` that could be copied by value
<jemc> so even though it's safe to clone to `iso` for `Array[U8]`, the fact that it's not safe for other reifications means that the function can't exist
<jemc> we have an RFC that was merged some time ago to allow you to specialize the functions available for a generic type, to deal with these kinds of situations
<jemc> we approved the semantics, but it's quite complex to implement, so it hasn't become a reality yet
<emilbayes> Ah ok. Thanks jemc
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
vaninwagen has quit [Ping timeout: 248 seconds]
dgcaccam has joined #ponylang
M-hrjet has quit [Write error: Connection reset by peer]
dtz has quit [Read error: Connection reset by peer]
Miikka[m] has quit [Remote host closed the connection]
srenatus has quit [Remote host closed the connection]
irx[m] has quit [Write error: Connection reset by peer]
<dgcaccam> hey everyone, I have a question about the compiler and the capabilities. When initializing an object with a capability, where does the compiler store this information?
bb010g has quit [Read error: Connection reset by peer]
<dgcaccam> Looking for some kind of struct that has the object info and a capability field but can find no such thing
<dgcaccam> And looking at the send object method and tracing it back, it looks like the capabilities are hardcoded in. I am not sure how that works
Licenser has quit [Ping timeout: 240 seconds]
<jemc> dgcaccam: currently, capabilities are only a compile-time construct - they don't exist at runtime, and the type system ensures that capabilities are not ambiguous at runtime in a way that would affect execution
<jemc> there's been some chatter about encoding in the object header at compile time too, but that's not a reality at this time
<dgcaccam> Ahh I see that makes sense
Licenser has joined #ponylang
<emilbayes> Hoping for more help; I'm trying to extend my hashing example to a stateful hash but get an error in the recover in my `final` method, that _state is not sendable: https://gist.github.com/emilbayes/f84fa8d3d3e87cb2956647e32a9c782e
<emilbayes> I tried reading the section in the tutorial on recovery but having diffculty seeing how it is not sendable since it is private
sarna has joined #ponylang
dgcaccam has quit [Quit: Page closed]
<emilbayes> I'm also thinking the way I'm using the _state array, it should be isolated at all times of use. Does that mean my methods should be iso, state should be iso or the whole class should be iso?
<jemc> I'll take a look
bb010g has joined #ponylang
<emilbayes> thanks jemc!
<emilbayes> Maybe iso is overkill here, still trying to get the thought patterns of when to use the different capabilities right
<jemc> yeah, it's tough - I'll try to provide some guidance, but feel free to ask followup questions
<jemc> so, recover is used in situations where you're trying to create something new, using only sendable references, and end up with a sendable result
<jemc> the `_state` reference here isn't sendable - it's a `ref` - the only sendable caps are `iso`, `val`, and `tag`
<jemc> `tag` isn't the right choice here, since you need to be able to read and write from state
<jemc> in this case, you could probably get away with it since you're using FFI and setting the signatures yourselves, but it would be violating the "spirit" of `tag`
<emilbayes> So I should make it iso?
<emilbayes> If I make the _state iso an my functions ref it compiles
<jemc> `val` is similar, since you want the state to be mutable - again, you could probably get away with it by fudging the FFI signatures, but you'd be violating the spirit of `val` and opening yourself up to accidentally sending it to another thread
<emilbayes> but is this the right way to go?
<emilbayes> ya
<jemc> `iso` is the only other option for making `_state` sendable, but it's also not quite right - basically every time you have an `iso` field, you end up having to make it a `var`, and use destructive reassignment to get the reference out of its slot in the field without aliasing it
<jemc> this is used appropriately in some places (like `buffered.Writer`, for example), but it's usually too cumbersome to be a clean solution
<jemc> I think what you want to do here is just to not use a recover block
<emilbayes> Ah, so the reason I had the recover block was because I wanted to make hash `Array[U8] val`
<jemc> instead, I think you want to create the `hash` reference as an `iso` (or `trn`, either would be correct in this case since both can decay to `val`)
<jemc> so, something like `let hash = recover trn Array[U8](_output_len)`
<jemc> and remove the outer recover block
_andre has quit [Quit: leaving]
<emilbayes> ahh ok
<jemc> this kind of use case is actually the main reason `trn` exists - to have a temporarily mutable reference that you then "decay" to a `val` when you're done initializing it
<jemc> hopefully my extended explanation helped to get you better acquainted with the kind of thought process to use in such a situation
<emilbayes> jemc: but wont I touch it right after creating it for my ffi call?
<emilbayes> jemc: It is extremely helpful!
<jemc> yes, you'll mutate it right after creating it, then you'll finalize it as a `val` by returning it at the end
<emilbayes> jemc: Ahh ok!
<emilbayes> What about my iso = recover block when defining state?
<jemc> this is `trn`'s purpose in life - create as `trn`, take some steps to initialize/mutate it, then finalize it to a `val` and let no-one mutate it ever again
<jemc> the `_state` as an `iso` part of your gist is unnecessary here, and would not usually be allowed if it weren't for the fact that you're mutating via FFI instead of in pure pony
<jemc> so I'd recommend keeping it as a `ref`, as it will stay truer to the way it would look if implemented in pure pony
<jemc> but yeah, the `final` function looks correct
<emilbayes> ah ok
<emilbayes> this is cool!
<emilbayes> jemc: Thank you so much
<emilbayes> this has given me a lot of confidence :D
<jemc> great, glad to help!
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
Guest34019 has quit [Ping timeout: 260 seconds]
bb010g has quit [Write error: Connection reset by peer]
bb010g has joined #ponylang
acarrico has joined #ponylang