<TJ800X>
Is there anything in Pony like a static variable? I'm guessing not, and that I should create a context in my library and use that context for state. Does that sound correct?
<jemc>
tj800x: yes, that sounds like the correct design pattern
<TJ800X>
For a single value, should the context state be a simple variable, an instance of a class, or an actor?
<jemc>
in the future, we're planning to have a separate construct for compile-time constant values (dependent types), but that doesn't exist yet
<jemc>
tj800x: do you need to mutate the global state, or is it a constant/immutable value?
<TJ800X>
Global immutable state.
<jemc>
you probably want a `class val`
<TJ800X>
Is Env a good thing to look at here. I'm sure it's much more complicated than I need.
<jemc>
tj800x: you won't be able to add your own values to `Env`, since it's immutable and already fixed by the time you receive, it but it's a similar design pattern to what you probably want to do with your "Context"
<TJ800X>
I was thinking it would be a good example to look at when building my own context.
<TJ800X>
I found it and will try and learn from it.
<TJ800X>
Pony is absolutely amazing. Very hard, but worth the effort.
<jemc>
yes, I see it as being quite a steep learning curve to climb, but very rewarding
Praetonus has joined #ponylang
<dyreshark>
hi! i'm running https://is.gd/7v13Np on my MacOS box, and it's (apparently) consistently taking 50% of a core. is that expected?
<TJ800X>
If I am creating a context at the top of my main and then passing it around, does it make sense to create it as an iso? I will be mutating the context from down inside my library.
<Praetonus>
tj800x: It should be iso if you intend to pass it to other actors. Otherwise, ref is fine
<jemc>
tj800x: if your requirements are *sendable* (between actors) and *mutable*, then yes, it would need to start its life as an `iso`
<jemc>
however, if you need to share it globally among many actors at once as you dsecribed earlier, you will need to step down from `iso` to `val` before it is *shareable*
<jemc>
(obviously, at which point it is no longer *mutable*)
<TJ800X>
Thanks for your patience.
<jemc>
happy to help! :)
<TJ800X>
I'm making all sorts of notes. It might make a good "Pony for Mere Mortals" type book.
<TJ800X>
Is there any way to print the reference capabilities of a variable? I'd like something like is_iso(refa) which would return tru if refa was an iso
<TJ800X>
At this point to figure things out I'm having to purposely assign variables to tag and see what error message the compiler kicks out.
<jemc>
tj800x: actually, that's not possible, because reference capabilities don't exist at runtime - they are purely a compile-time check - a zero-cost abstraction
<TJ800X>
Yes, that makes sense.
<TJ800X>
Any better way of doing it then trying to assign it to a tag?
<jemc>
with regard to your approach of assigning to `tag` - that's probably not going to help you much because `tag` is a subtype of everything, thus you can assign any cap to it
<jemc>
you could assign to an `iso`, which would succeed if the right hand side is `iso^` and fail for every other cap with a message telling you which cap it is
<TJ800X>
Im just trying to create a simple table that tells me how to get from one capability to another. I don't think what I've been doing is structurally all that wrong, I just dont get it I guess.
<TJ800X>
I've spent another six hours and am no closer to understanding this thing it seems.
<TJ800X>
Some sort of compile-time stop that simply prints the capability type at a given point would certainly help.
<TJ800X>
whatis(refa) . String iso <<COMPILER HALTED>> would be welcome.
<TJ800X>
I've been assigning numbers to String iso and getting similar results I think.
<TJ800X>
So far, here is what I understand. If I have an ISO, it is like two bands are around it blocking read and write from any other aliases in the world of Pony.
<TJ800X>
Only the variable reference can mutate it or read it.
<TJ800X>
Lets say I have a variable named refa_iso. If I do a refb = recover refa_iso end, it destructively reads the memory associated with refa_iso and essentially repoints that memory block to refb.
<TJ800X>
Now, what is refb's capability. I assume it depends on how it was declared.
<jemc>
close, but `consume` is the keyword to destroy a reference, not `recover`
<jemc>
I've gotta run for a sec, but I'll be back soon to answer more questions
<TJ800X>
Okay. consume. <<POUNDS HEAD HARD>>
<TJ800X>
Consume is the one that isn't in the block.
<TJ800X>
Is that because consume only works on simple variables?
smoon has joined #ponylang
<TJ800X>
So, according to the "Chart" -- the one with ISO, VAL, and TAG on the diagonal....
<TJ800X>
We can go down and to the right implicitly.
jemc has quit [Ping timeout: 260 seconds]
<TJ800X>
Does that mean, single step down, or single-step right, or multiple-steps?
<TJ800X>
The whole down-right implicit talk doesn't make sense to me. In order to do anything with an ISO you have to consume it.
<TJ800X>
It seems to me like down-right is really implicitly converting "from below and from right"