<polypus74>
i've got a pointer to a struct being returned bt an ffi call. i have defined a struct in pony. i'd like to access a field of that pointer to struct. how to dereference the pointer?
<polypus74>
s/bt/by
<Praetonus>
polypus74: A struct in Pony is implicitly a pointer, accessing the field will dereference it
<Praetonus>
Oh, sorry, I misread
<Praetonus>
Or not. I'm confusing myself, that's not good
<polypus74>
:)
<Praetonus>
So, does that solve your problem?
<polypus74>
no. basically i have 'struct X var x: Y' and then i have a 'let z: Pointer[X]'. and i want to read z.x. but i'm getting an error that x is not defined on None
<polypus74>
should i not wrap X in a Pointer is that what you are saying
<polypus74>
because the C side has 'X* getX()'
<Praetonus>
What is the declaration of your FFI function?
<polypus74>
getX[Pointer[X]](...)
<Praetonus>
You can do getX[X](...), you'll get a pointer in Pony
<Praetonus>
A Pointer[T] is a T** under the hood
<polypus74>
T**, applies only to structs then i take it
<polypus74>
in that case how do you handle the case of struct returned by value?
<polypus74>
how do you write the signature for 'X getXVal()'
<Praetonus>
You can destructure it with a tuple. That's not really convenient and there are unresolved issues (see #1240 on Github), but I hope my upcoming RFC on some FFI stuff will improve that
<polypus74>
ahh ok, so when dealing with values, use tuples, else a struct has an implicit *. merci
<polypus74>
indeed it compiles :)
<Praetonus>
Great!
<polypus74>
so if a struct is an mplicit pointer, how do you check it for NULL? is_null() from Pointer is not defined on it
<Praetonus>
You'll have to use MaybePointer for this. The name is a bit misleading, it doesn't behave like Pointer and doesn't add a level of indirection. Doing MaybePointer[X](myX) will construct a MaybePointer with the same value as the original object. You can then use is_none() to check for NULL and apply() to "re-encode" the MaybePointer into the original object type
<polypus74>
ok ty. i was trying to use tuples but was running into problems with recursive type aliases. i hope pony gets those soon.
<polypus74>
i'll have a look at MaybePointer
Praetonus has quit [Quit: Leaving]
pyon has quit [Quit: Reality is multi-dimensional. More precisely, two-dimensional.]
pyon has joined #ponylang
<SeanTAllen>
I still don't have anything for the October Pony VUG yet. If you are interested in presenting, drop a line.
<polypus74>
what about the game engine talk?
<polypus74>
i hope that's still on
<SeanTAllen>
O wow
<SeanTAllen>
I forgot about that
<SeanTAllen>
Dur
<SeanTAllen>
November! Need folks for novrmber!
<polypus74>
:)
<polypus74>
how to deal with a wchar_t string from C-land?
<polypus74>
i want to convert it to String
rurban has joined #ponylang
rurban has quit [Client Quit]
montanonic has joined #ponylang
polypus74 has quit [Remote host closed the connection]
amclain has quit [Quit: Leaving]
mitchellvanw has quit [Ping timeout: 244 seconds]
mitchellvanw has joined #ponylang
montanonic has quit [Ping timeout: 240 seconds]
montanonic has joined #ponylang
rurban has joined #ponylang
montanonic has quit [Ping timeout: 260 seconds]
rurban has left #ponylang [#ponylang]
dinfuehr has quit [Ping timeout: 265 seconds]
dinfuehr has joined #ponylang
montanonic has joined #ponylang
dimiii has joined #ponylang
dimiii has quit [Client Quit]
dimiii has joined #ponylang
montanonic has quit [Ping timeout: 272 seconds]
dimiii has quit [Quit: Leaving.]
TonyLo has joined #ponylang
rurban has joined #ponylang
_andre has joined #ponylang
Praetonus has joined #ponylang
jemc has quit [Ping timeout: 250 seconds]
rurban has quit [Quit: Leaving.]
dimiii has joined #ponylang
<dimiii>
Hi there.
<dimiii>
Please, add to appendices of tutorial some words about USE_TELEMETRY. Also It's interesting, is there any description of details of implementation? I see source code is excellent and has many comments, sure it would be fine to see some conceptual/general remarks over code.
<avsej>
is it possible to destructure tuple so that I will capture first two memebers separately, and eveyrhing else into third variable as tuple: (var x, var y, var rest) = ("foo", "bar", "baz", "extra")
rurban has joined #ponylang
jemc has joined #ponylang
CcxCZ has quit [Read error: Connection reset by peer]
CcxCZ has joined #ponylang
<SeanTAllen>
avsej: i'm not sure, did you try? i suspect it wouldn't work.
<SeanTAllen>
dimiii: we'd welcome a PR for that. there's nothing out there for that right now.
<avsej>
yes, I tried, and it didn't work
<avsej>
:)
rurban has quit [Quit: Leaving.]
<Praetonus>
Being able to slice tuples would be interesting, and I think it could cover that use case
amclain has joined #ponylang
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
runehog has quit [Remote host closed the connection]
dimiii has quit [Quit: Leaving.]
dimiii has joined #ponylang
TonyLo has quit []
<avsej>
SeanTAllen, I'm trying to use FilePath, but I'm getting error. How I can determine what gone wrong in the error handler?
<avsej>
and it is not clear how to open files with absolute path
<avsej>
like /etc/fstab
runehog has joined #ponylang
<avsej>
okay. nevermind. I traced it
dimiii has quit [Quit: Leaving.]
montanonic has joined #ponylang
<avsej>
if I have an actor, may I call it somehow to instruct it mutate itself? actor is a tag, but my function-mutator is a ref, so it does not allow to invoke the function
<avsej>
oh, my fault. I didn't use 'be' for that function