jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang
_whitelogger has joined #ponylang
PreetamJinka has joined #ponylang
PreetamJinka has quit [Ping timeout: 250 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
Guest85605 has quit [Ping timeout: 260 seconds]
Fuuzetsu has joined #ponylang
Fuuzetsu is now known as Guest26443
aturley has joined #ponylang
aturley has quit [Ping timeout: 260 seconds]
amclain_ has joined #ponylang
amclain has quit [Ping timeout: 276 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 248 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 268 seconds]
jemc has quit [Ping timeout: 276 seconds]
jemc has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
jemc has quit [Ping timeout: 248 seconds]
amclain_ has quit [Quit: Leaving]
copy` has quit [Quit: Connection closed for inactivity]
aturley has joined #ponylang
aturley has quit [Ping timeout: 248 seconds]
tm-exa has joined #ponylang
trapped has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
lispmeister has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 252 seconds]
_andre has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 252 seconds]
TwoNotes has joined #ponylang
<TwoNotes> Many library routines return ref objects. Is there a recommended way to convert these to val so they can be sendable?
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
Praetonus has joined #ponylang
<TwoNotes> For example, JsonDoc.data is a JsonType ref. I need to pass a JsonObject val to a constructor.
<Praetonus> TwoNotes: You can recover to val
<Praetonus> For example, let myval = recover val myobj.myfun(myarg) end
<Praetonus> myobj and myarg must be sendable
<TwoNotes> Not sure how I would create a sendable JsonDoc.
<Praetonus> Looks like the constructor is iso
<TwoNotes> But being iso, I can't create aliases to doc.data
<TwoNotes> I create the JsonDoc, calls its .parse method to give it a JSON string, then I need to pull values out of it
<Praetonus> I think you can do destructive read: let data = doc.data = None
<TwoNotes> I start out with a String val of the original JSON data. I need to end up with val versions of the objects described therein
<Praetonus> Since assignment returns the previous value, I think it works
<TwoNotes> hmm
<TwoNotes> So I have to incrementally dismantle the parsed data as I take valuyes out of it.
<TwoNotes> I am going to therow away the entire JsonDoc at the end of the function... but that doesn't count
<SeanTAllen> New Gitbook hosted Pony Tutorial is up: http://tutorial.ponylang.org
<SeanTAllen> You can get Epub, Mobi and PDF versions at https://www.gitbook.com/book/ponylang/pony-tutorial/details
<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
<doublec> TwoNotes: eg http://pastebin.com/YAbMpWLF
<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.
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
copy` has quit []
<SeanTAllen> praetonus: this is needed for syntax highlighting... https://groups.io/g/pony+dev/thread/volunteer_needed_pony/800005?p=,,,20,0,0,0:RecentPostDate,,,20,2,0,800005
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]