gmcabrita has quit [Quit: Connection closed for inactivity]
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
amclain has quit [Quit: Leaving]
aav_ has joined #ponylang
aav has quit [Ping timeout: 264 seconds]
troxid has joined #ponylang
magicbit has quit [Ping timeout: 240 seconds]
magicbit has joined #ponylang
troxid has quit [Quit: Page closed]
jemc has quit [Ping timeout: 260 seconds]
jmiven has quit [Read error: Connection reset by peer]
jmiven has joined #ponylang
Praetonus has joined #ponylang
rosstuck has joined #ponylang
rosstuck has quit [Remote host closed the connection]
gmcabrita has joined #ponylang
K4rolis has joined #ponylang
<K4rolis>
hi pony experts! I've got question on something that I suspect is quite a common pattern, but I just don't know how to elegantly do it. Let's say I've got a ref field in an actor which is an array of some objects with val capabilities. Let's now say that I want to take that field, make a val copy of it and send it to other actors. How do I do it?
<K4rolis>
the initial idea is to do something sendable_field = recover val non_sendable_field.clone() end , but obviously that does not work given that non_sendable_field is, in fact, non sendable :)
<Praetonus>
K4rolis: You can first create a new iso or trn Array and then append the elements to it manually
<Praetonus>
Note that line 5 it should be possible to do `recover trn Array[U8](_array.size()) end` (the method is safe to call inside of the recover expression since the result is sendable) but apparently there is a compiler bug here and it isn't allowed. I'll look into it
<K4rolis>
thank you, this makes sense. I've experimented with something like this before and got it to work, just wondered whether I could accomplish this with clone()
<K4rolis>
I'm sure to have more questions to do with how to implement things "the pony way", because at the moment I feel that I'm fighting against capabilities rather than using them appropriately :)
<Praetonus>
Yeah, it takes some time before getting the hang of it. Feel free to ask your questions here or on the mailing list
<K4rolis>
just out of curiosity - does consume actually result in any instructions after the code has been compiled or is it purely for compile-time checks?
<SeanTAllen>
compile time
<SeanTAllen>
K4rolis: i'm curious. what's your particular use case for having the mutable field that you hold on to the data of but send immutable copies of to other actors. Not saying this is unusual, but I'm always interested in hearing specific use cases that might lead to a good pony pattern to write up.
xyproto has joined #ponylang
<xyproto>
when using a C library from pony, like SDL2, how do I use a constant from C, like SDL_WINDOWPOS_UNDEFINED? use? let? primitive?
<xyproto>
I could not spot anything about this in the documentation.
<K4rolis>
SeanTAllen: it's a simulation - the mutable field lives in controller actor and effectively holds history of past states (it is used as a shift register) and those past states are required for the calculation of new states by the actors
<K4rolis>
the execution of the simulation is effectivelly a fork-join thingy where a controller sends out a task and sits there waiting for all the workers to return their results
<SeanTAllen>
xyproto: when i say "don't really exist" for constants, i mean there is nothing exported from c code that pony could access as constants are generally text replacements done by the c preprocessor.
<xyproto>
SeanTAllen: I see, thanks! Will just create my own constants in the pony code, then.
<xyproto>
How do I pass a NULL to a C function when calling a C function from pony?
<SeanTAllen>
use None
<SeanTAllen>
not "use None"
<SeanTAllen>
but
<SeanTAllen>
None
<SeanTAllen>
words, sometimes, they are difficult
<xyproto>
:)
<xyproto>
thanks, will try that
<SeanTAllen>
is this a pointer?
<xyproto>
yes
<xyproto>
it expects a Pointer[_SDLRect], but I want to send in NULL
<SeanTAllen>
is _SDLRect a struct in Pony?
<SeanTAllen>
if yes, you should also check out MaybePointer and see if that is more appropriate
<xyproto>
yes, it's defined with "struct _SDLRect\n var x: I32 = 0" etc
<SeanTAllen>
check out MaybePointer
<xyproto>
will check out MaybePointer, thanks!
<SeanTAllen>
all FFI advice from me should be taken with a grain of salt as my experience is limited to certain key areas. its probably right but... possibly wrong
<xyproto>
no worries, I am completely new to Pony and solidly in trial-error-read-documentation-ask-on-irc-land.
<xyproto>
MaybePointer[None] is not allowed, and MaybePointer[_SDLRect](None) says thaat argument is not a subtype of parameter. MaybePointer[_SDLRect](0) results in "could not infer literal type". A bit stuck.
<xyproto>
does the "tag" keyword make any difference?
<Xyliton>
(according to the IRC logs my messages never arrived here so I'll just resend them. I hope that it's actually my client that messed up and I'm not sending these messages the n-th time to you now)
<Xyliton>
I'm still trying to get my timed websocket message(s) working. Someone (sorry, forgot who it was) told me to use an actor which "manages" both the timer and the websocket notify, but I can't seem to implement that the way it was meant to be
<Xyliton>
I messed everything up now, and this whole actor-model is confusing me a lot (+ all these capabilities ;-;)
<jemc>
Xyliton: I think it was me you spoke with about this before - and don't worry, your client was disconnected, we didn't see your messages from before
<jemc>
can you describe your difficulties?
<Xyliton>
okay, so... After connecting to the server I want to interact with I'm forced to send heartbeat intervals in a regular interval. These heartbeat messages have to contain a payload I get with every message the server sends me (I always have to send the newest one)
<Xyliton>
s/intervals/messages/
<Xyliton>
But I'm not entirely sure where I should save said payload or the interval so I can create a timer which sends messages. This timer needs access to bot the tcp connection and the payload