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
_etc has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
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()`
<_etc> Woah
<_etc> that makes so much sense! Thanks :)
_etc has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
_etc has joined #ponylang
_etc has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
jemc has quit [Ping timeout: 260 seconds]
jemc has joined #ponylang
aceluck has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
plietar has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
<Candle> _etc: That's one of the sugary bits listed in https://tutorial.ponylang.org/expressions/sugar.html.
samuell 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
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
<jemc> endformationage: some relevant discussions to this topic happened a few days ago: see here: https://irclog.whitequark.org/ponylang/2017-08-08#19907406;
<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?
<doublec> kulibali: this works for me: https://pastebin.com/cyPcLFkt
zaiste has quit [Ping timeout: 248 seconds]
<kulibali> your example works for me but in my actual code (which is a bit more complex) the compiler crashes https://playground.ponylang.org/?gist=c01a11bbb5c1891e84080cf00a828f71
<SeanTAllen> kulibali: you can use a match
<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
<kulibali> iff they are U8s then i want the result to be "abcd" and not "979899100"
<SeanTAllen> ah
<SeanTAllen> i get it
<kulibali> don't tell anyone, but i'm working on a PEG parser generator too :-)
<SeanTAllen> another one!
<SeanTAllen> So
plietar has joined #ponylang
<SeanTAllen> when i boil this down
<SeanTAllen> i think
<SeanTAllen> the problem is that item is a T #read
<SeanTAllen> and that the capture hates taht
plietar has quit [Ping timeout: 260 seconds]
<kulibali> isn't val in #read?
<kulibali> U8 is val by default, right?
<SeanTAllen> o this is interesting
<kulibali> your example compiles with `let ff: box->T = item`
<kulibali> but my original still complains on `| let ch: box->U8`
jmiven has quit [Quit: co'o]
<SeanTAllen> yes
<SeanTAllen> i know
<SeanTAllen> i was breaking it down to see what was going on
jmiven has joined #ponylang
endformationage has quit [Quit: WeeChat 1.9]
<SeanTAllen> someone more knowledge than me needs to help with that
<SeanTAllen> i think this deserve an entry in the how to read errors section of the tutorial
<kulibali> heh - i'm still mostly at the voodoo stage - poke it with some random ref caps and see what happens