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
kulibali has quit [Quit: Going offline, see ya! (www.adiirc.com)]
<doublec> felko: if the Array[U8] is ref you'll have to copy it
<doublec> felko: if it's an iso you can recover it to a val without copying
<felko> how do I copy it ? clone returns a ref
<doublec> felko: create a new array, and iterate over the old one, pushing items into the new one
<felko> but push requires the array to be ref
<felko> doublec: can we use it on an Array val too ?
<felko> well i could use an iso
<felko> i think
<doublec> felko: in general you can work around the copy by using an iso, or by using things inside recover blocks
<doublec> if the array can be created as a ref inside a recover block, and the population of it done inside of it, then it can be returned from the recover block as a val
<jemc> felko: if you post a relatively complete snippet, we may be able to help you refactor to use a recover block instead
<felko> where can i paste a pony snippet with syntax coloring ?
<felko> sorry if this is chaotic, I just started learning pony yesterday
<doublec> felko: where do you need the val?
<doublec> felko: is it in the memory() function? You want to return a val?
<felko> line 35 when I have to provide a Array[U8] val for env.out.print
<felko> I also put some weird refcaps like String iso! because the compiler seemed to complain about it
<doublec> That set of lines creates an array, prints it and discards it - is that what you want?
<felko> yes
<felko> len = 1 because I haven't found a printChar function for StdStream
<felko> so i'm just building a 1-character string
<doublec> felko: let str: Array[U8] val = recover Array[U8].init(5 where len = 1) end
<felko> thanks
<felko> sorry all of those refcaps things are really new to me
<doublec> felko: env.out.print(current().string())
<doublec> felko: no worries, you're doing well
<felko> thanks
<doublec> felko: most types have a .string() that let you convert to something printable
<felko> ok, i'll remember that, thanks again
<doublec> 'recover' is a bit like a safe pointer cast. It can convert anything from inside the recover block to another reference capability when it is returned outside of it
mrkishi_ has joined #ponylang
<doublec> It does it safely because the recover block is special in that it restricts what can be put inside it and it knows than nothing can be retained that is created inside it.
<doublec> as a high level introduction to it
<doublec> So in that recover block we create an array ref but it is returned as an array val. This is safe because the ref cannot be stored anywhere else as it can't escape the recover block.
<felko> my experience with pointers is pretty limited, but i think i get the idea
<doublec> You can go a long way in solving problems by using recover somewhere, or consume something else, to fix compiler errors :)
mrkishi has quit [Ping timeout: 250 seconds]
<felko> ive been doing this for hours now, fixing error by error
<felko> not the best way to learn a language I guess :/
<felko> im starting to understand a little more now, thanks to you
<doublec> felko: I have some posts here which explain some of it https://bluishcoder.co.nz/tags/pony/
<felko> wow thanks a lot
<doublec> in particular the "bang, hat and arrow" one and the "borrowing in pony" one for dealing with and understanding errors
<felko> last question before i go to bed, is there a way to debug, like, with print, but without having access to the env variable ?
<felko> i know this is an issue for safety but even haskell does an exception for this
<doublec> felko: yes, there's a debug print facility
<felko> thanks
* doublec looks for details
<doublec> felko: do a: use "debug"
<doublec> felko: then you can access Debug.out.print, etc
<felko> found it, thanks
<doublec> felko: another common approach is to use the C ffi to access printf
<doublec> felko: so: @printf[None]("I am here: ", mystring.cstring())
<doublec> felko: actually that's: @printf[None]("I am here: %s".cstring(), mysetring.cstring())
<doublec> it requires converting types though so is a bit more technical
<doublec> I have to head out - good luck!
<felko> thanks a lot, bye :)
felko has quit []
mrkishi_ has quit [Remote host closed the connection]
jemc has quit [Ping timeout: 246 seconds]
_whitelogger has joined #ponylang
jemc has joined #ponylang
TwoNotes has quit [Quit: Leaving.]
jemc has quit [Ping timeout: 252 seconds]
graaff has joined #ponylang
Praetonus has joined #ponylang
jemc has joined #ponylang
graaff has quit [Quit: Leaving]
jemc has quit [Ping timeout: 250 seconds]
zevlg` has joined #ponylang
zevlg has quit [Write error: Broken pipe]
jemc has joined #ponylang
TwoNotes has joined #ponylang
<TwoNotes> Is there a convenient way to invert the "is" test? Like 'if a is not None then...'
<jemc> TwoNotes: `if not (a is None) then...`
ChubbyBreakfast1 has joined #ponylang
ChubbyBreakfast1 has left #ponylang [#ponylang]
<Praetonus> TwoNotes: IIRC, there is an `isnt` operator
<Praetonus> Just checked, it does exist
<Praetonus> So you can do `if a isnt None then...`
<TwoNotes> ok, great tnx