plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 276 seconds]
_etc has joined #ponylang
_etc has quit [Client Quit]
_etc has joined #ponylang
<_etc>
So when I have a class Foo that has create() with no arguments and it has apply() with no arguments then calling Foo() calls both create() and apply() - is this a design decision or just a biproduct that apply is called when create has no arguments?
<jemc>
_etc: if you just want to call `create`, use `Foo` - if you want `create` then `apply`, use `Foo()`
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 240 seconds]
plietar has joined #ponylang
aceluck has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_whitelogger has joined #ponylang
jemc has joined #ponylang
_andre has joined #ponylang
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
Praetonus has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 240 seconds]
plietar has joined #ponylang
plietar has quit [Ping timeout: 240 seconds]
theodus has joined #ponylang
theodus has quit [Client Quit]
endformationage has joined #ponylang
plietar has joined #ponylang
tscho has quit [Read error: Connection reset by peer]
tscho has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
samuell has quit [Quit: Leaving]
Matthias247 has joined #ponylang
plietar has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
plietar has quit [Ping timeout: 255 seconds]
zaiste has joined #ponylang
plietar has joined #ponylang
<endformationage>
In the 'C Types' section of the tutorial's C FFI chapter: "Pony classes correspond directly to pointers to the class in C."
<endformationage>
I'm not sure what this means or how I can use this when working with FFI. Is there an example somewhere?
<Praetonus>
endformationage: It means that a reference to an object in Pony (i.e. of type A) is ABI-compatible with a pointer to an object in C (of type A*)
<Praetonus>
So if you pass a reference as an argument to an FFI call, the corresponding C parameter must be a pointer
<endformationage>
Ah, interesting. Going to reread the C ABI section.
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_andre has quit [Quit: leaving]
<endformationage>
Are there any FFI examples which pass Pony objects in this way? I've seen the ffi-struct example.
<jemc>
endformationage: I think the FFI struct example is the best example of this - what's missing?
<endformationage>
I guess I'm wondering if you access the Pony object's fields on the C side of things the same way you would from a passed struct.
* endformationage
is obviously new to FFI dealings
<jemc>
if you want to access the fields on both sides, it needs to be a `struct` in Pony, not a `class`
<jemc>
a Pony `class` has some extra overhead bytes for runtime type matching, and a Pony `struct` leaves those out (at the cost of not being able to do runtime type matching)
<jemc>
if you want to "export" a Pony class to use from C, there's an option to do that, and it generates the C header for you
<jemc>
but you'll only have access to the methods, not the fields - it's like the C pattern of an opaque struct
<endformationage>
Ah, OK that is what I was getting at.
<endformationage>
So the 'Pony class as a pointer bit' really only applies to using Pony code exported as a C ABI compatible library, and would not really be useful, for example, passing a pony object directly to an FFI call expecting a pointer to such a type.
<jemc>
well, it's true all the time - the difference is that your C program doesn't have any way of knowing the memory layout of the type
<jemc>
so it's a pointer to an opaque struct, in effect
<endformationage>
Thanks for the help!
<jemc>
which is a really common C design pattern for keeping separation of concerns - having opaque structs that you can't do anything with directly, and can only be used with the provided functions
<jemc>
no problem!
<endformationage>
Good to know.
adam__ has quit [Ping timeout: 260 seconds]
Praetonus has quit [Quit: Leaving]
zaiste has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
Matthias247 has quit [Read error: Connection reset by peer]
kulibali has joined #ponylang
<kulibali>
hey, if I have a `class Foo[T: (Hashable &read & Equatable[TSrc] #read & Stringable)` how can i test if a variable of type `T` is a `U8` and get its value as U8?
<kulibali>
both `match` and `as` give "this capture violates capabilities"
<kulibali>
i think `iftype` can tell me if it's a `U8` (currently crashes for me) but how do i get the value as U8?
<kulibali>
if i try match it says "this capture violates capabilities"
<SeanTAllen>
hmmm
<SeanTAllen>
can you open a bug report for the bad error message for the "this capture violates capabilities"?
<SeanTAllen>
i think we can do better
<kulibali>
ok
<SeanTAllen>
what are you trying to do here?
<SeanTAllen>
leaving aside the capture error, why push a U8 but append anything else after calling .string() ?
<SeanTAllen>
T has to be Stringable so why not...
<kulibali>
i'm trying to get a string representation an arbitrary sequence of Stringables, only if they're U8s then i want their characters rather than their numbers