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.
<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.
<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)
<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
<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
<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?
<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
<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>
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]