<< 16-07-2015 >>

00:15:47*[CBR]Unspoken quit (Ping timeout: 256 seconds)
00:35:42*[CBR]Unspoken joined #nim
00:44:56*renesac quit (Ping timeout: 252 seconds)
00:45:24*brson quit (Ping timeout: 264 seconds)
00:47:02*brson joined #nim
00:55:43*[CBR]Unspoken quit (Ping timeout: 252 seconds)
00:57:26*renesac joined #nim
01:11:37*[CBR]Unspoken joined #nim
01:14:06*Demos joined #nim
01:18:17*[CBR]Unspoken quit (Ping timeout: 240 seconds)
01:18:59*Demos quit (Ping timeout: 265 seconds)
01:21:11*Jesin joined #nim
01:21:16*[CBR]Unspoken joined #nim
01:21:23*rinukkusu quit (Ping timeout: 250 seconds)
01:24:17*rinukkusu joined #nim
01:28:52*vasher_ joined #nim
01:31:27renesacwhere I find a list of things about the plataform that the compiler provides?
01:31:35renesaclike, what cpu is it
01:31:54renesacto acess by "when" in a nim file
01:33:16renesacwhat OS is it, etc
01:58:07EXetoCrenesac: when defined(<os>)
01:58:14*drewsrem quit (Quit: Leaving)
01:58:24renesacwhere is a list I can refer to?
01:58:46renesaca table, something like that
01:59:07*groungch joined #nim
01:59:20*groungch left #nim (#nim)
01:59:48EXetoCI've only seen one in compiler/platform.nim (line ~40, const named OS)
02:00:08EXetoCLinux, Windows, MacOS, MacOSX, FreeBSD...
02:02:11renesacright, it seems that it is all in that file
02:06:06renesacit should be documented outside it..
02:06:36renesacaaand, I discovered I can simply do "clong.sizeof"
02:06:52EXetoCyep
02:12:17*brson quit (Quit: leaving)
02:35:58*MatrixBridge quit (Remote host closed the connection)
02:36:06*MatrixBridge joined #nim
02:40:01*vendethiel joined #nim
02:41:39onionhammerapense the websocket implementation works with ws:// only, not secure websockets
02:41:44onionhammeroop
02:58:19*perturbation joined #nim
03:00:10perturbationhey all - bit of a weird question. Is it possible to check for presence of a module (so that you can provide what JS folks would call a 'polyfill') if a dependency is not present?
03:00:19perturbationi.e.
03:00:29perturbationwhen definedInImportPath(foo):
03:00:32perturbation import foo
03:19:30*darkf joined #nim
03:24:05perturbationhmmm... I think I can use compiler/option.nim's findModule() proc
03:24:11perturbationbut I have to play around with it some more
03:24:24*perturbation quit (Quit: Leaving)
03:38:52*vasher_ quit (Quit: Connection closed for inactivity)
03:44:57*vendethiel quit (Ping timeout: 265 seconds)
03:45:06*eventualbuddha quit (Read error: Connection reset by peer)
03:45:53*clone1018 quit (Ping timeout: 252 seconds)
03:46:15*TylerE quit (Ping timeout: 246 seconds)
03:46:17*pmbauer quit (Ping timeout: 252 seconds)
03:46:17*mikolalysenko quit (Ping timeout: 252 seconds)
03:47:18*DecoPerson quit (Ping timeout: 246 seconds)
03:48:06*vendethiel joined #nim
03:54:45*pmbauer joined #nim
03:57:56*mikolalysenko joined #nim
03:59:22*clone1018 joined #nim
04:01:28*BitPuffin|osx joined #nim
04:02:02*TylerE joined #nim
04:10:21*eventualbuddha joined #nim
04:10:50*vendethiel quit (Ping timeout: 256 seconds)
04:13:53*strcmp1 quit (Quit: Leaving)
04:15:36*pregressive quit (Remote host closed the connection)
04:18:55*DecoPerson joined #nim
04:22:56renesacEXetoC: done: https://github.com/nim-lang/Nim/wiki/Consts-defined-by-the-compiler
04:23:31renesacthose lists probably should be auto-generated and included in the documentation, but for now they are there
04:31:49*rgv151 joined #nim
04:35:35*Jesin quit (Quit: Leaving)
05:11:52*elbow_jason joined #nim
05:20:10*luke joined #nim
05:20:12*luke is now known as Guest23028
05:21:15Guest23028is there a way to memset an int array in nim?
05:22:09*BitPuffin|osx quit (Ping timeout: 246 seconds)
05:28:57Guest23028alternatively, say you have an array that has to be set back to 0 very often, what is the fastest way to do this?
05:30:56fowlGuest23028, system.zeromem()
05:33:12Guest23028cheers fowl
05:36:39*pregressive joined #nim
05:53:45*pregressive quit (Remote host closed the connection)
06:11:44*jszymanski joined #nim
06:13:20*pregressive joined #nim
06:17:17*vendethiel joined #nim
06:27:02*renesac quit (Ping timeout: 252 seconds)
06:30:12*pregressive quit (Remote host closed the connection)
06:39:17*renesac joined #nim
06:41:47*vendethiel quit (Ping timeout: 240 seconds)
06:52:00*Demos joined #nim
06:56:21*Demos quit (Ping timeout: 255 seconds)
06:56:43*EXetoC quit (Ping timeout: 246 seconds)
06:59:29*xet7 quit (Quit: Leaving)
07:01:16*vendethiel joined #nim
07:11:21*cazov quit (Ping timeout: 246 seconds)
07:14:34*cazov joined #nim
07:17:03Guest23028so, integer division of int64/int64, not allowed to? is this not supported?
07:17:24Guest23028l.nim(34, 20) Error: type mismatch: got (int64, int)
07:17:25Guest23028but expected one of:
07:17:25Guest23028system./(x: int, y: int)
07:17:25Guest23028system./(x: float32, y: float32)
07:17:25Guest23028system./(x: float, y: float)
07:20:34Guest23028ah sorry. 'div' is used. didn't realise / always returns float
07:20:58*darkf quit (Read error: Connection reset by peer)
07:21:32*vendethiel- joined #nim
07:21:33*vendethiel quit (Ping timeout: 255 seconds)
07:21:57*darkf joined #nim
07:29:36*keypusher quit (Remote host closed the connection)
07:30:02*key_ joined #nim
07:39:38Guest23028so hey, how does the binary & operator work on ints in nim? I wanna see if a&b is true but I cannot & two int's
07:43:10*vendethiel- quit (Ping timeout: 248 seconds)
07:44:32Guest23028it seems like 'and' works but then how do I &= a value?
07:47:11*vendethiel joined #nim
07:56:31r-kuAraq | [17:42:11] r-ku: you can have a fastcall call that calls a cdecl function
07:56:37r-kustill need to tell c compiler that fastcall is to be used
08:08:01*vendethiel quit (Ping timeout: 244 seconds)
08:08:17Guest23028hey, does anyone mind giving me a little hand? I don't get these 'and' and 'or' and & etc rules. I've looked around and it doesn't really say from what i've seen
08:09:02Guest23028this gets out of bounds 'arr[n shr 3] or int8(1 shl (n mod 8))' but i can print both sides of it fine without going out of bounds. any idea? am i using or completely wrong?
08:13:35*coffeepot joined #nim
08:18:24Guest23028oh! uint8 operations are not available without import the module? is this why i cant go uint8 or int?
08:25:16*Trustable joined #nim
08:31:01*Guest23028 quit (Quit: Leaving)
08:31:25*luke joined #nim
08:31:49*luke is now known as Guest86655
08:35:40Guest86655Hey people, so i'm trying to write a segmented sieve of Eratosthenes in Nim, I've got the algorithm working fine however its slow! I'm very new to Nim and would like some performance pointers. If anyone is willing to have a look, i'd much appreciate it. Its currently 10x slower than my python version that is not segmented. http://paste.ofcode.org/TKmny9WL2jCiAzdFpfTyY5
08:46:36Araqhi Guest86655, use 'result' in 'prime_sieve_s' directly, not 'result = primes'
08:46:41Araquse -d:release
08:46:52*vendethiel joined #nim
08:47:43Guest86655Cheers Araq!
08:47:57VarriountGuest62515: Does your code work with sequences and strings? If so, be aware that both those data types are copy-on-assignment.
08:48:35Araqprobably there is something else wrong with this code if it's 10x slower than python ;-)
08:48:57Araqbut right now I cannot see it and I'm too lazy to run it in a profiler
08:48:57VarriountAraq: Not wrong, just unoptimizes
08:49:05Varriount*unoptimized
08:50:23Guest86655Thanks, its just sequences and an array which i set to 0 with zeroMem as its needed lots.
08:50:28AraqVarriount: no, it could also be wrong. lot of 'countup' bounds that could be off, so Nim has to iterate 100x more than Python
08:51:07Guest86655Is it really that much faster to use result rather than setting it at the end?
08:51:37Araqno, for your example it's likely irrelevant since you call prime_sieve_s only once
08:51:50Guest86655Thought so. But cheers!
08:51:52Araqbut in general it's a copy vs a move
08:51:56VarriountGuest62515: Well, for the first procedure in that code, `result = primes` will copy `primes`
08:52:15Guest86655would it be easier to just return primes?
08:52:33VarriountGuest62515: That would work too... I think.
08:52:54VarriountAraq would know for sure how 'return' is done.
08:53:03AraqI don't think the compiler does that right now
08:53:04Guest86655I mean it does work, I just don't yet see why the result variable is there. I was just using it as i read about it early on
08:53:19Araq#sieve size to fit in cache
08:53:20Araqconst sievesize:int=1 shl 19
08:53:57Guest86655with my c++ implementation I could get it to fit in the cache and it was much faster, hence the segmented sieve
08:54:24Guest86655i've been trouble finding the right value for this. its currently at half the python time now with the command line switches
08:55:42Guest86655I don't think nim likes how i use the bit array as is using unsigned uint8's. there is no native bit array is there?
08:56:32VarriountGuest62515: Have you actually used a profiler on the code?
08:56:34Araqthere is an intsets stdlib module
08:57:05Araqmy guess is you call zeroMem way too often
08:57:22Araqalways resetting everything which is not necessary
08:57:38Guest86655hmm you just gave me a fantastic idea
08:57:40Guest86655cheers
08:57:43Araqyou can store a runtime "max used bit" in your 'proc set'
08:58:03Araqand use that for clearing 'arr'
08:58:12Guest86655as i iterate through afterwards getting the primes, i can set the bit to 0
08:58:39Guest86655you have a point with that also
08:58:42Araqor that, but this could be slower
08:59:07Araqalso try a smaller cache size
08:59:42AraqL1 cache is usually smaller, 32KB
09:00:15Araqoh wait, I have 128KB :P
09:00:41Guest86655yeah. Will do thanks. I'm just trying to find the best ways to actually use nim. I know it can be fast, i just haven't been able to achieve that yet ha. Yes indeed. Cheers. Sometimes its best to fit it in L2 if the primes you iterate through is large enough I assume.
09:01:33Araqyeah but you use ALL of L2
09:01:47Araqno room left for code and helper variables
09:02:24Guest86655hmm. Valid point.
09:02:36Araqbut then there is also L3 cache ... so ... I have no idea
09:03:33Guest86655ha yeah i'll work with the cache. its more just the use of the commands i'm looking for improvements in. I'll quickly whip up a identical python script to test in pypy
09:04:21Araqah ok! so you do compare to pypy :-)
09:05:55Guest86655yeah :D
09:06:45Guest86655is there any way to use pythons bitshifts and mod etc instead of having to explicitly type shr and what not?
09:08:10Araqtemplate `<<` (a, b): untyped = a shl b
09:08:41Araqbut << then has the precedence of < so that's why we don't do that
09:09:00Guest86655Oh i see
09:09:11Araqrenesac uses *< and *> so they have multiplicative precedence
09:09:33*vendethiel quit (Ping timeout: 255 seconds)
09:21:00*vendethiel joined #nim
09:37:26r-kuAraq: cant build 64 bit compiler on windows?
09:37:59Araquse build64.bat ?
09:42:38*vendethiel quit (Ping timeout: 248 seconds)
09:43:52Araq8888 posts on our forum :-)
09:46:08r-kuAraq: somehow doesnt work. assert_numbits thing fails. adding -m64 in build64.bat results in c_code\1_2\compiler_nim.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
09:56:34r-kubuild.bat works by the way, building 32 bit executable
09:59:17*Kingsquee quit (Quit: Konversation terminated!)
10:05:38coffeepotthat's weird, I'm sure I used the build64 batch file on devel
10:06:24r-kuwell i merged devel yesterday
10:06:38r-kucoffeepot: what compiler did you use? im using mingw myself
10:06:40coffeepotah well it was a few weeks ago now for me
10:07:04coffeepotI literally just used git to pull over devel and did the normal install procedure but with buil64
10:07:12Araqif assert_numbits fails your setup is wrong
10:07:45coffeepotofc you gotta make sure any dlls are 64bit
10:08:03Araqbootstrapping doesn't use DLLs
10:08:06r-kuadding -m64 makes it go away Araq, but why c_code/1_2 has no 64 bit mode implemented as error says?
10:08:20coffeepotah yes but nimble does I think
10:08:24Araq1_2 is the 32 bit variant
10:08:30Araq2_2 should be win64
10:09:05r-kubuild.bat uses 1_1 and build64.bat uses 1_2
10:09:24r-kuand build.bat correctly builds 32 bit executable
10:10:03Araqoh ok, so it's 1_1 and 1_2
10:10:05Araqsounds right
10:12:34coffeepotI think... I may have downloaded the 0.11.2 release in 64 bit, installed that and later decided to move to devel so used the dist from the 0.11.2 package :3
10:14:28coffeepotso with a fresh devel folder but with the 0.11.2 bundled mingw
10:17:18*k1i quit (Ping timeout: 248 seconds)
10:18:52*k1i joined #nim
10:19:11r-kuwell someone needs to do some testing in that area
10:19:56Araqr-ku: http://buildbot.nim-lang.org/builders
10:20:11Araqhttp://buildbot.nim-lang.org/builders/windows-x64-builder/builds/465
10:28:31*vendethiel joined #nim
10:31:56*vendethiel- joined #nim
10:32:51*vendethiel quit (Ping timeout: 252 seconds)
10:38:39*bjz joined #nim
11:05:14*raza joined #nim
11:05:25r-kuAraq: build bots do not serve built binaries?
11:06:28r-kualso what compiler actually those buildbots are using?
11:13:33*arnetheduck quit (Ping timeout: 246 seconds)
11:15:28*dom96_ joined #nim
11:16:28dom96_r-ku: http://build.nim-lang.org/ has binaries
11:17:08dom96_Only linux though
11:17:17dom96_I need to revive NimBuild
11:25:50*arnetheduck joined #nim
11:40:36*wtw quit (Ping timeout: 264 seconds)
12:05:26*zemm quit (Ping timeout: 264 seconds)
12:06:23*arnetheduck quit (Quit: Leaving)
12:08:03*dom96_ quit (Ping timeout: 246 seconds)
12:10:11*ozra joined #nim
12:11:23*joebo quit (Quit: WeeChat 1.1.1)
12:14:19*UberLambda joined #nim
12:26:15*zemm joined #nim
12:27:18*ozra quit (Ping timeout: 246 seconds)
12:38:02*OnwardEuler joined #nim
12:52:37*Onward_Euler joined #nim
12:52:50*zephyz joined #nim
12:55:57*OnwardEuler quit (Ping timeout: 265 seconds)
12:58:11*drewsrem joined #nim
13:00:31r-kuyeah dom96 i need windows x64 build so i can test windows x64 coroutines. linux 32/64 bit + windows 32 bit tested and work. got code for windows x64 too but it will most likely fail as its not tested
13:01:40drewsremIs there any way to allow identifier starting with _ ?
13:01:49drewsremLike quoting them or something?
13:03:54*Onward_Euler is now known as OnwardEuler
13:04:23Araqdrewsrem: I don't think so.
13:06:13drewsremThey seem a bit like nuisance to work around with when wrapping/using clibs
13:06:24drewsremBut nothing big
13:07:12Araqwell wrappers should adhere to NEP1 too
13:07:25Araqwhich c2nim supports via the --nep1 switch
13:07:50Araqactually it should be the default but c2nim's defaults are all crappy
13:08:49*EXetoC joined #nim
13:12:17drewsremRight, in my case it's the usage of the plain c2nim ported clib, the example I'm porting uses an enum to both index an array and the field names of the enum correspond to strings the interface makes use of and they just happen to use underscore-prefixed-commands.
13:12:37drewsremSo I just need to do it differently
13:13:07drewsremBut I'm 1:1 copying/porting c-code here, so it probably can be done better in nim anyway
13:13:31Araqyeah, for example $ works for enums out of the box
13:14:46drewsremRight, so that'd work, but e.g. the enum has a field named "_FOO" and you're supposed to pass that cstring to an API, now I can't call the enum-field "_FOO", but "uFOO" but then I can't just pass it to the API anymore, but would have to replace it or something
13:15:25drewsremI should probably just show you some code if you care, but I don't think it's too interesting anyway
13:15:41drewsremJust can't use enums for this like they do in C
13:16:49fowlYes you can drewsem
13:17:21fowlEnum a = (1,"_a"), ...
13:17:32AraqOnO: why are colors disabled with --stdout too?
13:18:31fowlFor stringification at least, in general c enum members should just be consts
13:18:31AraqI thought --stdout should become the default on Unix anyway, so the precious stdout stream is available ... for something ...
13:19:07drewsremfowl, right, I just realized it uses some macro stuff for C...
13:19:16Araq(for what? gcc doesn't spill out a.out on stdout either)
13:21:21drewsremfowl, if you care: http://ix.io/jLq
13:25:24Araqdrewsrem: do you wrap x11? there is already a wrapper for that
13:25:25drewsremSo it uses the identifiers of the enum to index an array, but they also correspond to API-calls which are passed to as cstrings
13:25:31drewsremAraq, I partially wrapped xcb
13:25:40bogenAraq: Well, while gcc won't put a.out on stdout, it will output aseembly on stdout
13:25:40bogenprintf '#include <stdio.h>\nvoid main(){printf ("hello world!\\n");}' | gcc -o- -x c - # yeah, that outputs to a file named -
13:25:40bogenprintf '#include <stdio.h>\nvoid main(){printf ("hello world!\\n");}' | gcc -S -o- -x c - #outputs assembly
13:25:59drewsremAraq, x11 AFAIS uses xlib
13:27:15drewsremAraq, I really didn't had to do much of anything thanks to c2nim :), enjoying this very much so
13:28:05Araqbogen: bah, now I need to figure out how to get rid of this useless piece of information
13:28:14Araq;-)
13:29:33Araqdrewsrem: afaict your snippet is an excercise of how to simulate $ for enums :P
13:29:59reactormonkAraq, don't we have $ for enum?
13:30:10Araqreactormonk: yes but C lacks it.
13:30:28reactormonkall hail nim \o/
13:30:55drewsremAraq, right, it would be perfect if I could name the enum "field-identifiers" as starting with an underscore :P
13:31:17reactormonkdrewsrem, you can, via importc I'd say
13:31:25reactormonkor exportc, depending on what you need
13:31:44*FedeOmoto joined #nim
13:32:15drewsremBut I think I understood fowl now, so I'm just going to do: a = enum \n uFOO = (0, "_FOO"), uBAR = (1, "_BAR")
13:32:32Araqor just use a .pure enum
13:33:37drewsremAraq, how does that help me? - does it let me use underscore-prefixed identifier for the enum fields?
13:33:51Araqno.
13:34:13Araqbut I don't get why the underscore is so important. by definition it carries no semantics.
13:34:48fowlIm curious too
13:35:17drewsremBecause I can stringify them via $ and then pass them to the API, the API takes them as strings: xcb_intern_atom_cookie_t xcb_intern_atom(xcb_connection_t *conn, uint8_t only_if_exists, uint16_t name_len, const char *name);
13:35:23fowlAnd most problems with c identifiers are solved with importc:"_$1"
13:35:38drewsrem const char *name
13:35:44reactormonkfowl, ^ nice one
13:35:56drewsremThat's the only reason
13:36:02*dalarmmst joined #nim
13:36:03Araq proc `$`(x: MyEnum): string = "_" & system.`$`(x)
13:36:22drewsremProblem is that not all enum fields are prefixed with underscores, some aren't
13:36:49drewsremBut I guess I could find some rule how to replace them
13:36:55Araqwrap wayland instead? :P
13:37:00fowlYes
13:37:40fowlWork on new monoliths not old ones :p
13:37:54drewsremI'm actually more confident in X11 becoming better then wayland replacing X11 all of the sudden :P
13:38:25reactormonkdrewsrem, probably too much legacy compat
13:38:32fowldrewsrem we dont generally keep the same names in nim as c
13:39:30Araqyup. we don't hate vowels for a start.
13:40:13drewsremIt's not really an issue tho anyway
13:40:22drewsremI just can't do it exactly like the example does
13:40:24EXetoCx11 just seems like a mess judging by the presentation I watched, and many former x11 devs have migrated to wayland. I assume they have their reasons
13:40:38EXetoCa lot of momentum is needed though
13:41:36drewsremWayland is very meh tho because it leaves so much open to the widget-toolkit-guys, what X11 does well is it enables lonseome people to write powerful window-managers like i3/awesome-wm etc., in wayland you have to go ask the widget-toolkit for example to please not draw any borders around your windows, because there's no generalized API in wayland itself
13:42:20Araqhrm now I feel like trying out a linux distro that uses wayland. any suggestions?
13:42:27fowlSo wm is now widget toolkit? Sounds great
13:42:32drewsremAraq, archlinux
13:42:38EXetoCbut such abstractions will emerge at some point surely
13:42:52bogendrewsrem: heh, was going to say the same thing...
13:42:53r-kufedora could run gnome on wayland afaik
13:43:02EXetoCif they haven't already
13:43:13drewsremThe difference is that you have to deal with the widget-toolkit guys, X11 has a lot of ancient concepts, but its very centralized
13:43:33drewsremAraq, https://github.com/Cloudef/orbment
13:44:14drewsremBut I have no idea what is going to happen in the future, just atm I'm not that hyped about it and X11 is getting a lot better recently
13:44:57drewsremAraq, AFAIS it's a lot of work tho to get the wayland stuff going
13:45:27Araqyay, bright grey on darker grey
13:45:58drewsremWell, gotta love your minimalism on Linux or why else are you using it :)
13:46:30drewsremBut KDE might be Wayland ready already
13:46:43drewsremI don't follow this stuff
13:47:01r-kuits not, but is getting there
13:47:31EXetoCis that color scheme available somewhere?
13:47:32r-kubut still some basic things like copying text from xwayland to wayland window no workie.. (on gnome too i think)
13:47:33Araqmy /usr/bin had over 100 binaries iirc and the typical distro doesn't fit on a CD anymore. what kind of minimalism do you have in mind?
13:49:11drewsremAraq, the interface work-flow window-manager thingies are usually rather minimal
13:50:11drewsrembut yeah, "minimalism" is overused
13:50:56drewsremI can only say that i3 brings me daily joy, still after 2 years, so I guess whatever floats your boat
13:54:54drewsremback to dealing with this c-api so I can do really simple things in a really hard complicated way...
13:56:58federico3yay for i3
14:01:08*vendethiel- is now known as vendethiel
14:02:23*bogen quit (Quit: Leaving.)
14:02:47*bogen joined #nim
14:12:55*yglukhov_____ joined #nim
14:17:03Araqbogen: oh btw using cling for a REPL has been brought up before. It's a good idea and feel free to work on it
14:17:31*brson joined #nim
14:18:50*Demos joined #nim
14:21:19Araqr-ku, fowl any objections about making currentModule a proc?
14:21:34Araqthis way we could use the plugin mechanism for this feature
14:22:30Araqoh well we can use the plugin mechanism anyway
14:22:48r-kuAraq: it would be awkward but if its easier... can always deprecate it later
14:23:53r-kubtw 64 bit build on windows might be my gcc not being able to build x64. i totally did not expect that :|
14:24:28Araqthe plugin system supports constants easily anyway, so never mind
14:25:07r-kuawesome \o/
14:26:49*aziz_ joined #nim
14:27:26Araqis it CurrentModule or currentModule?
14:28:10r-kufollow same style as other constants
14:28:19*zephyz quit ()
14:28:51r-kuthere are CompileTime and cpuEndian. uh..
14:29:01r-kuwell idk whats the correct nim style, you know better
14:29:19Araq". All other identifiers should be in camelCase with the exception of constants which may use PascalCase but are not required to."
14:29:38Araqso ... I'll use currentModule
14:29:58r-kui would take that "but are not required to" out. things should be consistent in one project
14:30:31Araqping Varriount
14:32:19AraqI still think these should be in a new module
14:32:47Araqcurrentmodule.name, currentmodule.file, currentmodule.dir
14:34:37fowlAraq all of those are accessible from system.currentSourcePath
14:34:41r-kuhaving currentModule entity serving these 3 properties suggests there could be more stuff to do with it
14:35:09r-kuthink there gonna be more in the future?
14:35:16Araqwe have a system.currentSourcePath ?
14:35:26fowlYes omg its great
14:35:44r-kutemplate currentSourcePath*: string = instantiationInfo(-1, true).filename
14:35:46r-kuwow
14:36:03fowlhttp://nim-lang.org/docs/system.html#currentSourcePath.t,
14:36:19Araqwell then we don't need currentModule stuff, do we?
14:36:32fowlI dont think so
14:36:51EXetoCyou should know what's in there :p
14:37:03EXetoCjk
14:37:10drewsremDoes it make sense to include a "proc len" for enums?
14:37:12r-kuits probably very rare case when this kind of thing is needed yeah
14:37:15fowlI use os.splitpath.head to refer to this module dir. Works great for c sources in nimble package
14:37:48r-kufowl: is there any proc that extracts dir path from file path?
14:37:53Araqdrewsrem: no.
14:38:11Araqr-ku: os.extractDir
14:38:26r-kuawesome, thanks
14:38:40Araqor splitFile(f).dir
14:38:50EXetoCiterating over enum members is another use of getType
14:38:58fowlShortcuts would be good tho
14:39:16r-kuAraq: we really should move error/warning/hint to system..
14:39:27Araqno way
14:39:32r-kuthey arent exclusively needed when doing macros
14:39:45EXetoCexcluding those pesky holes \o/
14:39:48Araqthey only work in macros
14:40:02Araqbut we also have {.error: "foo".}
14:40:11r-kuohh
14:40:14r-kudidnt know
14:40:18r-kuthat solves it then \o/
14:40:18Araqdon't ask why, this stuff has grown
14:40:18fowlMagic thismodule symbol might be useful for templates
14:43:07r-kufowl: whats usecase for that?
14:45:08r-kudamn this msys2 thing is nice
14:45:19r-kuit has pacman as package manager (on windows!!)
14:45:45*Onward_Euler joined #nim
14:46:36UberLambdaDo you think there is any need for RAII? I'm currently using try...finally blocks but it just doesn't feel the same
14:46:53coffeepotdon't forget defer: too
14:46:57UberLambdaOr is there a better approach at things like closing streams, etc?
14:47:00EXetoCwasn't there a point when there was neither a package manager nor a bundle of sorts?
14:47:25EXetoCor was that cygwin? but what a pain in the ass
14:47:34UberLambdacoffeepot: hm, I had no idea it existed... it's like python's 'with' statement?
14:48:06coffeepothmm not really used python's with, but it's kind of syntactic sugar for try finally
14:48:09AraqUberLambda: we have proc `=destroy`(x: var Foo) for destuctors in the language but currently they don't work too well
14:48:10r-kuEXetoC: i know nothing of package managers in original msys (v1.0). cygwin had pkg manager for a long time.
14:48:12*xet7 joined #nim
14:48:26coffeepotf = openFile... defer: closefile(f)
14:48:28UberLambdaAraq: I've tried them, but they never got executed :(
14:48:57*OnwardEuler quit (Ping timeout: 244 seconds)
14:49:05UberLambdaeven with the {.destructor.} pragma on them
14:49:20Araqdon't test them in top level statements
14:49:38UberLambdaAraq: so I should wrap the code in a function?
14:49:41UberLambda*proc
14:49:51coffeepotahem, sorry i guess you found this already uberlambda http://nim-lang.org/docs/manual.html#exception-handling-defer-statement
14:49:51Araqfor destructors to work, yes
14:50:11UberLambdacoffeepot: thanks for the tip :D
14:50:45coffeepotaren't destructors only for the type? Or is that finalizers...
14:51:06UberLambdaAraq: I'll try them...but are they really bugged, like "executed twice" bugged? If so I think I'll just use defer
14:51:32Araqtry it
14:52:15UberLambdaAlso, one thing... when I have a "ref object of ...", is every instance of that passed as reference? Or are they copied everytime they're passed to a function?
14:52:34UberLambdaI don't quite understand how passing in general works
14:53:01Araqa ref object works like a Java/C# class
14:53:39UberLambdaso... always passed by reference then?
14:53:59UberLambdaIn C++ terms I mean
14:54:00*BitPuffin|osx joined #nim
14:54:01Araqnot really, passed by value but the value is a pointer
14:54:16*aziz_ quit (Remote host closed the connection)
14:54:24UberLambdaHm, well, atleast they do not get deep copied everytime
14:54:46Araqit's like a C++ typedef struct SomeStruct* RefObject;
14:55:07Araqand then RefObject still is a pointer but the pointer is copied
14:55:10UberLambdaAraq: oh, it's clearer now, thanks
14:55:41*zephyz joined #nim
14:56:53AraqUberLambda: "I don't quite understand how passing works". In C++ terms everything is passed by const& T except as an optimization the compiler is free to pass T directly by copy too.
14:56:54*xet7 quit (Quit: AndroIRC - Android IRC Client ( http://www.androirc.com ))
14:57:12Araqand it does so for a small T
14:57:33drewsremIs it possible to maintain some state between macro calls? - i.e. I'd like to have a macro foo that adds elements to a sequence on each call and then a call to bar runs over those and does things with them
14:57:37r-kuwhen i ``import os`` in my arch.nim module i get strutils.nim(244, 3) Error: undeclared identifier: 'assert'.. why? :\ that file -> https://github.com/r-ku/Nim/blob/coroutines/lib/arch/arch.nim
14:57:49Araqwhere "small" means <= sizeof(float)*2 iirc
14:59:01coffeepotAraq: why is it ever considered an optimisation to copy a struct rather than pass a pointer (if I understand correctly)?
14:59:21coffeepothang on
14:59:31UberLambdaAraq: wait... no difference between "void a(const std::string a)" and "void b(const std::string& b)" ?
14:59:45coffeepotthought about it for more than 2 seconds, I'm guessing CPU cache being one reason
14:59:53Araqcoffeepot: because the "copy" can mean a "mov rax, rbx"
15:00:14UberLambdaYeah but that's an optimization right? Not actually in the language "standard"
15:00:41UberLambdaOr the standard specifies what the compilers can/can't do in these situations?
15:00:54r-kuthis to me sounds like value vs reference semantics. like strings and lists in python for example.
15:00:54Araqyeah but it's an implementation detail that leaks
15:01:07Araqthanks to aliasing ...
15:01:27Araqfortunately there are ways to detect this eventually
15:01:31UberLambdaHm... so, what happens in nim when I pass a plain object?
15:01:41UberLambdaDoes it get deep copied then?
15:01:55Araqit depends on the size of the object
15:02:03UberLambdaNice
15:02:22Araqand also whether the object uses GC'ed memory for reasons that are too complex to explain here :P
15:03:05UberLambdaI guess I don't have to worry too much about what kind of structures to use then... that's a problem less to solve, yay
15:03:34Araqyeah, it works really well in practice. it's like C++ should have done it.
15:03:37coffeepot"mov rax, rbx" ah nice
15:03:56UberLambdaBut why does most code define a "object XyzObj" and then define "Xyz" as "ref XyzObj"?
15:04:08UberLambdaI mean, most code that I've seen in the standard library atleast
15:04:13AraqUberLambda: legacy
15:04:19Araq'ref object' came later
15:04:31UberLambdaAraq: oh, that explains it. Thanks :D
15:09:38r-kuAraq: wth..? Error: system module needs 'copyStrLast'
15:09:51r-kuall because i use substr()
15:10:16Araqr-ku: do you use your arch stuff from system?
15:10:22r-kuno
15:10:38UberLambdacompany-nim is pretty broken... if you consider that it spawned ~100ish nimsuggest processes, lol
15:10:44Araqwell you use substr() too early then :P
15:11:16r-kucoro.nim is my test case which imports arch.nim, and arch.nim tries to use substr
15:11:20r-kuhow the hell can it be too early?
15:11:44*yglukhov_____ quit (Quit: Be back later ...)
15:12:19Araqbefore the compiler processed system/sysstr and so knows where to find copyStrLast
15:13:11Araqare you sure you didn't touch anything in the system module?
15:13:20*bogen-work quit (Quit: Lost terminal)
15:14:52r-ku100% positive, i have no business in system.nim
15:15:10Araqshouldn't the GC use your new asm based stuff?
15:15:21r-kuohhhh
15:15:24Araqdidn't you modify the GC?
15:15:30r-kui forget that gc stuff is included, not imported
15:15:36Araqaye
15:16:11r-kubut its included way after substr()
15:16:14r-kushouldnt it work?
15:16:40Araqit comes before sysstr though
15:17:01Araqwhat do you use it for anyway?
15:17:22r-kuoh. i want to extract path from filename
15:17:41r-kuits used in passL to point to obj file compiled from asm
15:18:08Araqso it is evaluated at compile-time?
15:18:15r-kuyes
15:18:26Araqhrm then it should work
15:18:43r-ku{.passL: extractDir(currentSourcePath) "/" & ABI & "_" & hostCPU & objExt} - compile time right?
15:20:14Araqer yeah but
15:20:25Araqso you import os.nim from system.nim
15:20:37Araqthat is not supported
15:20:56r-kuwell in current testcase i did not import it cause it yielded error. tried to reimplement extractDir myself only to find out i cant use substr
15:21:12Araqyeah you can
15:21:23Araqyou need to mark your extractDir with .compileTime
15:22:09r-kudone. Error: undeclared identifier: 'currentSourcePath'
15:22:31Araqsee? there is progress!
15:22:45r-kui see waist-deep mess :D
15:23:37Araqi told you I want compiler support for the external assembler
15:23:41*vasher_ joined #nim
15:23:48Araqyou knew better and now see where that got you :P
15:24:14r-kunah it was more like now knowing how to do it properly so.. here we are :D
15:24:18Araqbut you only need to move the declaration of currentSourcePath and instantionInfo around
15:25:12r-kunah.. {.passL: extractDir(instantiationInfo(-1, true).filename) & "/" & ABI & "_" & hostCPU & objExt} - Error: undeclared identifier: 'instantiationInfo'
15:25:14*UberLambda quit (Ping timeout: 264 seconds)
15:25:24r-kubut hey - maybe you are bored and want to implement external assembler support? :D
15:25:42Araqok
15:26:18Araqactually i implemented caching for staticExec
15:26:34Araqyou can call the assembler via staticExec, right?
15:27:02r-kuerr no idea, idk how staticExec works even
15:27:46r-kuah i see. that sounds useful
15:27:52Araqhow do you invoke the assembler then?
15:28:01r-kucurrently i just stick fasm execution on koch boot step
15:30:10r-kunot sure how staticExec caching should even work. compiler doesnt know about output of external program..
15:32:59Araq{.passL: staticExec("fasm " & hostCPU & ".asm", "", NimVersion).}
15:33:14Araqand fasm should output only the name of the produces object file :P
15:33:21Araq*produced
15:33:30r-kubut it doesnt
15:37:18Araqwhat is its output?
15:38:25r-kuyou can call the assembler via staticExec, right? bler version 1.71.39 (16384 kilobytes memory)
15:38:27r-ku2 passes, 787 bytes.
15:38:33r-kugarbage..
15:38:57*sparrk joined #nim
15:39:00r-kuheh that old text should not be on first line start
15:39:14sparrkIs it possible to determine the type of something at runtime?
15:39:34Araqsparrk: if foo of Subtype
15:39:44Araqworks for objects only
15:40:00Araqbut for the other things you already know at compile-time
15:40:24sparrkSo that is what I'm doing. Maybe I'm misunderstanding the JSON library. Is there an example of someone parsing an api that they do not know the structure of ahead of time?
15:40:39sparrkAnd thanks for your help again Araq
15:41:32Araqwell the JSON library returns a Json object that can represent every JSON data including "schemaless" data
15:41:58Araqhowever if it's schemaless you can convert it into a Nim object with fixed fields
15:42:03Araq*you cannot
15:42:41*raza quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
15:42:55Araqso you have to use data["field"]["fieldB"] rather than specializedObject.field.fieldB
15:43:09Araqbut no big deal, is it?
15:44:53Araqr-ku: const dummy = staticExec("..."); {.passL: "foo.obj".}
15:45:17r-kuso... can build wrapper executable that would call assembler and print input path to stdout.. can try to modify fasm itself but i dont think its optimal.. or you can implement external assembler support into compiler
15:45:25r-kuwe kind of have to use absolute paths in passL
15:45:33r-kucause it works relative to project root
15:45:38*sparrk quit (Ping timeout: 264 seconds)
15:47:15*raza joined #nim
15:48:58Araqok, ok, I know how to do it
15:50:09r-kuim all ears
15:52:41*darkf quit (Quit: Leaving)
15:52:50Araqwe planned to support {.compile: "foo.cpp".} to invoke the C++ compiler even when in C mode
15:53:08Araqso .compile should do some file extension detection
15:53:17Araqand might as well detect .asm files
15:54:11Araqto reuse as much as possible from the existing logic, we will treat fasm as yet another C compiler
15:54:24Araqso only extccomp.nim needs to be modified
15:54:29Araqyou can do it
15:55:00r-kusounds good. although i bet we want to be able to use any assembler right? because its possible we will need other assembler for arm
15:55:09r-kucertainly other assemblers for other more weird archs
15:55:23EXetoCI like abstractions
15:55:37AraqEXetoC: pfff
15:55:47r-kuso.. like adding it to nim.cfg somehow?
15:56:21Araqwell that comes out of the box when you treat it as a c compiler
15:56:31AraqC compilers can be configured already
15:56:51r-kuah, so picking different compiler based on extension
15:56:53r-kugot it
15:57:16EXetoCI wasn't referring to the low level nature of asm :p
15:57:20r-kuhowever.. doesnt it imply we would have to have different extensions for different archs (when different assemblers used)?
15:57:36*sparrk joined #nim
15:57:47Araqno you can override it in the config anyway
15:58:09r-kuwhat i mean is i think we would want one config that works on all archs
15:58:17Araqperhaps the config is not flexible enough but I think it is
15:58:25r-kuoh unless we can if/else based on environment in config
15:58:31Araqexactly
15:58:39Araqand we can
15:58:59sparrkSo I found my answer. I can do value.kind. Thanks for your help!
15:59:31Araqsparrk: ah that's what you're after
16:05:22r-kuerr Araq.. {.compile.} not even implemented yet or i just cant find it?
16:06:44*Onward__Euler joined #nim
16:06:48Araqnimc.html
16:06:51*Demos quit (Remote host closed the connection)
16:06:56Xer-ku: {. compile: "foo.c" .}
16:07:15Xer-ku: http://nim-lang.org/docs/nimc.html#additional-features-compile-pragma
16:07:47r-kuoh ok, ill keep looking for it
16:08:18r-kuahh right.. wCompile
16:09:39*Guest86655 quit (Quit: Leaving)
16:09:39*Onward_Euler quit (Ping timeout: 246 seconds)
16:09:50*vendethiel quit (Ping timeout: 250 seconds)
16:16:01*vendethiel joined #nim
16:16:35*coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
16:17:36*raza quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
16:17:58*raza joined #nim
16:18:15sparrkIs it possible to append to an existing set?
16:18:42sparrkOther than doing x = x + y
16:21:22EXetoCwith incl, as seen here: http://nim-lang.org/docs/manual.html#types-set-type
16:24:21sparrkAh, thanks, how did I miss that
16:32:17EXetoCI dunno d(:D)|<
16:38:39*zephyz quit (Ping timeout: 255 seconds)
16:40:25*bogen-work joined #nim
16:42:54*sparrk quit (Read error: Connection reset by peer)
16:53:22*Demos joined #nim
16:58:39*Onward_Euler joined #nim
17:00:34federico3some documentation on how to implement packet generation/parsing would be nice.
17:01:03federico3any pointers?
17:01:41Demoswhat level
17:02:03*Onward__Euler quit (Ping timeout: 255 seconds)
17:05:32federico3Demos?
17:05:39Demosyes?
17:06:00federico3"what level"?
17:06:40Demoslike are you trying to parse Application level headers or generate IP headers
17:06:46Demosor like maybe even link-level frames
17:07:09Demosmy recomendations for all but app level is "use BSD sockets"
17:08:44*filcuc joined #nim
17:09:35EXetoCor one of the libraries abstracting over BSD sockets and winsock
17:10:34EXetoCor could you actually re-implement that part of the stack with BSD sockets?
17:22:55federico3Demos: generating or parsing IP | UDP | ICMP, think Scapy
17:24:54Demoshow does scapy give you packets, I would kinda expect it to give you the raw data
17:25:55federico3Demos: yep - and it's awesome: http://www.secdev.org/projects/scapy/doc/usage.html#stacking-layers
17:26:35Demosit's a command line tool?
17:27:01*xcombelle joined #nim
17:27:07federico3no, from its own shell or the Python interpreter
17:27:16Demosugh, that's really annoying
17:27:21federico3why?
17:27:49Demosbecause we wrap sockets.h and if it was a native lib you could just copy the packet into some memory and look at it via the struct
17:27:55Demossame as when you sent it
17:28:29federico3*if* scapy was written in C? :)
17:28:36Demosright
17:29:07*elbow_jason quit (Ping timeout: 244 seconds)
17:29:21federico3nobody dared to implement it in C so far
17:30:12Demoswell yeah, the packet sniffer in C is just using sockets.h to sniff packets
17:30:14federico3but if somebody is interested in doing it in Nim...
17:30:21drewsremI'm assuming something went wrong with my c2nim wrapper-generation when porting an example over from C crashes whenever I try to free a returned ptr and run it through Valgrind...
17:30:28Demosanyway for scapy I'd just parse the strings that it outputs I guess
17:30:45Demospointer returned from what?
17:30:54federico3well, sniffing is the easy part - parsing or generating is the difficult one
17:31:10r-kuAraq: check out https://github.com/r-ku/Nim/commit/d9df1347e69a5fdb4dd4ce5b53f1cca6a5bcbdf4 and https://github.com/r-ku/Nim/commit/f7b7893d8fa1b8c4149a6d9ec142dd04b79afe80 and comment
17:31:21*zephyz joined #nim
17:31:38*bogen-work quit (Quit: leaving)
17:37:27drewsremDemos, xcb, xcb_wait_for_event, which expects me to free it, some reason it crashes Valgrind if I do, but it seems to run okay
17:37:49drewsremis free in Nim different from stdlib free?
17:39:00Demoshm, I don't know
17:39:04Demosit very well could be
17:39:10r-kuoh score. its so awesome when code that was written without any testing works on first try \o/ (coroutines on windows x64)
17:40:42drewsremah, no it isn't, so I'm pretty lost
17:46:08Demosvalgrind can be strange
17:46:14Demostry with -gc:bohem
17:46:16Demos?
17:46:30Demosor one of the other simpler GC options
17:47:01drewsremDemos, it only happens when I free the ptr tho, the GC shouldn't do anything? - I'm isolating it as much as I can now
17:47:29Demosright but if the GC is running maybe it triggers strange stuff in valgrind
17:47:31DemosI don't know
17:47:45EXetoC*boehm
17:47:51Demosthanks EXetoC
17:48:49drewsremDemos, nope, still crashes
17:52:30*sparrk joined #nim
17:55:53drewsremit's essentially this: http://ix.io/jLL
17:58:01Demosplease try and avoid {.header.}
17:58:18zaspardIs there anything that prevents me from doing something along the lines of `var observed_tables = initTable[string, Table]()`
17:58:21Demosbut that's not the problem
18:00:45drewsremwhoops
18:00:53drewsremit works now, let me try to find out why :)
18:01:27drewsremokay, so free is not stdlib free
18:01:58drewsremIt works with: http://ix.io/jLM
18:02:59drewsremDemos, fixed
18:03:03zaspardFigured it out, you need to type the nested table.
18:05:30*Onward_Euler quit (Ping timeout: 240 seconds)
18:07:16Demosthat must be wrapped someplace already
18:07:34Demosalso you probably don't need header for that
18:07:38drewsremDemos, I thought so too, it is in lib/system/ansi_c as c_free but it's not exported
18:07:53drewsremDemos, why shouldn't I use header?
18:08:04Demosbecause there's no need
18:08:09Demosand in can cause strange namespace issues
18:08:20Demosthe lib that free's in will be linked one way or another
18:08:38Demosand the importc will ensure the right call is generated
18:09:13drewsrembut that's because stdlib is always linked?
18:09:24drewsrem./lib/system/ansi_c.nim:proc c_free(p: pointer) {.importc: "free", header: "<stdlib.h>".}
18:09:26drewsremNim does it too :P
18:09:54*gmpreussner|work quit (Read error: Connection reset by peer)
18:10:44*gmpreussner|work joined #nim
18:12:23drewsremDemos, can you tell me about the namespace issues?
18:12:45drewsremNim manual also makes use of header-pragma, should this be changed?
18:12:49drewsremI just copied what I saw really
18:15:42drewsremCan I now comfortably wrap this ptr into a ref, tell it to call this stdfree-proc I imported and pass it around?
18:16:51Demosdrewsrem: yeah I know, I'm the one adding the warning but I got super busy and I can't exactly deal with the pr while at work :D
18:17:42drewsremDemos, oh, sure
18:18:52*vasher_ quit (Quit: Connection closed for inactivity)
18:20:53*strcmp1 joined #nim
18:40:39*brson quit (Remote host closed the connection)
18:44:17baabelfishI got to say this language is great
18:46:53baabelfishAraq: what kind of language background do you have?
18:46:56Demosbaabelfish: I know right! It's all in the details
18:47:13Demosand our bdfl has excellent taste
18:47:31baabelfishThis fills my c++ tmp cravings so well
18:47:59*doxavore joined #nim
18:49:18baabelfishBuild system of D, erase of js or python safety of c++ at least
18:49:23*sparrk quit (Read error: No route to host)
18:49:26baabelfishEase*
18:50:55*elbow_jason joined #nim
18:53:50Demosyeah, it definitely feels like there's way less friction in nim, I can opt into features as I grow my project
18:55:06*wtw joined #nim
19:21:47*polde quit (Ping timeout: 240 seconds)
19:29:31*filcuc quit (Ping timeout: 256 seconds)
19:31:23*xcombelle quit (Remote host closed the connection)
19:31:50drewsremIs it discouraged to use define your own exceptions as "ref objects of Exceptions" and then raise them via constructor "raise MyRefObjException(msg: "my error message")" ?
19:32:09drewsreminstead of using this awkward newException template
19:33:02drewsremI'm trying to use exceptions that carry additional fields beyond the msg-field and newException clearly isn't suited for that, or is this bad practice?
19:40:43EXetoCmaybe newException was added before ref could be applied to types. not using newException is fine imo
19:42:00EXetoCnewFoo is the convention for ref constructors, and initFoo is the convention for value types
19:42:35EXetoCI usually define a "fail" proc which takes a msg parameter and possibly other parameters as well
19:43:17drewsremEXetoC, a fail proc?
19:43:44*sparrk joined #nim
19:46:36EXetoCjust a proc which raises the exception type defined in the current module. that might not be a good idea though because more types might appear later
19:47:46zaspardI'm having trouble with nesting sets into a table. Is this something that others have done, or is it currently broken like nested Tables ( https://github.com/nim-lang/Nim/issues/2722 )
19:47:47drewsremEXetoC, gotcha, thanks
19:48:31*X67r joined #nim
19:49:40EXetoCI like the "exception + error code" approach though
19:50:00*nande joined #nim
19:52:59DemosI like exceptions and sometimes error codes
19:53:11Demosusually I just want my app to crash when smthing goes wrong
19:55:39drewsremhmmm... the _ as a placeholder for tuples seems quite restricted? - I can only do "var _, foo = bar()" but of course if I want to do the same thing again I can't because I'd redefine foo, but when I drop the var and just do an assignment "_, foo = bar()" the placeholder errors out as not valid syntax
19:56:52drewsremah whoops, this isn't Go and Nim doesn't have placeholders like that
19:57:05drewsremFor some reason I thought it did ...
19:57:50EXetoC_ can be used for that
19:59:11drewsremEXetoC, then I currently can't construct a tuple: http://ix.io/jLV
19:59:16EXetoCbut don't you need parentheses?
19:59:33drewsremah
19:59:47drewsremthanks, that was it
19:59:48EXetoCnot according to your snippet
20:00:03EXetoCit doesn't actually compile?
20:00:07drewsremit does
20:00:17drewsremit's supposed to be "var (_, p) = bar()"
20:01:10*dom96_ joined #nim
20:02:02EXetoCright
20:02:24EXetoCI don't really care for that "var x, y = 1" syntax
20:02:27drewsrembut I still can't reassign it / do it more then once: http://ix.io/jLW
20:03:52dom96_'var foo' is not valid syntax
20:04:03drewsrem...
20:04:14EXetoCdrewsrem: it has been requested
20:04:29drewsremdom96_, that changes the error to "undeclared identifier: '_'"
20:05:19drewsremEXetoC, ah that makes sense
20:05:49dom96_drewsrem: bug report
20:06:05EXetoChttps://github.com/nim-lang/Nim/issues/2421
20:10:02*wuehlmaus quit (Quit: Lost terminal)
20:11:11drewsremIt would then be nice if a proc returning a tuple could know if the caller actually cares for each element in the tuple and optimize accordingly, i.e. if the caller doesn't care an error field, the proc does no error checking etc., but IIRC the type-system wouldn't allow for that?
20:11:34drewsremI guess it's not really a type-system issue
20:16:27*wuehlmaus joined #nim
20:20:58*Trustable quit (Remote host closed the connection)
20:21:00federico3Demos: this thread is what I was looking for :) http://forum.nim-lang.org/t/1443
20:22:59*raza quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
20:27:14VarriountAraq: Finally, the MSDN Scraper is finished
20:29:41EXetoCwhat's it for exactly?
20:30:59Araqdrewsrem: that can be done with a TR macro
20:32:30drewsremAraq, oh nice, I'll look into it
20:36:20drewsremAraq, I saw just now that proc free in lib/system isn't the same as c's free from stdlib and I had some issues because I thought it was (Using system-free crashed Vallgrind). Is this expected or have I maybe found a bug?
20:37:33Araqthe free in the stdlib isn't even called "free". why do you think that is?
20:38:04drewsremIn Nim?
20:38:43Araqwait a sec
20:38:50Araqwe do have system.free? wtf?
20:38:51EXetoCthere is a free now. I dunno if I added that
20:38:56drewsrem./lib/system.nim: proc free*[T](p: ptr T) {.inline, benign.} =
20:39:14Araqyeah, well that's an oversight, we need to rename this asap
20:39:17EXetoCwhen I added the other procs related to memory management (typed overloads)
20:39:50Araqyeah, I remember
20:39:56EXetoCin what way does it differ? or is it simply implementation defined?
20:40:11drewsremIt just uses dealloc I think
20:40:18Araqwell it doesn't use C's memory manager, it uses dealloc
20:41:47drewsremThat messed me up good today, when things have the same name but are different
20:42:07drewsremBut shouldn't there be a cfree or something that just importc's free?
20:42:20EXetoCI think it was because "ptr T" is implicitly converted to "pointer", or whatever the issue was
20:48:56EXetoCbut overloading was involved too. I don't think I created an issue for that
20:49:30drewsremIs there an easy way to "make" a ptr into a ref, define my own destructor and pass it around?
20:56:32Araqdrewsrem: no, you need to start with a 'ref' and pass it as a ptr to C-land
20:56:49Araqso that it has a proper GC header etc
20:57:49drewsremI see
20:58:12*jszymanski quit (Quit: computer sleeps...)
20:59:43*polde joined #nim
21:03:19*Matthias247 joined #nim
21:05:29sparrkHow does one handle the general case of using functions from an inherited type? For example, I defined my own seq and now I want to use the .add proc, but instead it give me the error `Error: type mismatch: got (seq[FieldType], FieldType)\nbut expected one of:\nsystem.add(x: var seq[T], y: T)` (snipped)
21:05:34VarriountAraq: My goodness... There's over a thousand output files.
21:06:04Varriountsparrk: How did you define your own sequence?
21:06:44sparrkvar field_types: seq[FieldType] # and below: field_types = @[]
21:07:37Varriountsparrk: Uh, that should work. Could you post your code on gist or some other paste website?
21:07:40EXetoCis it a "var" in your code?
21:08:00EXetoCand it's an instantiation rather than inheritance
21:14:22*Varriount quit (Ping timeout: 248 seconds)
21:16:37*polde quit (Ping timeout: 256 seconds)
21:18:43sparrkVarriount: sorry for the delay / poor code quality. I'm still in my first couple days of learning Nim http://paste.ofcode.org/TqQTwnYnzj3yRX3iDYKZXs
21:22:08EXetoCit's not a sequence so it can't work
21:22:13*Demos_ joined #nim
21:22:42EXetoCbut you can define an overload of add for your type
21:25:32sparrkWhat is not a sequence? field_types?
21:25:50*Demos quit (Ping timeout: 264 seconds)
21:26:06sparrkHow does one make a sequence of objects and get all the normal sequence procs to work then?
21:28:09EXetoCseq is a generic type that expects a type parameter, which corresponds to the element type, so seq[SomeElemType] is what you want
21:28:43EXetoC.eval
21:30:00EXetoChttps://nim-by-example.github.io/seqs/
21:31:35EXetoCtype annotations would be nice to have in tutorials, but "a" is of type seq[int]
21:32:05EXetoCjust that it has been omitted in that example. "var a: seq[int] = @[1, 2, 3]" works too
21:38:00sparrkAh, so I understood that for types outside of the parameter section of the proc
21:38:16EXetoCand then you can do "a.add(1)", but "a.add('b')" will of course not work
21:38:18sparrkbut it didn't occur to me to use var seq[MyType]
21:38:31sparrkin the parameters list
21:38:48sparrkThank you very much for your help.
21:40:46EXetoCthe signature can be found in the documentation for the system module, if you want to know why it works like that
21:41:56EXetoCnp
21:48:19*Ven joined #nim
21:52:39*Ven quit (Ping timeout: 246 seconds)
22:03:34*Demos_ quit (Remote host closed the connection)
22:07:49*Demos joined #nim
22:10:30*sparrk quit (Quit: Leaving)
22:24:31*Demos quit (Remote host closed the connection)
22:24:49*mt_laptop joined #nim
22:28:16*brson joined #nim
22:31:17*Jesin joined #nim
22:31:35*mt_desktop joined #nim
22:37:46*gyeates joined #nim
22:44:26*Matthias247 quit (Read error: Connection reset by peer)
23:03:38*elbow_jason quit (Remote host closed the connection)
23:11:30*gyeates quit (Ping timeout: 246 seconds)
23:19:08*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
23:23:12*gyeates joined #nim
23:32:07*doxavore quit (Quit: I said good day, sir.)
23:37:27*doxavore joined #nim
23:53:55*Jesin quit (Quit: Leaving)
23:55:50*vendethiel quit (Ping timeout: 260 seconds)