<TwoNotes>
Compiler says parameter type TimerNotify but argument 'MultiRole tag'
<Praetonus>
I think the problem is that not all of your fields are initialised when you use this, so this is a MultiRole tag and not a MultiRole iso
<sblessing>
correct!
CJL has joined #ponylang
CJL has quit [Client Quit]
jemc has joined #ponylang
<TwoNotes>
Hmm, but the socket returned by UDPSocket is itself one of the fields!
<TwoNotes>
So if I make it a var with an alternate type of None, and init it to None, that would work?
<TwoNotes>
Doing protocols requires timeouts, so I need access to UDP events and Timer events at the same time
<TwoNotes>
Why is an Array literal 'ref' instead of 'val'?
amclain has joined #ponylang
<TwoNotes>
In what actor are Timer 'apply' functions executed?
Matthias247 has joined #ponylang
copy` has joined #ponylang
<_andre>
stupid question but uhm... how do i print an F32 or F64? they don't have a string() method
<jemc>
TwoNotes: because ref can be recovered to val, but not the other way around - I think possibly making it infer the array cap from the lhs cap has been discussed before though and might be implemented in the future
<jemc>
TwoNotes: a Timer object is expected to live and be executed from within a Timers actor - the idea is that if you have many timers you can run them from a single actor that wakes up whenever the next timer expires so that you're not wasting lots of asio handles and other resources
<jemc>
_andre: last time I checked, they did indeed have a string() method - checking again
<Praetonus>
_andre: F32 and F64 do have a string() methode, provided by the FloatingPoint trait
<_andre>
if i change 'let s: S' to 'let s: T' it compiles
<TwoNotes>
So a Timer.apply executes in the same actor that created the Timer? Or in a diferent one like UDPSocket callbacks?
<jemc>
TwoNotes: it executes in the Timers actor
<jemc>
_andre: I have to run to a meeting but will take a look at your pastebin after
<Praetonus>
_andre: Looks like string() for integer types expect a FormatSettings[FormatInt] and string() for floating point types expect a FormatSettings[FormatFloat], so the two signatures are incompatible
<TwoNotes>
So, any way it interacts with the rest of my code has to be with 'be' calls?
Matthias247 has quit [Read error: Connection reset by peer]
<_andre>
Praetonus: oh :(
<_andre>
guess i'll split the union in two then
<jemc>
Praetonus: if that's true that may not have been the intended effect when they made that change
<jemc>
ideally all Stringables should have the same signature
<jemc>
_andre: might be worth filing an issue for sylvanc or andymcn to look at
srenatus has quit [Quit: Connection closed for inactivity]
juanjoc has quit [Quit: Leaving]
<SeanTAllen>
keep it up _andre! shake those bugs out.
<_andre>
:)
<darach>
They're not bugs, they're community contribution features! :)
<_andre>
haha
<_andre>
it's working :p
<_andre>
the mysql bindings are almost done
<_andre>
just need to handle date/time objects
<shepheb>
hm
<_andre>
and then figure out a ponyish interface with notify objects instead of throwing errors everywhere
<shepheb>
I have need to create an actor as an iso, pass it to Stdin as the receiver, but retain a tag to the actor.
<shepheb>
but I can't just assign it, really
<shepheb>
I want like a softer consume, or something.
<jemc>
an actor can only be passed to another actor as a tag
<jemc>
anything else would let the other actor directly read/write state, which isn't safe
<shepheb>
yes, I understand
<shepheb>
Stdin wants a StdinNotify iso
<shepheb>
I've created one, and will pass it (synchronously)
<shepheb>
but I also want to retain a tag reference to that same notifier, so I can send it messages too
<jemc>
the rule I mentioned above effectively means that StdinNotify cannot be an actor
<jemc>
it should usually just be a "dumb" object that simply forwards messages to your other actor
<TwoNotes>
_andre what I did for errors was call a user-provided notify class, passing the error code and a string of what it means, but only if the code was not "OK". Then, I would throw an error for all codes other than the one that means "no more rows in the query", as that case gets handled by the 'has_next' iterator code.
<TwoNotes>
Maybe there should be a standard interface for these things that people could use - like what is the name of the function entry point, etc
<jemc>
shepheb: the pattern I like to use is: within my actor that needs to hear from Stdin, create a method like this in MyActor to generate a notify object as "glue code" `fun tag notify() => object is StdinNotify; let parent: MyActor = this; ... end`
<_andre>
when i match multiple values like in "match x | 1 | 2 => ..." is there a way to get a binding to the matched value?
<TwoNotes>
match foo | let v: String => v.something() end
<_andre>
well my example would be more like match foo | "x" | "y" as v: String => v.something() end
<TwoNotes>
If you mean just a simple value match, well, you know what the value is already. And you could also refer back to the arg to the match
<_andre>
huh indeed
<TwoNotes>
You can not refer back to the match arg if it is a union type, but you can for simple values
<shepheb>
ah, okay, that makes sense and will work
<shepheb>
a different, unrelated problem: I cant seem to create a List[U8] iso
<TwoNotes>
UDPSocket constructor returns a tag, but UDPSocket.local_address() expects a box receiver. grrr
<TwoNotes>
Doc on all the ways to change capabilities would be nice. "To turn a ref into val, use recover. To convert X to Y, do this..."
mitchellvanw has joined #ponylang
<mitchellvanw>
morning
<jemc>
good afternoon :)
<shepheb>
still having a lot of trouble creating a tag ref to another actor
<shepheb>
it seems like it wants to create that other actor as a ref
<darach>
'rag ref' <- brain hurty!
<darach>
'tag ref' :/
<jemc>
shepheb: your earlier question about creating a List[U8] iso: `let x = recover iso List[U8] end`
<TwoNotes>
Can a 'be' declaration take a viewpoint parameter? Like "be box foo() =>" ?
<jemc>
also my earlier example for `fun tag notify() => ...` should have been `fun tag notify(): StdinNotify => ...` but you probably figured that out
<jemc>
TwoNotes: I don't think I've ever tried, but yes I think it should work
<TwoNotes>
I have a Timer action routine, 'apply' that has to return a Bool. But what it returns depends on some state in another class. Since TimerNotify classes are iso, and belong to the Timer control actor, how can I get this bit of state available to the apply function?
<jemc>
TwoNotes: honestly, you probably need to change your paradigm a bit to make it work - off the top of my head, you could try something like this:
<jemc>
* your TimerNotify holds a tag to the actor that holds the state you need
<TwoNotes>
yes, got that
<jemc>
* your actor-that-holds-state (I'll call it A) has a tag to the Timers actor that contains your Timer
<TwoNotes>
yes
<jemc>
* your TimerNotify calls a behavior on A and passes the `Timer tag` and any other info it needs
<jemc>
* your TimerNotify's applyalways returns true, so it never directly cancels
<TwoNotes>
So the outer actor does a Timers.cancel on it.
<jemc>
* A will receive the behavior call and calls timers.cancel(timer) based on the state
<jemc>
yeah
<TwoNotes>
whew
<TwoNotes>
Kind of round about
<TwoNotes>
Only bad thing would be on a heavily loaded system the 'be' call might get backed up and not fire before the next timer event goes off. Have to defend against multiples...
<jemc>
yeah, well I think you should always consider "notify" objects to be more like glue code between two actors than really capable of acting on their own
<TwoNotes>
I am finding that out
<jemc>
TwoNotes: yes, that race is a concern
<TwoNotes>
Comm protocol programming is full of such headaches. Oh well
<jemc>
however, your A actor is the central point where you manage state so you should know what to ignore and when
<TwoNotes>
Yes. That is how it is shaping up.
<TwoNotes>
My voice control program runs in multiple distributed parts, each one handling certain kinds of activities (lights, movie library, etc) and they all communicate over UDP messages on the house LAN.
<TwoNotes>
This is how you can plug in new sorts of activities without modifying any of the central server code
<_andre>
have a good weekend everyone
_andre has quit [Quit: leaving]
kulibali has quit [Ping timeout: 260 seconds]
emancu_ has joined #ponylang
trapped_ has joined #ponylang
emancu has quit [Ping timeout: 276 seconds]
doublec has quit [Ping timeout: 276 seconds]
doublec has joined #ponylang
trapped has quit [Ping timeout: 248 seconds]
<doublec>
shepheb: did you solve your List[U8] iso problem?
_ has joined #ponylang
_ is now known as Guest81970
trapped_ has quit [Ping timeout: 244 seconds]
Matthias247 has joined #ponylang
TwoNotes has quit [Quit: Leaving.]
tdc has joined #ponylang
jemc has quit [Ping timeout: 268 seconds]
Matthias247 has quit [Read error: Connection reset by peer]