<< 07-12-2015 >>

00:00:12girvoso I assume they'll live on the stack
00:00:15dom96yeah
00:00:20girvobeautiful
00:00:35dom96:D
00:00:53girvocryzed: I'm ostensibly creating a "game engine", but to be honest I'm more trying to work out what a completely safe Nim wrapper over SDL2 would look like
00:01:08girvothanks dom96 :D
00:01:09cryzedSounds really interesting :)!
00:01:27*zepolen joined #nim
00:01:35girvoIt's something I've wanted to see for ages, and I've had a fair bit of free time for once in my life so I figured it was worth taking a shot at it
00:01:42girvoSo far it's going pretty well!
00:01:51*jaco60 quit (Ping timeout: 260 seconds)
00:02:08girvoThough I keep having this need to implement ref counting for the c-allocated vars hahaha, but that's probably me just being a masochist
00:02:11*pregressive joined #nim
00:04:09girvoOh! I also quickly ported a set of disgusting bash scripts into a docopt-based Nim CLI, for managing local Docker containers for web development; think docker-compose with actual persistance for your database
00:04:40cryzedgrr, now I want to finish my shitty markdown parser :D
00:04:55girvoThe Nim code is gross though because I had 30 minutes to do it and my Nim was rusty as hell, heh: https://github.com/girvo/dup
00:05:08girvoLooking forward to refactoring it to be beautiful inside and out ;)
00:05:32girvoOh, and properly safe; currently it's just doing cmdEx with built strings hahaha
00:05:41cryzedgirvo, please do. If you feel like sharing, please also let us (me) know about how you are progressing with your game engine :)
00:06:02*zepolen quit (Ping timeout: 260 seconds)
00:06:03girvocryzed: I will~ ... mainly cause i'll be in here bugging everyone with weird questions :D
00:06:17cryzedoh, we have our fair share of that, mostly from me recently
00:06:18cryzedso don't worry
00:06:59*Learath2 quit (Ping timeout: 260 seconds)
00:07:26girvohahaha
00:07:47girvoAlso, the lead dev at work has finally stopped being a negative nancy and took a look at Nim... and loves it lol
00:08:01*Learath2 joined #nim
00:08:41cryzed:D
00:09:33girvohey dom96: are there any projects around that show C mem management done well that I can take a look at?
00:09:41girvoIn nim, I mean
00:09:53dom96hmmm
00:10:11Araqgirvo: no, but the best way to do it is this way
00:10:12girvoIf not, all good :) I'm interested in what a safe wrapper looks like in nim
00:10:19girvoOh hi Araq :D
00:10:29dom96Nothing jumps to mind
00:10:36Araqvoid initT(Foo* foo); // let host language do the allocation
00:11:06girvoAraq: That's what I've been doing, made sense to me, nice
00:11:09Araqlet x = newFoo() # can use Nim's GC here :-)
00:11:16AraqinitT(x) # pass to C
00:11:17girvoYay :D
00:11:41girvoI've been keeping everything in Nim's GC for as long as possible, only converting to C types right at the end
00:12:05Araqmost C libraries do this though Foo* newFoo(); and then you need to deal with C's manual memory mangement in some way or the other
00:12:18girvoAraq: Best way of profiling to check for leakages? I guess I'll just run it through valgrind
00:12:23girvoYeah that's what I've seen
00:12:29girvoHence why I thoguht I'd ask
00:12:52girvoGetting rid of a lot of the destroy() calls littering the app code would be nice, at least if it means moving them to one place
00:12:54Araqactually valgrind is quite pointless, just check getOccupiedMem()
00:13:25Araqthat it stays rather constant keeping in mind taht the cycle collector only kicks in after 4 MB
00:13:30girvoOh yeah, fair
00:13:32girvoNice
00:13:42Araqthat's what our tests do
00:14:02Araqand from time to time we ensure getOccupiedmem agrees with what the OS reports
00:14:11girvoAwesome
00:14:17girvoI'll add it into my debug macros :)
00:14:23*pilne quit (Read error: Connection reset by peer)
00:14:48*pilne joined #nim
00:16:09girvoIs it worth my writing up some documentation on this stuff at all? Maybe even just some larger examples for the "Nim for C Programmers" wiki page
00:16:57girvoWork's giving me some hours a over the next two weeks to contribute some stuff back to OSS
00:17:20cryzedgirvo, even I can say to that: definitely
00:17:36cryzedMore documentation is always appreciated, I am positive
00:17:57girvo:)
00:17:58Araqwell it's a wiki, free for anybody to enhance
00:18:23girvoIt's already pretty well done, might just link some larger stuff based on the questions I've run into
00:18:32girvoWas extremely helpful recently
00:20:47girvoHow safe is the existing SDL wrapper?
00:22:03Araqjust merged a PR to the SDL2 wrapper
00:23:06Araqand I use it myself fwiw
00:23:23girvoAwesome :D
00:23:52Araqsomebody needs to port graphics.nim to use SDL2 *wink*
00:24:10girvoHah! Funny you say that, sdl2/graphics was next on my list ;)
00:28:40*Trustable quit (Remote host closed the connection)
00:33:07*lokulin quit (Ping timeout: 260 seconds)
00:39:47*lokulin joined #nim
00:45:38*nicktick joined #nim
00:47:16*pregressive quit (Remote host closed the connection)
00:52:41*pregressive joined #nim
00:58:59*lazypenguin quit (Ping timeout: 264 seconds)
01:01:46*theduke quit (Remote host closed the connection)
01:07:16girvoWith Nim macros, is it possible to see if a given NimNode has a given method available?
01:07:48girvoIt turned out to not really be needed in my case as the standard Nim typechecker was smart enough to realise what was going on, but I'm curious as to whether its possible
01:11:55Araqit's complex.
01:12:11Araqyou can generate a 'when compiles' check for example
01:12:31Araqin general macros should not be exposed the symbol table
01:12:48Araqto keep the design resonably sound.
01:17:17*lazypenguin joined #nim
01:20:59*thotypous quit (Ping timeout: 245 seconds)
01:23:16*thotypous joined #nim
02:14:41*[CBR]Unspoken quit (Ping timeout: 246 seconds)
02:16:14girvoYeah makes sense Araq
02:29:40*[CBR]Unspoken joined #nim
02:31:21*strcmp1 quit (Quit: return 0;)
02:35:29*strcmp1 joined #nim
02:36:49*sepisoad2 quit (Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org)
03:01:36*zepolen joined #nim
03:05:59*zepolen quit (Ping timeout: 245 seconds)
03:17:27*porchswing joined #nim
03:52:40*pilne quit (Quit: Quit!)
04:11:03*nicktick quit (Ping timeout: 260 seconds)
04:14:55*desophos quit (Quit: Leaving)
04:15:15*desophos joined #nim
04:24:23*pregressive quit (Remote host closed the connection)
04:26:10*porchswing quit (Quit: Leaving)
04:26:31*porchswing joined #nim
04:26:58*porchswing quit (Client Quit)
04:27:07*porchswing joined #nim
04:37:33*pregressive joined #nim
04:57:21*porchswing quit (Quit: Leaving)
04:59:01*zepolen joined #nim
05:21:36*darkf joined #nim
05:35:59*BitPuffin|osx quit (Ping timeout: 260 seconds)
05:51:45*pregressive quit (Remote host closed the connection)
05:53:16*pregressive joined #nim
06:11:04*SeVenSiXseVeN joined #nim
06:33:00*pregressive quit (Remote host closed the connection)
06:35:16*pregressive joined #nim
06:53:30*bjz joined #nim
06:53:48*desophos quit (Read error: Connection reset by peer)
06:54:51*pregressive quit (Remote host closed the connection)
06:57:22*bjz quit (Max SendQ exceeded)
06:58:04*bjz joined #nim
06:59:25*zepolen quit (Remote host closed the connection)
06:59:52*gokr quit (Quit: Leaving.)
07:08:12*sepisoad joined #nim
07:08:22*bjz quit (Ping timeout: 260 seconds)
07:12:04*girvo quit (Ping timeout: 250 seconds)
07:17:18*zepolen joined #nim
07:19:53*cyraxjoe_ joined #nim
07:20:14*cyraxjoe quit (Ping timeout: 246 seconds)
07:24:22*bjz joined #nim
07:27:33*exebook joined #nim
07:42:29*zepolen quit (Remote host closed the connection)
07:48:31sepisoadi tried to upgrade to latest nim compiler (0.12) on my raspberry Pi(arch linux)...
07:49:25sepisoadbut the latest available version is 0.11, so i decided to get it from github
07:50:10sepisoadwhen i compile nim compiler the version number is 0.10
07:50:59sepisoadhow come?
08:08:43*girvo joined #nim
08:13:15*girvo quit (Ping timeout: 260 seconds)
08:15:00*sepisoad quit (Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org)
08:15:21*sepisoad joined #nim
08:17:07*yglukhov joined #nim
08:18:39*sepisoad quit (Read error: Connection reset by peer)
08:23:25*gokr joined #nim
08:25:50*bjz_ joined #nim
08:26:44*bjz quit (Ping timeout: 246 seconds)
08:28:07*zepolen joined #nim
08:33:18*zepolen quit (Ping timeout: 260 seconds)
08:34:42*lazypenguin quit (Ping timeout: 260 seconds)
08:49:55*Ven joined #nim
08:50:29*lazypenguin joined #nim
08:55:27*pregressive joined #nim
08:55:40*Trustable joined #nim
08:56:35*sepisoad joined #nim
08:59:59*pregressive quit (Ping timeout: 246 seconds)
09:00:21reactormonksepisoad, wrong branch?
09:03:39*Demon_Fox quit (Ping timeout: 260 seconds)
09:06:34sepisoadreactormonk, but i follow the instructions on the github page
09:07:02reactormonksepisoad, link?
09:07:24reactormonksepisoad, master branch?
09:10:07*coffeepot joined #nim
09:10:17*nastavnic joined #nim
09:11:42sepisoadreactormonk, git clone git://github.com/nim-lang/Nim.git
09:12:33sepisoaddevel branch i guess
09:14:16reactormonksepisoad, should be devel, yup.
09:15:34sepisoad:-(
09:19:37*Trustable quit (Remote host closed the connection)
09:20:47*Trustable joined #nim
09:23:09*jaco60 joined #nim
09:24:38*makoLine quit (Ping timeout: 260 seconds)
09:37:22*zepolen joined #nim
09:40:29*sepisoad quit (Read error: Connection reset by peer)
09:45:17*coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
09:47:40*coffeepot joined #nim
10:09:44*girvo joined #nim
10:14:34*girvo quit (Ping timeout: 260 seconds)
10:14:42*cyraxjoe joined #nim
10:15:30*cyraxjoe_ quit (Ping timeout: 260 seconds)
10:17:55*sepisoad joined #nim
10:20:44*sepisoad quit (Read error: Connection reset by peer)
10:57:48*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
11:13:20*nastavnic quit (Ping timeout: 246 seconds)
11:20:30*Gonzih joined #nim
11:21:21*Gonzih quit (Client Quit)
11:21:40*Gonzih joined #nim
11:22:04*Gonzih quit (Client Quit)
11:22:50*Gonzih joined #nim
11:23:22*Gonzih quit (Client Quit)
11:24:46*gokr quit (Quit: Leaving.)
11:25:18*gokr joined #nim
11:27:29*Gonzih joined #nim
11:27:56*nastavnic joined #nim
11:31:19*sepisoad joined #nim
11:33:52*sepis0ad joined #nim
11:33:53*sepisoad quit (Read error: Connection reset by peer)
11:42:29*Arrrr joined #nim
11:44:33ArrrrHow can sleep give me these results? http://pastebin.com/w4Jw7F77
11:44:40ArrrrIt must be bugged or something
11:45:17ArrrrI sleep in a loop for 1 ms and running stat tells me the max value pushed is '0.016' wut
11:50:38*Gonzih quit (Quit: WeeChat 1.3)
11:56:01*irrequietus joined #nim
11:59:06*sepis0ad quit (Ping timeout: 260 seconds)
12:05:11*irrequietus quit (Ping timeout: 260 seconds)
12:05:41*irrequietus joined #nim
12:10:29*girvo joined #nim
12:14:44*girvo quit (Ping timeout: 245 seconds)
12:22:25*lokulin quit (Changing host)
12:22:25*lokulin joined #nim
12:30:39def-Arrrr: cpuTime does not measure real time
12:31:28def-"gets time spent that the CPU spent to run the current process in seconds" - so the CPU doesn't have to do a lot of work when your process is sleeping
12:31:43def-epochTime is probably what you want
12:44:18Arrrrbut im actually measuring the time it takes to sleep
12:44:53ArrrrI get sleep is not precise, but if i say "sleep for 1ms" how does it take up to 16ms ?
12:45:14ArrrrIt cannot be the gc
12:47:25*Ven joined #nim
12:51:09*filcuc joined #nim
12:53:13*pregressive joined #nim
12:56:56*gokr quit (Quit: Leaving.)
12:57:01*gokr1 joined #nim
13:08:32*pregressive quit (Remote host closed the connection)
13:08:53*xet7 joined #nim
13:11:48coffeepotI think sleep only guarantees waiting for at least the parameter time, but doesn't guarantee it won't wait longer
13:21:20*irrequietus quit ()
13:27:27ArrrrIt must be that
13:28:26*zepolen quit (Remote host closed the connection)
13:57:21*irrequietus joined #nim
14:00:38*ozra joined #nim
14:10:05*Jehan_ joined #nim
14:11:01Jehan_Arrrr: sleep can take longer than the minimum amount of time due to scheduling or other activity in the system. http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html
14:11:14*girvo joined #nim
14:11:20Jehan_System timers often don't have granularity that low.
14:13:26*BitPuffin joined #nim
14:15:50*girvo quit (Ping timeout: 260 seconds)
14:26:09*gokr1 quit (Quit: Leaving.)
14:30:14*irrequietus quit ()
14:37:51Arrrrmmm i see
14:45:03*filcuc quit (Quit: Konversation terminated!)
14:45:30*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
14:49:00*pregressive joined #nim
14:50:33*SeVenSiXseVeN quit (Quit: Leaving)
14:53:44*nicktick joined #nim
15:10:59*nastavnic quit (Ping timeout: 246 seconds)
15:11:15coffeepotif you've got an array[0..100, byte] as a buffer, what's the most convenient way to get a string out from the first, say 10 bytes?
15:11:58*nastavnic joined #nim
15:12:08coffeepotI was hoping for a toString or something, rather than have to do it manually
15:14:12*saml joined #nim
15:15:46def-coffeepot: var s = newString(10); copyMem(addr s[0], addr source[0], 10)
15:16:18coffeepotNice one def- :)
15:18:26*Sornaensis quit (Excess Flood)
15:18:50*Sornaensis joined #nim
15:22:18*pregressive quit (Remote host closed the connection)
15:27:17*Ven joined #nim
15:29:40*Jehan_ quit (Quit: Leaving)
15:39:54*nicktick quit (Quit: Leaving.)
15:40:09*joelmo joined #nim
15:40:25*nicktick joined #nim
15:43:01cryzedI'm going to make people angry again: https://gist.github.com/cryzed/3a11d40be667d2444b7a so scenario A can never work?
15:43:15cryzedUsing ref types for attributes in type definitions doesn't make sense?
15:49:51cryzedAll actions that modify a referenced object will automatically copy the object, and simply change the pointer to point to the new object?
15:55:30*vqrs quit (Max SendQ exceeded)
15:56:46*vqrs joined #nim
15:59:52coffeepotuh thats... unexpected
16:00:00coffeepotfor me anyway XD
16:03:19*nicktick1 joined #nim
16:03:49coffeepotif that's right altering the contents of a ref would invalidate a stored ref wouldn't it? But that doesn't happen AFAIK - refs are fine to reference
16:05:52cryzedcoffeepot, you cant store redfs
16:05:54cryzedrefs
16:06:24*nicktick quit (Ping timeout: 256 seconds)
16:07:22coffeepotI'm sure I've stored plenty of refs and modified them without issue though *confused*
16:07:47coffeepotis this something to do with the fact it's inherited?
16:08:02coffeepotdoesn't look like it
16:08:07cryzedthere's no inheritance
16:08:11*nicktick1 quit (Ping timeout: 250 seconds)
16:08:13cryzedin my example?
16:08:22cryzedjust 2 different classes
16:08:24cryzedNode and RefNode
16:08:26cryzedor well types
16:09:01coffeepotyeah sorry i thought it was but no inheritance
16:09:06coffeepotodd
16:09:18cryzedIt's what threw me off yesterday, and still does to be honest
16:09:35*nastavni1 joined #nim
16:09:36coffeepotwell me too tbh
16:09:48cryzedI was told, if I didnt misunderstand, that its not possible to actually store references
16:09:48coffeepotI wonder if this is something to do with what repr displays
16:09:59cryzedrepr displays the memory adresses and contents etc.
16:10:00coffeepothuh?!
16:10:03cryzedPretty sure that is correct
16:10:28*OurRoyalGabe joined #nim
16:10:31cryzedI would have to ask Ara-q again, but I don't want to ping him. I annoyed him plenty yesterday
16:10:33cryzedmaybe dom96
16:10:40*OurRoyalGabe left #nim (#nim)
16:11:02cryzedcoffeepot, do you know of a way to initialize the children attribute of refnode?
16:11:16cryzedsince I can't figure it out
16:11:58*girvo joined #nim
16:12:17cryzedWelcome back girvo :)
16:12:30*nastavnic quit (Ping timeout: 272 seconds)
16:12:35coffeepothmm well if it were a seq it'd just be myRefNode.children = @[] ... maybe myRefNode.children = newSeq[seq[string]]() or something?
16:12:51coffeepotno that doesn't look right XD
16:13:25coffeepotnew newSeq[string]() ?
16:13:36coffeepota seq is a ref anyway btw
16:13:45coffeepotAFAIK
16:14:34cryzedb:ref 00568048 --> [children = 00568058[]]
16:14:35cryzed doesnt look like it
16:15:02*nastavni1 quit (Ping timeout: 272 seconds)
16:16:56*girvo quit (Ping timeout: 272 seconds)
16:18:14coffeepotI hope someone can tell you why, will be keeping an eye on chat :)
16:19:19cryzedyeah me too
16:21:19*Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
16:22:03Arrrrwhat's the matter
16:22:37coffeepotArrrr see cryzed code snippet above
16:22:38dom96hello guys
16:22:44coffeepothello :)
16:22:46cryzedhello dom96!
16:22:53cryzedI still can't leave it alone after all
16:23:00cryzedI need to fully understand how nim's memory management works
16:23:09cryzedI know I'm making enemies at this point
16:23:25cryzedCode sample: https://gist.github.com/cryzed/3a11d40be667d2444b7a
16:23:36cryzed<cryzed> Using ref types for attributes in type definitions doesn't make sense?
16:23:36cryzed<cryzed> All actions that modify a referenced object will automatically copy the object, and simply change the pointer to point to the new object?
16:24:15coffeepotcryzed I don't think you are making enemies for asking questions :)
16:24:29cryzedeh, let's hope -- I can be persistent
16:25:01cryzeda:ref 00598028 --> [children = nil]
16:25:01cryzeda:ref 00598028 --> [children = ref 00598038 --> nil]
16:25:01cryzedb:ref 00598048 --> [children = 00598058[]]
16:25:01cryzedb:ref 00598048 --> [children = 0059c368[0059c3c8"Hello World"]]
16:25:05cryzeda full sample output of the script
16:25:23coffeepotcryzed are you on devel?
16:25:26cryzedI am
16:25:43cryzed> git hash: 6f09282352341d750332592fa06988102992a276
16:26:18ArrrrThe issue is that repr is displaying a different dir when you add a new string?
16:26:20*nicktick joined #nim
16:26:39dom96cryzed: I get consistent memory addresses
16:26:45dom96I commented on your gist with my output
16:27:20cryzeddom96, your children address changed
16:27:25cryzedin b
16:27:38cryzed24050 and 2c050
16:28:00cryzedArrrr, address
16:28:20Arrrrhttp://ideone.com/6F2wkR
16:29:02cryzedSo when limiting it to a single element it works?
16:29:08ArrrrSeq is very strange, it is implemented at the compiler lever, it doesn't work like a value type or a ref type
16:29:31dom96What I think happens is that the seq grows so it must reallocated
16:29:32ArrrrIt has a lot of implementations details to make it perform better
16:29:45cryzedArrrr, dom96 can either of you then tell me how to initialize a properly in my example?
16:29:45coffeepotdom96 that makes sense
16:29:56cryzedspecifically a.children?
16:30:01ArrrrInitialized it with @[]
16:30:05dom96what Arrrr did was explicitly specify how big the seq should be allocated.
16:30:07Arrrr*initialize
16:30:08cryzedthat doesn't work
16:30:14Arrrrwhy not
16:30:18cryzedit expects a ref seq[string] not a seq[string]
16:30:30cryzedThe docs say that new(a.children) should
16:30:32cryzedoops
16:30:32coffeepotit doesn't make sense that the 'container' ref should change if a ref within it does thou
16:30:34dom96Stop using 'ref seq[string]'
16:30:34cryzedsandbox.nim(11, 29) Error: type mismatch: got (seq[empty]) but expected 'ref seq[string]'
16:30:35ArrrrYesterday i gave you a snippet that does that
16:30:39dom96just use 'seq[string]'
16:30:54cryzedSo using ref in attributes doesn't make sense at all?
16:30:54ArrrrAnd if i were you, i would do what dom says
16:31:07dom96it doesn't make sense on a seq
16:31:18dom96because it is already a reference type
16:31:22coffeepotcryzed using ref should work in attributes but seq is effectively a ref anyway
16:31:34cryzedI see, alright.
16:31:46dom96Writing 'ref int' also doesn't make much sense
16:31:47ArrrrThere is a point on ussing a ref, if you want to reuse it instead of making a copy
16:32:05coffeepotref int does make sense if you want to pass around a pointer to an int tho
16:32:13dom96btw, have you guys seen this? http://adventofcode.com/
16:32:22dom96Looks like a good way to practice/learn Nim :)
16:32:32cryzeddom96, one last question then. Is new even needed, isn't new implicitly called when doing MyType()?
16:32:37dom96(And other programming languages too)
16:33:20coffeepotcool link dom96 :)
16:33:26dom96cryzed: Indeed, new is implicitly called when you call MyType()
16:33:32dom96i.e. the type constructor
16:33:52cryzedOkay, since I see new being used in some code and I never get why, when the type cosntructor could just have been used
16:34:09dom96The type constructor is a relatively new addition to Nim :)
16:34:14coffeepotso have we confirmed that when having ref object with a ref inside it, if you add to the child ref it does not change the parent ref address?
16:34:25dom96Also, in some cases you may not want to specify each attribute.
16:34:53ArrrrIt doesn't coffe, it is only how seq works
16:35:00ArrrrWe have talked about it many times
16:35:11ArrrrThe shallowcopy thing
16:35:38cryzed<cryzed> coffeepot, if it's a seq it apparently might be moved around in memory -- so the address might change, but it points to the same data exactly
16:35:39cryzedsorry got disconnected
16:35:41coffeepotgood good, I thought that was a bit weird and surely would make refs unusable if it were true - you'd pass one over and it's address would be changed? That'd be mad
16:36:17ArrrrWell, seqs and strings
16:36:29coffeepotcryzed yeah this makes sense for seq as they're just dynamic arrays and need to be resized. It would be upsetting if it happened to a seq's container though
16:37:05coffeepotwhich is what your code snippet seemed to show
16:37:08cryzedcoffeepot, ah not -- the reference to the seq itself -- relative to the object instance never changed
16:38:01cryzeddom96, so what problem did I have yesterday. I used a custom accessor proc to get the correct field, but it ended up returning a copy of that seq field instead of a reference to it
16:38:07dom96https://gist.github.com/dom96/eb7ed68cbca07175bafc
16:38:49cryzedah neat
16:39:13coffeepotgreat :) So what happened in cryzed's snippet for the container ref to change?
16:39:39cryzedcoffeepot, http://i.imgur.com/7bu7P0C.png
16:39:44cryzedthe ref didnt change to the container
16:39:54cryzedit stayed constant for a and b
16:40:42coffeepotthat's ok then, sanity restored :)
16:41:38cryzedIt is. So now I am trying to recreate my actual problem from yesterday in a small code sample
16:41:51cryzed(told you, I'd make enemies :P)
16:43:32*pregressive joined #nim
16:50:21*nicktick quit (Quit: Leaving.)
16:53:49cryzedcoffeepot, https://gist.github.com/cryzed/5acdc21d1560b8a99d62
16:53:53cryzedthis is what threw me off yesterday
16:54:18cryzeddom96, I understood correctly regarding this: https://gist.github.com/cryzed/5acdc21d1560b8a99d62 -- that there's absolutely no way without using ptr or templates to do what I am trying to do? Sorry if I'm annoying you
16:55:36dom96cryzed: I'm always happy to help :)
16:55:46cryzedglad to hear that :)
16:55:59cryzedThe comments explain my thinking hopefully exactly
16:56:05cryzedfrom Python I'm used to just work with references
16:56:10cryzedso this still throws me off a bit
16:56:33cryzedbut yes, the docs say "the assignment operator copies the value"
16:56:40cryzedor something like that, I remember reading that
16:56:57cryzedI just don't understand what difference it makes to specify "var" in the children return type or not
16:58:06coffeepotspecifying a var return type means you're returning a mutable value
16:58:54coffeepotie; var returns the actual "pointer" to the item so it can be edited
16:59:03NimBotnim-lang/Nim devel f3d5782 xiongxin [+0 ±1 -0]: 7 div 5 == 1... 2 more lines
16:59:03NimBotnim-lang/Nim devel ca47256 Dennis Felsing [+0 ±1 -0]: Merge pull request #3627 from xiongxin/devel... 2 more lines
16:59:31coffeepototherwise you'd get a copy
16:59:54cryzedcoffeepot, well that doesn't work in the example
17:00:14cryzedcoffeepot, I am attempting to return the correct field -- or a pointer/reference to it
17:00:23cryzedbut I get a copy -- or well maybe I don't
17:00:36cryzedI assign it to a variable in between so I don't have to execute the proc twice to do something like this
17:00:46cryzednode.children.delete(node.children.high)
17:00:52cryzed -- this would execute my custom children proc twice
17:00:57cryzedI can't do
17:01:11cryzedvar childrenRef = node.children
17:01:16cryzedchildrenRef.delete(childrenRef.high)
17:01:27cryzedbecause as soon as the assignment happens the value gets copied, even if it's a var return type
17:02:22dom96let me see if I can come up with something
17:02:48cryzeddom96, alright -- thank you
17:03:09cryzedhttps://gist.github.com/cryzed/cc42a92ab57a8c140a5c for reference this works
17:03:14cryzedand probably really has negligible overhead
17:03:16cryzedI'm just being silly
17:03:40cryzedI'm just used being able to store references, and I don't get why I can't. It has to do with memory-safety Ara-q said, but how does it affect memory safety?
17:04:26coffeepotyou definitely can store references, he must have been talking about something specific
17:04:37cryzedcoffeepot, check the example
17:04:38cryzedexecute it
17:04:53cryzedthe var referenceToChildren is a _copy_ after the assignment
17:04:59cryzedit does not point to the original object's field
17:05:10cryzedyou can modify it, but the object itself does not get modified -- or rather its children attribute
17:05:25coffeepotyeah it's unexpected
17:05:41cryzedcoffeepot, https://gist.github.com/cryzed/cc42a92ab57a8c140a5c with adjusted output
17:06:02coffeepotunfortunately I must exit stage left for it is the time of going home!
17:06:10coffeepotgood luck, hopefully there's an easy solution :)
17:06:16cryzedcoffeepot, see you!
17:06:19coffeepotsee ya!
17:06:23cryzedI almost wish Nim could be changed for this to work haha
17:06:24*coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
17:06:36cryzedbut there's probably a good reason for it
17:08:49cryzeddom96, if I understood the reasoning behind it I would probably stop nitpicking at this. Do you understand/know/can explain to me, why the assignment operator always automatically creates a copy -- even of mutably returned data structures from procs (i.e. marked as var)?
17:09:27dom96I'm afraid I don't
17:09:33dom96All I can do is guess
17:10:29cryzeddom96, please share your guesses
17:13:29*yglukhov quit (Ping timeout: 246 seconds)
17:23:12cryzedI'm almost tempted to create an issue with this snippet on the nim repo: https://gist.github.com/cryzed/cc42a92ab57a8c140a5c
17:28:05cryzeddom96, would this be a terribly bad idea? I feel many people will run into this issue at some point
17:28:38cryzeddom96, the docs say "assignment operator will copy the value" -- but since var should just return a _reference_ -- only the reference should be copied, not the value pointed to by the reference
17:36:40dom96sorry, got distracted by this weird automated phone call I got.
17:37:45ldleworkSir, we have detected that you have a virus on your windows desktop.
17:37:50ldleworkAre you the administrator of this computer?
17:38:03ldleworkSir, I ask you, are you the administrator of this computer?
17:40:04cryzeddom96, :D no prob. Regarding my question?
17:40:22cryzeddon't you think it should work that way too?
17:41:00dom96I'm not sure
17:42:20dom96That being said, this works: https://gist.github.com/dom96/1984a7a196dddd658c2f
17:44:30cryzedthat looks good, and basically what I had attempted yesterday. I still feel that when returning a result of a proc marked as var, it shouldnt just copy the returned datastructure during assignment
17:44:33cryzedwhy even return it as var then
17:44:38cryzedin that case at least
17:44:56*pregressive quit (Remote host closed the connection)
17:45:12*pregressive joined #nim
17:45:15dom96If you feel that way then by all means create an issue
17:46:29cryzeddom96, you don't?
17:47:25cryzeddom96, also is it possible to do what your newNode proc does in a single line with the type constructor? I am wondering how to combine the new(result.internalChildren), result.internalChildren[] = @[] step
17:47:51dom96cryzed: I would need to think about it more ;)
17:48:03cryzedAlright, I'll at least create an issue with the code snippet then
17:48:09dom96I don't think you can combine those
17:49:27*pregressive quit (Remote host closed the connection)
17:49:48cryzeddom96, ah I see
17:59:34*vendethiel joined #nim
18:00:02*aziz joined #nim
18:01:46cryzeddom96, https://github.com/nim-lang/Nim/issues/3628
18:02:13*yglukhov joined #nim
18:06:26*yglukhov quit (Ping timeout: 240 seconds)
18:09:36cryzeddom96, https://github.com/nim-lang/Nim/issues/3629 I wonder how ling it will take before Ara-q kills me :D
18:11:37dom96cryzed: Depends how far away from him you live :P
18:12:36cryzedGermany
18:12:39cryzedwait.
18:12:41cryzedAndreas Rumpf sounds german
18:12:45*girvo joined #nim
18:13:08cryzed \o/ ~
18:17:18*girvo quit (Ping timeout: 256 seconds)
18:21:11Araqif you want to create a 'var T' accessor there is no accessor abstraction possible, so I don't know why it's such a big deal for you tbh
18:21:36Araqthe reasonable man would mark the field with an * and call it day.
18:22:04Araqand would have done so two days ago.
18:22:13Araq;-)
18:22:52*yglukhov joined #nim
18:24:00Araqand 'var T' is not a first class citizen in the language. you cannot have a 'var T' in an object.
18:24:34AraqNim is not like C++ in this respect.
18:25:53Araqyou can do var x = addr thingReturningVar() to preserve the pointer
18:27:03*cyraxjoe_ joined #nim
18:27:20*cyraxjoe quit (Ping timeout: 246 seconds)
18:27:22Araqthat precious pointer that allows both to read and write with its changes propagated to the underlying data structure. which is as far away from an "accessor" as it can get.
18:31:18cryzedAraq, <Araq> the reasonable man would mark the field with an * and call it day. what do you mean by that?
18:32:04cryzedAraq, and you discouraged me from working with pointers IIRC
18:32:53*FreeDog is now known as LibreWulf
18:33:24AraqI mean instead of 'children: seq...' and an accessor proc for it
18:33:36Araqyou use 'children*: seq...'
18:33:46Araqand don't have an accessor proc.
18:34:02Araqas far as I followed the discussion this seems to solve all your problems
18:34:15cryzedAraq, I would have done that -- if I didn't have this issue too: https://github.com/nim-lang/Nim/issues/3629
18:35:29cryzedAraq, as in I want nodes with no children and nodes with children -- but not nodes with simply nil-initialized children
18:35:38*pregressive joined #nim
18:35:47cryzedbut I can't create the correct type variant for that, because I get a redefinition error
18:35:54Araqyeah and then you move out the 'children' outside the 'case'.
18:36:06cryzed> as in I want nodes with no children and nodes with children -- but not nodes with simply nil-initialized children
18:37:01Araqyeah but that's just not possible right now, sorry.
18:37:13Araqwe can make the compiler support that eventually.
18:37:18cryzedAwesome :)
18:37:28Araqbut then in the implementation the compiler will move the field outside the 'case'.
18:37:44cryzedSo there will be no difference?
18:38:27Araqthere will be a difference in that it will work as you would expect
18:38:57cryzedah alright, I simply don't understand what you said then
18:38:58Araqbut for the memory layouts and offsets etc it won't make any difference
18:39:02cryzedah I see
18:40:14Araqthat said, that 'children' is always accessable will turn out to be pretty useful, IME
18:40:32*LibreWulf quit (Remote host closed the connection)
18:40:36Araqso you can write generic recursion without checking 'if isAtom n'
18:40:49Araqsince 'len' can deal with 'nil' seqs
18:41:09Araqso you can write a treee walker like so:
18:41:19Araqproc walk(n: Node) =
18:41:29Araq for i in 0..<n.len:
18:41:43Araq walk(n.children[i])
18:41:47*LibreWulf joined #nim
18:41:51*LibreWulf quit (Remote host closed the connection)
18:42:35*LibreWulf joined #nim
18:45:20cryzedAraq, you might be right, that might simplify the code
18:45:58cryzedAraq, however can you explain to me why "var T" are not first citizen of the language?
18:46:05cryzedfirst-class
18:46:45Araqthe language tries hard (and fails btw) to ensure memory safety for 'var T'.
18:47:25cryzedmemory safety meaning that you never accidentally try to access an invalid memory address?
18:47:35Araqyes, pretty much
18:47:48Araqbecause 'ptr' is the unsafe pointer already.
18:48:03Araqand 'var' is usually more convenient to use.
18:48:14Araqso 'var' should be convenient and *safe*.
18:48:33Araqand so we have all kinds of restrictions for 'var'.
18:49:41AraqC# does the same with its 'out' modifier.
18:49:56cryzedDo you think you can explain to me in which scenarios storing "var T" and accessing it might blow up in my face? Because if I store "var T" the GC should never try to delete the object in memory?
18:50:29Araqbut even ignoring safety you cannot convince me that 'var x = foo(); x = 3 # updates the data structure!' is good code.
18:51:18cryzedThat's not what I'm doing though, I am getting a var-return value for an object. I would have expected for Integer types to work differently
18:52:05Araqwhy are ints special? Nim is not Java with its split between primitives and classes.
18:52:54cryzedAraq, I see. Sorry, I just need to get used to this different behavior that Python and other languages have ingrained in me
18:54:32cryzedSo for the record: 1) have a children attribute for each Nodetype, and use the .field accessor which allows me to actually modify the reference I want to modify. Use a field for selected nodetypes, once that feature is implemented, and use conditional to access the field depending on type. Or use addr and dereference the pointer to access the field
18:55:58cryzedAraq, is that about right -- did I miss anything? I just have a big interest in understanding exactly how nims work internally -- at least regarding the features I'm regularly exposed to as the end-user.
18:57:37Araqwell you start with (1) and there is no (2) and I'm not sure I understand your summary.
18:58:01cryzed:D
18:58:03cryzedYou are right
18:58:32Araqyou should have 'children*: seq...' in your object outside the 'case' and mark it with 'XXX move it into case once Nim supports that'
18:58:39cryzed1) Create a children field for each of my nodes, even if they don't need one. This allows me to do nodeInstance.children... and actually modify the reference I want to modify without having to store the reference in between and calling a custom children accessor proc in between
18:59:12cryzed2) Continue what I'm doing now, and use the custom children accessor proc, but store the address of the returned field as a pointer instead, and dereference it when needed
18:59:33cryzed3) Do 1 basically just with the assumption that not all variant types have the children field
19:00:07cryzedSo 1) and 3)
19:00:39cryzedthen again, as you said, actually doing 3) would complicate the code at points
19:00:43cryzedbut make it more logical
19:01:26cryzedAraq, thanks for your patience
19:01:26*nastavni1 joined #nim
19:04:12*darkf quit (Quit: Leaving)
19:04:41*nastavni1 quit (Client Quit)
19:06:08*nastavnic joined #nim
19:11:12Araqyou're welcome
19:36:53*desophos joined #nim
19:40:29*BaronFumble joined #nim
19:40:57*pilne joined #nim
19:41:08*Gonzih joined #nim
19:41:29*BaronFumble left #nim (#nim)
19:41:48*Matthias247 joined #nim
19:54:44*gunn quit (Ping timeout: 245 seconds)
19:58:40*gunn joined #nim
19:59:25*makoLine joined #nim
20:03:20*boopsiesisaway is now known as boopsies
20:03:55*Arrrr left #nim ("WeeChat 1.2")
20:13:29*girvo joined #nim
20:18:14*girvo quit (Ping timeout: 272 seconds)
20:26:34*mat4 joined #nim
20:26:36mat4hi all
20:26:38*yglukhov quit (Remote host closed the connection)
20:34:20*BitPuffin quit (Ping timeout: 245 seconds)
20:35:12*Demon_Fox joined #nim
20:44:44cryzedhello
20:58:14*Gonzih quit (Ping timeout: 256 seconds)
21:18:24*ozra quit (Ping timeout: 252 seconds)
21:28:24*Gonzih joined #nim
21:29:31*ozra joined #nim
21:38:12*bjz_ quit (Read error: Connection reset by peer)
21:43:55*bjz joined #nim
21:48:19*bjz quit (Ping timeout: 253 seconds)
21:52:34*bjz joined #nim
21:54:19*zepolen joined #nim
21:57:10*bjz quit (Ping timeout: 256 seconds)
22:04:31*mat4 quit (Quit: Leaving)
22:14:19*girvo joined #nim
22:18:41*girvo quit (Ping timeout: 250 seconds)
22:26:55*Gonzih quit (Ping timeout: 250 seconds)
22:35:46*nastavnic quit (Ping timeout: 240 seconds)
22:44:17*makoLine quit (Read error: Connection reset by peer)
22:48:43*BitPuffin|osx joined #nim
22:49:01*vendethiel quit (Ping timeout: 250 seconds)
23:00:38*boopsies is now known as boopsiesisaway
23:01:19*makoLine joined #nim
23:07:02*ephja joined #nim
23:09:49*solidsnack joined #nim
23:09:58*pregressive quit (Remote host closed the connection)
23:10:14*pregressive joined #nim
23:10:20*pregressive quit (Remote host closed the connection)
23:11:32*desophos quit (Remote host closed the connection)
23:15:39ephjahow do I make this https://github.com/ephja/nim-glfw/blob/master/src/glfw.nim#L271 work now? failIf is defined here: https://github.com/ephja/nim-glfw/blob/master/src/glfw.nim#L242
23:16:02ephjamust all those statements be rewritten?
23:22:06ephjaI should take another approach though
23:24:59*zepolen quit (Remote host closed the connection)
23:33:07*nastavnic joined #nim
23:34:33*cyraxjoe_ is now known as cyraxjoe
23:38:25*nastavnic quit (Ping timeout: 250 seconds)