<Praetonus>
By looking at the code of the json package, I don't really understand why data in JsonDoc is ref and not iso. I'll open an issue about it
<TwoNotes>
SeanTAllen, tutorial.ponylang.org says that the tutorial can be accessed at tutorial.ponylang.org.
<TwoNotes>
Praetonus, what I am looking for is a way to go from a String val JSON to val versions of the parsed objects, without having to write 3 pages of code.
<TwoNotes>
The trick is, the intermediate data structures involved in the parsing cannot be val
<Praetonus>
I think the best you can do is to recursively pattern-match on the Json types when you get a JsonArray or a JsonObject
<Praetonus>
What do you want on the other side? An array?
<doublec>
Has something involving AmbientAuth/FilePath changed recently? I updated ponyc and am getting errors in that part of code.
c355e3b has quit [Ping timeout: 248 seconds]
<Praetonus>
doublec: Yes, I've seen something about FilePath in sylvanc's recent overhaul of ambient authority in the net package
<TwoNotes>
I can accomplish this by picking apart the entire JSON structure, then passing simple strings and numbers into the constructors for my final 'val' objects. But that puts knowledge of the JSON/object mapping in my top level code. I want to put that mapping knowledge inside the class constrcturs themselves, and that is where I run into this problem.
<doublec>
Praetonus: thanks, found the commit
<TwoNotes>
Praetonus, starting with a string like {"a":1, "points":[{"x":10,"y":15}, {"x":19,"y":7}]}
strmpnk has quit [Ping timeout: 248 seconds]
c355e3b has joined #ponylang
<TwoNotes>
I want to construct one object containing 'a' and 'points', and 'points' itself is an Array of xy coordinate objects
<doublec>
I just needed to do an "env.root as AmbientAuth" in places
trapped_ has joined #ponylang
strmpnk has joined #ponylang
trapped has quit [Read error: Connection reset by peer]
trapped_ is now known as trapped
<SeanTAllen>
yup, that would be it doublec
<doublec>
TwoNotes: can you extract the iso data object from the json and pass that to your class constructors?
<doublec>
TwoNotes: using destructive assignment as suggested by Praetonus
<TwoNotes>
It worked on the topmost element so it would probably work lower down as well. But I think my original way is cleaner. Just do not try to use constructors that take JsonObject as a parameter.
<Praetonus>
SeanTAllen: Did we lost syntax highlighting in the tutorial?
copy` has joined #ponylang
<doublec>
TwoNotes: you can also do the json parsing within a recover, return the result as an iso
<TwoNotes>
Yes, I was thinking of that. I have to parse the entire JSON string into a single toplevel object, with all lower level objects beneath it. And JSON parsng requires the use of 'try' blocks, which constructors do not like
<TwoNotes>
It seems like the 'else' branch of a 'try' is not taken into account when it tests whether all fields have been initialized.
<doublec>
TwoNotes: huh, you're right, it doesn't
<TwoNotes>
I've run into that before... very frustrating
<TwoNotes>
That seems like a bug to me - there is no path thru the code that does not initialize the fields, but the compiler does not see it
<doublec>
Yes, you should raise an issue
<TwoNotes>
There are two ways to use try. a = try 1 else 2 end and the other is try a=1 else a=2 end
<TwoNotes>
I am sure it does not like the second form. Not sure about the first.
<TwoNotes>
But if the thing being try-ed is complex, you really need to use the 2nd form
<Praetonus>
I think there is an open issue about this
<TwoNotes>
Yes, that is exactly what I run into. Any time you deal with hash maps, arrays, or parsing, there is a try-block around somewhere
jemc has joined #ponylang
<TwoNotes>
And if you make all your fields unions with None, and initialize them to None, you condemn yourself to having to use a 'match' every time you refer to them.
<TwoNotes>
I added a comment to that issue.
<doublec>
I hit it with TCPConnections. I end up with "conn as TCPConnection" every wrapped in try blocks.
<doublec>
s/every/everywhere/
<doublec>
Or create the connection outside of the actor/class and pass it in the constructor
<TwoNotes>
I don't think creating a TCPConnection can fail. What happens is the Notify callback for failure gets called, and the mainline ends up with a 'conn' variable that won't work. But it still exists
<TwoNotes>
Since a TCPConnection is an actor
<doublec>
TwoNotes: ah right - in my code I use SSL so it's the SSL setup that can fail.
tm-exa has quit [Quit: Computer has gone to sleep]
Praetonus has quit [Quit: Leaving]
graaff has joined #ponylang
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
amclain has joined #ponylang
tm-exa has joined #ponylang
michael_campbell has quit [Ping timeout: 250 seconds]
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
juanjoc has joined #ponylang
Matthias247 has joined #ponylang
michael_campbell has joined #ponylang
bb010g has joined #ponylang
juanjoc has quit [Quit: Leaving]
graaff has quit [Quit: Leaving]
tm-exa has quit [Quit: Computer has gone to sleep]
tm-exa has joined #ponylang
tm-exa has quit [Quit: Computer has gone to sleep]
TwoNotes has quit [Quit: Leaving.]
_andre has quit [Quit: leaving]
<jeremyheiler>
is the process lib code available somewhere?
<SeanTAllen>
jeremyheiler: very soon. Markus is putting together documentation in prep for a PR.
<jeremyheiler>
cool
tm-exa has joined #ponylang
<Scramble1ams>
Question from my inner language geek: Why is method overloading not supported in Pony?
<jemc>
Scramble1ams: well, pony doesn't really have inheritance, so what are you picturing?
tm-exa has quit [Quit: Computer has gone to sleep]
pulpfiction has joined #ponylang
bb010g has quit [Quit: Connection closed for inactivity]
TwoNotes has joined #ponylang
<TwoNotes>
The tutorial has two sections on 'aliasing'; one for types and one for objects. I wonder if that could be confusing. But I do not have any suggestions for a different term to use.
<TwoNotes>
"synonym"
TwoNotes has quit [Quit: Leaving.]
trapped has quit [Read error: Connection reset by peer]
pulpfiction has quit [Quit: Leaving]
Praetonus has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]