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 | Please consider participating in our mailing lists => https://pony.groups.io/g/pony
campbellr has quit [Remote host closed the connection]
bb010g has quit [Read error: Connection reset by peer]
dtz has quit [Remote host closed the connection]
bb010g has joined #ponylang
dtz has joined #ponylang
_whitelogger has joined #ponylang
<jdhorwitz> Last Week in Pony - November 25, 2018 - https://www.ponylang.io/blog/2018/11/last-week-in-pony---november-25-2018/
acarrico has quit [Ping timeout: 240 seconds]
endformationage has quit [Quit: WeeChat 2.3]
mahmudov has joined #ponylang
jemc has joined #ponylang
jemc has quit [Ping timeout: 268 seconds]
zeeshanlakhani_ has joined #ponylang
jdhorwitz has quit [*.net *.split]
zeeshanlakhani has quit [*.net *.split]
zeeshanlakhani_ is now known as zeeshanlakhani
acarrico has joined #ponylang
acarrico has quit [Ping timeout: 252 seconds]
acarrico has joined #ponylang
aturley has joined #ponylang
jemc has joined #ponylang
endformationage has joined #ponylang
mahmudov has quit [Remote host closed the connection]
jemc has quit [Ping timeout: 252 seconds]
<_andre> hello
<_andre> so, in this code: https://pastebin.com/BdUvVRCZ
<_andre> why does the array append() works in a trn variable in the first method, but not in the second (requiring the extra 'consume ref' shown in the third one)?
<SeanTAllen> im not sure why the "consume ref" compiles
<SeanTAllen> That said
<SeanTAllen> _andre:
<SeanTAllen> what are you trying to accomplish?
<SeanTAllen> your ref types don't make a lot of sense, so i think starting over from what you are trying to accomplish would make sense
<_andre> i have this map of array values which i need to populate, and i want to have methods that return array vals
<_andre> which is why i went with 'trn'
<SeanTAllen> so you have a map that is String for key and an array of Strings as the value correct?
<SeanTAllen> when you say "i need to populate", do you mean, "i need to be able to mutate the arrays of strings"
<_andre> yes. foo3() is like a "save" method, so if the key isn't present, i initialize it with the empty array using insert_if_absent, then append a given value (in the real program the "bar" string would be a parameter)
<SeanTAllen> ok so, trn isnt for that.
<SeanTAllen> trn is "i want a thing that is temporarily mutatable but i can make it not mutable by giving up my reference to it"
<SeanTAllen> let me make sure i understand a bit more...
<SeanTAllen> you have an array of strings that is mutable and you want an immutable copy so you can send it to another actor?
<SeanTAllen> btw, here is a link to a pony playground for the code you provided: https://playground.ponylang.io/?gist=3400706a979b6ce9e739ba52743e8555
<SeanTAllen> playgrounds can be nice because others can often run the code and see the error you get (with less work than copying a pastebin somewhere and running)
<_andre> yes, i'm trying to make it work as an in-memory key-value store
<_andre> where a key can hold multiple values
<_andre> i'd like the read function to return the array corresponding to the given key, but as a val
<SeanTAllen> I take it you are thinking that trn would create a copy when you get a val from it, yes?
<_andre> i thought it would, yes
<SeanTAllen> yeah it doesnt do that
<SeanTAllen> so what you want is a `ref` array
<_andre> so i have to make the copy manually?
<SeanTAllen> and then you make a copy when you want to send a copy elsewhere
<SeanTAllen> yes
<SeanTAllen> you could use either iso or trn to make the copy mutable while builing it then you'd consume that so that it would be a `val` when sending
<SeanTAllen> the strings in the array are immutable yes?
<_andre> yes
<SeanTAllen> right, so then its a loop and copy. that is pretty straight forward.
<SeanTAllen> 1. create an iso array of String
<SeanTAllen> 2. loop over your ref array
<SeanTAllen> 3. add each element from ref array to the iso array
<SeanTAllen> 4. consume iso array and return as val
<SeanTAllen> you can't use Array.clone because right now, there's no way to get back something other than a ref when you clone a ref from it
<_andre> i guess copy_to() doesn't fit either
<SeanTAllen> you can see the clone issue with this playground: https://playground.ponylang.io/?gist=d0a2a348a2e2a2f838f0d0e47ec64b56
<_andre> i think a clone_as_val() function would be useful in the stdlib :)
<SeanTAllen> as iso would be more useful, if its iso it can become anything
<SeanTAllen> including val
<SeanTAllen> do you feel like you have enough info to make progress _andre ?
<_andre> yes, thanks!
<SeanTAllen> awesome
<_andre> btw, in my attempts to understand capabilities, i generated a lot of nonsense code, including something that triggered an assertion failure in ponyc
<_andre> should i report this on github?
<_andre> i managed to create something small that reproduces it
<SeanTAllen> yes
<SeanTAllen> please do report
<SeanTAllen> thanks
jemc has joined #ponylang
jemc has quit [Quit: WeeChat 2.2]
endformationage has quit [Quit: WeeChat 2.3]