<< 14-03-2015 >>

00:00:17*banister quit (Ping timeout: 250 seconds)
00:04:01*johnsoft joined #nim
00:05:49AszarshaHello everyone. I'm slowing introducing myself to Nim by using it for a few things at work. Can anyone tell me if this code (https://gist.github.com/Aszarsha/32c68e654d384e363c59) is idiomatic ? If not, what should I change ? Thank you.
00:08:07dom96Aszarsha: don't put spaces after ( and before )
00:08:47dom96var files: seq[File] = @[]
00:09:05dom96do put spaces before and after &
00:09:47AszarshaHo, yes, those spaces. They have been my personal signature for years :)
00:09:47AszarshaThank you !
00:10:03dom96I think the rest is fine.
00:10:25epicherohaha FASTA, i think nim is a good choice for that actually
00:11:50*reem_ quit (Remote host closed the connection)
00:12:00AszarshaOne thing that I tried, is using the "for index, value" idiom for the lines and tokens, but was unable to do so. I guess it works for lists but not generator ? Is there a generator that does it ? I read the last few days of talk and at some point the case for return type overload was made. I think this overload (value vs. index,value) in for loop is a good candidate.
00:12:11*irrequietus quit ()
00:12:23def-Aszarsha: by making "let inToken = split(...)" you create a seq, if you do "for token in split(...)" instead it's an iterator, which will take less memory and be faster
00:13:19Aszarshadef-: Yes, this is what I though, but then I lose the automatic index in the for loop, which is one more point of error...
00:13:52AszarshaI searched for an generator/iterator withCount (or something similar) that would return the pair index,value but couldn't find it.
00:14:13AszarshaNeither could I find a generator/iterator for the lines of the file
00:14:31def-pairs and lines iterators in system
00:14:39def-but pairs only works with seqs and related, not iterators
00:15:54*banister joined #nim
00:16:13def-i guess a pairs iterator that wraps other iterators would be a good idea
00:16:34Aszarshadef-: ha ! I'll try to write one then :)
00:17:28AszarshaIs "pairs" really a good name though ? Somehow, it doesn't look obvious that pairs would return the index
00:17:34*reem joined #nim
00:18:29*johnsoft quit (Ping timeout: 250 seconds)
00:18:47*johnsoft joined #nim
00:21:27EXetoC"for i, x in stuff" invokes pairs. you need to invoke it explicitly?
00:26:05*epichero quit ()
00:26:06*reem quit (Remote host closed the connection)
00:26:19*epichero joined #nim
00:27:58flaviuI like python's "enumerate" btw
00:29:57*arnetheduck joined #nim
00:30:24*reem joined #nim
00:44:03AszarshaEXetoC: If I don't, I get: "Error: wrong number of variables"
00:45:15flaviuyep, invoking an iterator directly vs invoking it explicitly.
00:45:26flaviuerr, implicitly
00:45:32AszarshaThis is weird...
00:45:33Aszarshafor line in file.lines(): works
00:45:33Aszarshafor lineNum, line in file.lines(): Error: wrong number of variables
00:45:33Aszarshafor lineNum, line in pairs( file.lines() ): Error: undeclared identifier: 'lines'
00:47:04flaviufor line in file.lines() invokes the lines() iterator, which returns "string".
00:47:40flaviufor lineNum, line in file.lines() invokes the lines operator, which returns "string". The for loop is asking for a "tuple[a:..., b: ...]"
00:48:07AszarshaWell, I guess the problem is that there is no pairs( var it: iterator ) right (I'm not sure of the syntax) ? In that case, the error message is weird, no ?
00:48:13flaviuI'm not sure why "for lineNum, line in pairs( file.lines() )" gives that error, it'd expect "Error: undeclared identifier: 'pairs'"
00:49:22flaviuYes, there is no pairs that takes an iterator.
00:49:53flaviuI'm not really sure of the syntax myself.
00:51:55EXetoCjust count manually then
00:52:13Aszarsha Well, this is what I've been doing. :)
00:55:16def-the error with "undeclared identifier: 'lines'" is indeed weird
00:56:34flaviu.eval let iter = lines("/etc/passwd")
00:56:38Mimbusflaviu: eval.nim(3, 16) Error: expression 'lines' cannot be called
00:56:46flaviuright, that's an old compiler.
01:02:44flaviu.eval let iter = lines("/etc/passwd")
01:02:44Mimbusflaviu: /bin/sh: nim: command not found
01:04:39*saml_ joined #nim
01:04:50flaviu.eval let iter = lines("/etc/passwd")
01:04:51Mimbusflaviu: eval.nim(3, 16) Error: undeclared identifier: 'lines'
01:04:52*chrisheller quit (Remote host closed the connection)
01:09:20Aszarshahttps://gist.github.com/Aszarsha/32c68e654d384e363c59 I can't get it to compile. nimrod.vim + syntastic tells me "internal error: transformVarSection" (but I expect nimrod.vim to be based on an old version of the compiler ?). the compiler (devel) still tells me "Error: undeclared identifier: 'lines'"
01:13:07EXetoCit uses whichever version is installed
01:15:49*banister quit (Ping timeout: 264 seconds)
01:15:52Aszarshawell, I get two different outputs from the command line compiler and nimrod.vim
01:16:07flaviuAszarsha: nimrod.vim tells the compiler not to stop when it hits an error.
01:16:24AszarshaI could make the program to compile by specifying {.inline.} for the parameter iterator
01:17:32Aszarshaflaviu: but the compiler failed at a line 14 while nimrod.vim reported an internal error at line 6
01:18:01Aszarshais the parsing multi-pass ?
01:18:24flaviuNo, but there's a lot more to a compiler than parsing.
01:18:31Aszarshasure
01:19:07reactormonkAszarsha, I'm not sure if iterators are first-class yet
01:19:40flaviuthey are first class, but they are confusing to use (also somewhat buggy)
01:19:43Aszarshareactormonk: the manual says closure iterator are, while inline iterator can only be passed to other inline ones
01:20:39Aszarshais there a way to specify inline and closure iterator for a parameter, something like {.inline. || .closure.} ?
01:21:21AszarshaI can understand that an inline iterator can only be passed to another inline iterator, but there is no such restriction for a clorure iterator, right ?
01:21:36flaviuwell, you can separate pragmas by a comma, but you can't change code you don't control (the stdlib in this case)
01:22:32Aszarshawell, I'll make a pull request for pairs(it: iterator) and mpairs(it: iterator) at least :)
01:23:08flaviuDid you get it to work?
01:23:14reactormonkAszarsha, if it works, sure. Don't forget tests in tests/system/
01:23:43Aszarshayes it does, with {.inline.} parameter at least, I'll try with a {.closure.} one
01:24:08reactormonkAszarsha, also if it works, you can kick the other pairs iterators if you yours is more general and also works for these cases
01:24:16reactormonkmight not for all of them though
01:25:56AszarshaI see pairs (and mpairs) for openArray, array, seq, string, and cstring in lib/system.nim. Are any of those auto convertible to iterator ? Is there such auto conversion in the first place ?
01:26:32reactormonkthey are an iterator
01:29:08Aszarshahttps://gist.github.com/Aszarsha/548ad265c2bed02fb675 All iterators have exactly the same code as the first, but the one for array. Is there any reason ?
01:29:35*darkf joined #nim
01:29:56reactormonkAszarsha, what's different in the array?
01:32:22*gsingh93 quit (Ping timeout: 240 seconds)
01:33:33Aszarshareactormonk: the use of low and high, but the infinite loop and break looks overkill. wouldn't for i < len(a); suffice with index being i+low(a) ?
01:39:27reactormonkAszarsha, high(IX) can be statically determined, and is simpler on the type system than len(a)
01:41:01EXetoCif it's an array then surely len will be statically known
01:42:16AszarshaAnyway, the code works, I better not touch it since it would need to be different (i+low(IX)) anyway :) Thank you for the help
01:44:50reactormonkAszarsha, you only need the items iterator for pairs?
01:47:10*MyMind joined #nim
01:47:51*szatz joined #nim
01:47:56*gsingh93 joined #nim
01:47:57*BlaXpirit_ quit (Quit: Quit Konversation)
01:48:34EXetoCAszarsha: I think high is just for convenience, and low is necessary because the index might not start at 0 for arrays
01:48:59*Sembei quit (Ping timeout: 245 seconds)
01:50:37AszarshaWell, indices not starting a 0 is very... Let just say that Dijkstra would disagree :)
01:52:22EXetoCthe user gets to decide for arrays, but the occurrence of non-zero indexing is probably rare
01:53:56EXetoCit's only for arrays so it's statically known
01:54:11szatzHey, all. Not at all familiar with nim but I decided to browse the source a little. I'm not confident enough to send a PR myself (or know if this is really a problem), but line 36 of the following seems to be missing a comma after "T": https://github.com/Araq/Nim/blob/devel/compiler/canonicalizer.nim
01:54:28VarriountMeep
01:57:36flaviuszatz: Good catch, I have no idea how that got in. It doesn't even compile!
01:57:41AszarshaThe test suite fails for tdialogs.nim [reNimcCrash], twalker.nim [reNimcCrash], trecinca.nim [reMsgsDiffer], trecincb.nim [reMsgsDiffer], tfailedassert.nim [reOutputsDiffer], main.nim [reNimcCrash], trawsockets.nim [reNimcCrash], it is still running, and a few of them are [reIgnored]. Is this expected ? This is devel from 15 minutes ago (2f44729).
01:58:12flaviuunfortunately the test suite is in poor shape.
01:58:28*rzzz quit (Ping timeout: 255 seconds)
02:00:31szatzflaviu: No sweat. Pure chance that I saw it at all.
02:05:24*chrisheller joined #nim
02:09:57*chrisheller quit (Ping timeout: 252 seconds)
02:18:04AszarshaI extract the exact pairs function that enabled me be compile my program and put it in lib/system.nim. Recompiled the compiler. And I get the same error as before: Error: undeclared identifier: 'lines'. If I put my function at the top of my program, it works. What am I doing wrong ?
02:27:35flaviuwhat happens when you add {.closure.} to the lines iterator?
02:29:08*mal`` quit (Ping timeout: 245 seconds)
02:36:41*mal`` joined #nim
02:38:43*szatz quit (Quit: Page closed)
02:41:05*rzzz joined #nim
02:41:40*Menche left #nim ("Leaving")
02:41:43*banister joined #nim
02:44:18*chemist69_ joined #nim
02:47:21*gsingh93 quit (Ping timeout: 252 seconds)
02:47:21*chemist69 quit (Ping timeout: 252 seconds)
02:56:36Aszarshaflaviu: I'll try that tomorrow, thank you
02:57:08Aszarshagood night all, thanks for your help
03:06:38reactormonkAraq, canonizer?
03:06:51*chrisheller joined #nim
03:07:34reactormonkhttps://en.wikipedia.org/wiki/Graph_canonization <- that stuff?
03:11:11*chrisheller quit (Ping timeout: 252 seconds)
03:13:43*pregressive joined #nim
03:13:46*chrisheller joined #nim
03:31:22*arnetheduck quit (Ping timeout: 240 seconds)
04:07:20*pregressive quit (Remote host closed the connection)
04:12:49*gsingh93 joined #nim
04:15:43*chrisheller quit (Ping timeout: 252 seconds)
04:34:07*chrisheller joined #nim
04:45:57*chrisheller quit ()
05:05:45*TEttinger quit (Quit: Leaving)
05:13:35*reem quit (Ping timeout: 246 seconds)
05:16:23*bitcraft__ joined #nim
05:19:37*bitcraft_ quit (Ping timeout: 264 seconds)
05:25:03*reem joined #nim
05:25:32*Varriount quit (Read error: Connection reset by peer)
05:31:31*saml_ quit (Quit: Leaving)
05:47:22*gsingh93 quit (Ping timeout: 245 seconds)
06:00:34*banister quit (Ping timeout: 256 seconds)
06:08:36*reem quit (Remote host closed the connection)
06:16:29*reem joined #nim
06:17:02*gsingh93 joined #nim
06:30:05*TEttinger joined #nim
06:45:11*reem quit (Remote host closed the connection)
06:45:49*reem joined #nim
07:10:17*reem quit (Remote host closed the connection)
07:15:51*reem joined #nim
07:25:42*untitaker quit (Ping timeout: 245 seconds)
07:25:45*reem quit (Remote host closed the connection)
07:26:17*reem joined #nim
07:31:09*untitaker joined #nim
07:36:20*reem quit (Remote host closed the connection)
07:39:04*gsingh93 quit (Ping timeout: 265 seconds)
07:49:19*epichero quit ()
08:05:51*reem joined #nim
08:06:23*epichero joined #nim
08:18:57*BlaXpirit joined #nim
08:25:40*epichero quit (Read error: Connection reset by peer)
08:26:16*epichero joined #nim
08:34:48*epichero quit (Read error: Connection reset by peer)
08:35:15*epichero joined #nim
08:40:54Araqszatz, reactormonk this file is not yet part of the compiler ;-)
08:41:02AraqNim would have caught this typo
08:43:40*epichero quit (Remote host closed the connection)
08:43:58*epichero joined #nim
08:51:46ekarlsodom96: nope, that crashes too :(
08:55:05*^aurora^ joined #nim
09:04:43*reem quit (Remote host closed the connection)
09:17:11*reem joined #nim
09:18:47*gokr quit (Quit: Leaving.)
09:24:04*davidhq joined #nim
09:30:08*xificurC joined #nim
09:35:31*BlaXpirit_ joined #nim
09:35:39*epichero quit (Remote host closed the connection)
09:37:11*rzzz quit (Ping timeout: 246 seconds)
09:37:17*BlaXpirit quit (Ping timeout: 252 seconds)
09:52:59*reem quit (Remote host closed the connection)
09:59:52*Matthias247 joined #nim
10:02:16*reem joined #nim
10:02:44*bcinman quit (Quit: My Mac has gone to sleep. ZZZzzz…)
10:07:24*reem quit (Remote host closed the connection)
10:08:32*reem joined #nim
10:09:00*rzzz joined #nim
10:13:27*rzzz quit (Ping timeout: 250 seconds)
10:17:21*reem quit (Remote host closed the connection)
10:19:52*reem joined #nim
10:21:16*reem quit (Remote host closed the connection)
10:27:45*reem joined #nim
10:36:32*epichero joined #nim
10:39:13*rzzz joined #nim
10:41:22*epichero quit (Ping timeout: 255 seconds)
10:43:38*rzzz quit (Ping timeout: 246 seconds)
10:43:51*reem quit (Remote host closed the connection)
10:51:08*reem joined #nim
11:10:59*Matthias247 quit (Read error: Connection reset by peer)
11:32:53*reem quit (Remote host closed the connection)
11:39:21*rzzz joined #nim
11:43:47*rzzz quit (Ping timeout: 252 seconds)
11:44:19*Trustable joined #nim
12:07:13*epichero joined #nim
12:12:01*epichero quit (Ping timeout: 252 seconds)
12:18:00Aszarshahi everyone. ok, so my problem remains, I added a function to lib/system.nim, recompiled nim, and I still can't use the function (it's as if it did not exists). any idea ?
12:18:21Araqadd a star?
12:18:44Araq(an "export marker")
12:19:19ekarlsoAraq: is there goroutines or so in nim ?
12:19:52Araqekarlso: we have spawn and coroutines in the form of "closure iterators"
12:20:15ekarlsoAraq: spawn does a new thread I guess ?
12:20:21Araqno, it doesn't
12:20:34AszarshaAraq: it's there already (I'm trying to write a pairs function for iterators, and basically copyed the pairs function that were already there)
12:20:36Araqit uses the thread pool
12:20:47dom96ekarlso: try to figure out why it crashes
12:20:57ekarlsodom96: meh, I did :/
12:21:06ekarlsodom96: should I try in gdb ?
12:21:12dom96perhaps
12:21:26ekarlsolemme give it a shot !
12:25:00ekarlsodom96: so, how to get useful info again in gdb :D
12:25:47dom96hrm, it would be nice if you could reproduce it outside your app
12:25:54dom96i.e. in asyncproc's isMainModule section
12:25:58dom96then I could take a look
12:26:14ekarlsodom96: tmate + vim ?: )
12:27:16dom96would prefer to have it running on my PC :P
12:27:22ekarlsodom96: :p
12:27:24ekarlsosureo k
12:27:31*arnetheduck joined #nim
12:28:15def-ekarlso: compile with --debuginfo --linedir:on
12:28:42def-Aszarsha: i tried that as well, i think there's another problem there.
12:29:41*Etheco quit (Read error: Connection reset by peer)
12:30:52Aszarshahttps://gist.github.com/Aszarsha/32c68e654d384e363c59 I described what I did exactly as comments in there
12:32:03def-i guess it's a problem with lines or inline iterators, i don't know
12:33:03ekarlsomeh dom96 I can't get it to blow up using just asyncproc outside there :/
12:34:39AraqAszarsha: you cannot use inline iterators like this (and the compiler is way to lax about that for now)
12:34:50Araqthey are inline, you cannot pass them around
12:34:54ekarlsodom96: tmate ? :d
12:37:04AszarshaAraq: The manual says: "Inline iterators are second class citizens; They can be passed as parameters only to other inlining code facilities like templates, macros and other inline iterators." Even if lines is not inline, the only (documented) restriction if for passing inline iterator around, not closure one (which lines is, right ?)
12:37:07dom96ekarlso: ok
12:37:50Aszarshais it an error in the doc then ? I hope not, because the use case pairs(lines) seems pretty frequent to me
12:39:20*rzzz joined #nim
12:39:54Aszarshafurthermore, split (which I use a few lines below) is also a closure iterator (well, default type anyway) and it works there
12:41:44*^aurora^ quit (Quit: Leaving.)
12:41:49AraqAszarsha: I don't know yet if these bugs are easy enough to fix or I'll change the manual
12:43:52*rzzz quit (Ping timeout: 240 seconds)
12:44:32AszarshaAraq: but the weirdest thing, really, is that if I declare those functions (inline pairs and mpairs for inline iterators) at the top of my extractFasta.nim file, everything works then! it doesn't only when I put them in lib/system.nim
12:46:12Aszarshawhich is even weirder considering that I declare them as taking an inline iterator and neither lines nor split are...
12:52:12ekarlsotmate is so nice : p
12:58:49dom96agreed
13:01:52dom96Araq: It seems that threads have a bug when it comes to handling exceptions
13:12:48*rzzz joined #nim
13:21:35*banister joined #nim
13:24:48Araqdom96: maybe, but did you read the manual?
13:25:03Araqan uncaught exception shuts down the whole process
13:25:20dom96well, the exception is caught
13:25:40dom96it's doing something strange in the except block though
13:25:52dom96it crashes after it is executed AFAICS
13:29:04Araqdom96: well report it then. :P
13:29:21dom96Guess I need to try to reproduce it first
13:39:18*banister quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
13:51:08*zipR4ND joined #nim
13:51:36*banister joined #nim
13:53:15dom96I think it's more likely that I am doing something dangerous with threads
13:53:20dom96because threadanalysis complains
13:53:47dom96Araq: thoughts? https://gist.github.com/dom96/f208a9dc34fd6c1909c3
13:54:03dom96Am I allowed to put channels inside an array?
13:58:17*banister_ joined #nim
13:58:52*banister quit (Ping timeout: 252 seconds)
13:59:30*banister joined #nim
14:02:30Araqyeah but the compiler has a bug
14:02:50*banister_ quit (Ping timeout: 246 seconds)
14:06:27dom96ahh ok
14:06:37dom96well then I don't know why there is a crash when an exception happens in that thread
14:09:33Araq AsyncExecutor* = ref object
14:09:35Araq threads: array[1024, TThread[int]] # seriously?
14:11:55*zipR4ND quit (Ping timeout: 252 seconds)
14:12:52dom96Araq: :P
14:12:59EXetoCstrength in numbers
14:14:54dom96Araq: care to give an alternative implementation?
14:16:18Araqdon't put it into a 'ref'
14:17:06dom96Is TThread required to be on the stack?
14:18:04Araqno, in a global
14:20:47dom96ok
14:20:50dom96ekarlso: ^
14:21:29ekarlsowhat's wrong with that ? :/
14:24:27dom96there are too many of these little things which the compiler does not enforce at all for threads
14:25:12*zipR4ND1 joined #nim
14:27:09Araqwell in theory TThread is allowed in a 'ref' but it has never been tested
14:27:53Araqand we created 'spawn' to get rid of explicit TThread creation
14:28:01ekarlsoAraq: hmm, would it be possible to add like infinite loop check to the compiler ? :D
14:28:07ekarlsolike rust has :P
14:28:35Araqekarlso: sure, it's not hard
14:28:47ekarlsoit would be nice to have for the playsite
14:28:55ekarlsothe loop protection stuff is weird
14:28:59Araqbut it doesn't solve your problem
14:29:11ekarlsoAraq: what is my problem then ? multiple users ?
14:29:14Araqyou need proper sandboxing as provided by the OS anyway
14:29:25ekarlsoAraq: I got that with playpen
14:29:41Araqwhat's the problem then?
14:29:52ekarlsobut for some weirdo reason the timeout set gets ignored or whatever when there's a while loop
14:30:02ekarlsodunno if it's due to too much output or what :/
14:30:46Araqwell I'm not willing to work on features only required to workaround playpen's bugs
14:30:55ekarlsoAraq: meh-,,-
14:31:10ekarlsoi tried to remedy that by killing the playpen process when output exceeds a maximum of lines but the compiler process is still left :p
14:31:57ekarlsowondering if LXC would be better :/
14:32:42ekarlsoAraq: any suggestions ? :p
14:33:35*reem joined #nim
14:36:17*pregressive joined #nim
14:38:04*reem quit (Ping timeout: 255 seconds)
14:38:57Araqjust write a script that kills any process named 'nim_<id>' after 5 minutes
14:39:53ekarlsoAraq: hmmm
14:40:11ekarlsoI guess I could register a async thing no that runs every n seconds or smth ? :D
14:43:31*rkj-b joined #nim
14:45:49AraqI never expected to say this but:
14:46:00Araqstop doing *everything* in Nim
14:46:13EXetoCekarlso: and you? do you write nim code for $$ yet?
14:46:17Araqin particular a watchdog HAS to be in separate process
14:46:26Araqstop with async and threads
14:46:50Araqit's pointless anyway since you need to run *processes* anyway
14:47:24Araquse a decent server that supports scgi or cgi and then keep it simple
14:49:05Araqagain, serving more than a single user is a solved problem. Even the CGI protcol that's been invented right after the byte can do that.
14:50:32Araquse apache or nginx or *any* server out there and call it day please
14:50:59*banister_ joined #nim
14:51:03*banister_ quit (Max SendQ exceeded)
14:51:12EXetoCwhat does the program do?
14:52:07*banister quit (Read error: Connection reset by peer)
14:52:07*banister_ joined #nim
14:52:11*banister_ quit (Max SendQ exceeded)
14:52:21AraqEXetoC: it takes a Nim snippet and compiles and runs it via the nim compiler
14:53:59*banister joined #nim
14:54:11*banister quit (Max SendQ exceeded)
15:00:56dom96Araq: CGI is old and deprecated
15:01:32dom96what we need is a proper asyncproc implementation
15:01:40flaviudom96: I see no mention of "deprecated" on http://en.wikipedia.org/wiki/Common_Gateway_Interface
15:06:17Araqdom96: we don't need a proper asyncproc implementation for ekarlso's use case
15:06:31*banister joined #nim
15:07:02*^aurora^ joined #nim
15:07:06Araqthreads and async are about removing the overhead of multi-processing
15:07:27Araqbut that's what he cannot avoid at all
15:07:29dom96ekarlso will need to rewrite quite a lot of things to use CGI
15:07:47dom96but sure. It may work better.
15:08:01*epichero joined #nim
15:09:11dom96I still think the threading issues deserve further investigation though
15:11:35ekarlsoEXetoC: nope :(
15:11:46EXetoCthat sucks
15:12:26*epichero quit (Ping timeout: 246 seconds)
15:13:00*matkuki joined #nim
15:13:54NhanHIn procedure, did the behaviour that return the `result` variable by default changed?
15:14:06NhanHright now, it seems like without explicitly return, the result variable isn't returned
15:15:27dom96NhanH: nope, that didn't change.
15:15:28*yibter joined #nim
15:15:49flaviuNhanH: Are you shadowing result?
15:16:07flaviuonly the compiler-generated result gets impciltly returned.
15:16:37NhanHhere is the gist for the proc: https://gist.github.com/anonymous/a1037b563d3dd381cf15
15:16:40NhanHis that shadowing?
15:16:51ekarlsoAraq: still I wonder how that would help with playpen issues ...
15:16:54ekarlsofor isolation
15:17:03flaviuNhanH: Yep. Just delete line 2 completely.
15:17:12NhanHflaviu: okay thanks!
15:17:44flaviuNhanH: Also, I don't think those type parameters are doing what you expect.
15:17:46fowlAraq, if i have a when block inside an object def it causes getType to return an empty tree
15:18:11flaviudo s/, float]/]/
15:19:15NhanHyeah the first float is redundant
15:19:29NhanHoriginally it was proc `*`* [r, T] (a,b : array[r,T]): T
15:19:48*gokr joined #nim
15:19:54NhanHbut I then need to initialized the generic result somehow ... and I don't know how yet, so I changed it to float
15:20:01flaviuyes, but using "float" instead of "T" makes no difference.
15:20:34flaviuyou're just using a generic named "float"
15:20:39*banister quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
15:20:44NhanHyeah that's true
15:21:11EXetoCis shadowing result supposed to be allowed?
15:21:31flaviuEXetoC: Yes, but it's a warning in the latest devel.
15:21:52EXetoCthat's good enough
15:22:27fowlshould be an error imo
15:24:13EXetoCI'd prefer that actually
15:27:07EXetoCfowl: you asked me some time ago about creating a new project, right? a game was it?
15:29:06*darkf quit (Quit: Leaving)
15:29:24Aszarshaif I were to take a look at this issue: https://github.com/Araq/Nim/issues/2212, where should I start looking ?
15:30:33AraqAszarsha: name mangling for the C(++) backend is done in compiler/ccgutils.nim
15:30:45AszarshaAraq: ok, thank you :)
15:31:10reactormonkAszarsha, I guess both variables are mangled to lowercase, gotta change that
15:32:21dom96fowl: as long as there is a way to override that error
15:32:23EXetoChas anyone attempted to bind Qt yet?
15:32:28dom96some code depends on this shadowing
15:33:07EXetoCdeprecate that functionality then
15:33:24def-EXetoC: I've only seen the qml stuff
15:33:24fowlsince it has to be returned manually i dont believe that
15:33:47EXetoCdef-: can one do with just qml?
15:33:53def-http://forum.nim-lang.org/t/692
15:34:06EXetoCand the associated initialization routines of course
15:35:26EXetoChopefully it'll be stable somewhere around 1.0
15:36:18EXetoCis the realistic ETA < 2016? :-)
15:37:48ekarlso:P
15:40:02*epichero joined #nim
15:40:16Araqfowl: want to write a 'print' macro that is as close to python as reasonable?
15:40:52dom96Araq: isn't that just echo but with spaces between params?
15:40:53EXetoCI hope I'm not annoying anyone. I'm not that impatient actually :p
15:41:51AraqEXetoC: hrm?
15:42:10Araqdom96: python's print is full of special syntax
15:42:21Araqbut I guess they removed all that for python 3
15:42:24BlaXpirit_you mean "was"?
15:42:35dom96Araq: example?
15:42:52Araqprint >>stderr, foo, endl=" "
15:42:59EXetoCgradha's string interpolation macro would come in handy too
15:43:04Araqor similar, never used it
15:43:37BlaXpirit_there is no reason to use it
15:44:13dom96somebody should finish this printf macro https://github.com/Araq/Nim/issues/1152
15:44:30BlaXpirit_why?
15:44:46EXetoCechof?
15:44:47BlaXpirit_just get good string formatting
15:44:58BlaXpirit_and there does seem to be a good library
15:45:00def-I also think that we need a nice way of printing complex data, but i'm not sure if we need to emulate C or Python
15:45:16EXetoCstrfmt?
15:45:20BlaXpirit_strfmt
15:45:32def-*in the standard library
15:45:33AraqBlaXpirit_: btw I plan a -d:progress switch. if enabled negative slices fail at compiletime or we cannot detect that, at runtime
15:45:40*ChrisMAN quit (Remote host closed the connection)
15:45:42Araq*or if
15:45:51BlaXpirit_what does "progress" stand for? o.o
15:46:10Araqprogress in Nim's design
15:46:13Araq;-)
15:46:20BlaXpirit_i'd rather have a "stagnation" switch
15:46:31BlaXpirit_cuz nobody's gonna use this flag and fall for all the problems anyway
15:46:35dom96what?
15:46:41Araqwell you need to enable it for 0.10.4
15:46:42dom96s[5 .. -1] will stop working?
15:46:52Araqit will be default for the version after that
15:46:56BlaXpirit_cool
15:47:01Araqand will be removed the version after that
15:47:21Araqdom96: yes
15:47:30BlaXpirit_much like python, but i still think these compiler switches need to be available for each file separately
15:47:36BlaXpirit_i.e. exactly like python does it :|
15:47:51AraqBlaXpirit_: but it's affecting the runtime
15:48:03BlaXpirit_i imagine it's damn difficult or impossible
15:48:03dom96Araq: Why?
15:48:07dom96Araq: Most of my code uses this.
15:48:30BlaXpirit_well then it's probably bugged
15:48:47BlaXpirit_at least somewhere
15:49:15Araqdom96: I plan something like s[5 .. ^1]
15:49:24Araqthat you can use instead
15:49:32dom96Araq: I'm tired of changing hundreds of lines of code.
15:49:50dom96what does this gain us?
15:49:58BlaXpirit_dom96, are u serious...
15:50:04BlaXpirit_i explained the bug enough times
15:50:27*ekarlso quit (Changing host)
15:50:27*ekarlso joined #nim
15:50:37BlaXpirit_not a bug in some particular place, but a bug that will be common, recurring if current design stays
15:50:45BlaXpirit_in people's code, that is
15:51:08EXetoCyeah, why have a print clone?
15:51:27BlaXpirit_there is no need for any print functions
15:51:36BlaXpirit_except one
15:51:49BlaXpirit_that allows you to just output a string you give it
15:52:02EXetoCand I'd rather build a string than call stdout.write multiple times
15:52:23dom96This is the relevant issue right? https://github.com/Araq/Nim/issues/1979
15:52:29BlaXpirit_yes
15:52:53dom96Then why is there no mention of this decision there?
15:53:23BlaXpirit_because discussion is scattered across multiple places, of course
15:54:09*ChrisMAN joined #nim
15:54:18BlaXpirit_the decision was likely made on 17 january
15:54:28BlaXpirit_or 18
15:55:59dom96ahh. So the discussion on the relevant issue was completely ignored. Nice.
15:56:28AraqI'm only a human being, I'm not perfect, sometimes I make up my mind and don't tell github
15:56:34EXetoCincluding IRC of course, where things get lost
15:56:43BlaXpirit_this was 95% irc
15:56:45ekarlsoAraq: you're Araq the compiler writing machine :p
15:56:53EXetoCwell there you go
15:57:23*yibter quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:57:46BlaXpirit_EXetoC, why are you asking about Qt? any ideas? news?
15:58:25Araqdom96: in addition to being bug prone, negative indexing is also a pita to support for the 'parallel' statement
15:58:40Araqand I never really liked it tbh
16:00:15dom96I think you should implement proper slicing instead
16:00:16EXetoCthe -1 exception seemed reasonable because of how indexing in nim works
16:00:26dom96ala python
16:01:03AszarshaAraq: what was the rational behind lowercasing the variable names ?
16:01:17EXetoCand if that's the only change then won't some things become less convenient? I'll re-read the discussions though and hope that all the relevant information is there
16:01:23*Matthias247 joined #nim
16:01:58EXetoCBlaXpirit_: I just wanted to know what was new, since I hadn't been active for some time
16:03:30dom96Araq: can we have both `..` and `...`?
16:03:45EXetoCx[-1 .. -1] will throw? assuming that they are runtime values
16:04:10BlaXpirit_dom96, do you mean a different type of slices?
16:04:29dom96yes
16:04:55BlaXpirit_first of all, it's a ton of useless work to duplicate every operation on slices
16:05:00BlaXpirit_and it doesn't gain you much anyway, because all standard library uses inclusive indices
16:05:26dom96It gains me tons of expressivity when working with strings.
16:05:45BlaXpirit_well currently you mustn't use slices on strings
16:05:56BlaXpirit_because of what we just mentioned
16:06:09dom96yeah, which is why I recommend we introduce `...` which will work differently.
16:06:16BlaXpirit_but then you'll want to use a some method on strings
16:06:20BlaXpirit_and get confused as heck
16:06:32dom96what?
16:06:41dom96You mean use `..`?
16:07:09dom96We can do what Araq already wants to do and disallow negative indices for that.
16:08:43BlaXpirit_hm actually there are not as many functions that use indices as i thought
16:09:00EXetoCso, must an if/else pair be used if one wants to possibly yield an empty slice?
16:09:07*Jesin joined #nim
16:09:10BlaXpirit_but look, after this change you can trivially make a ... or ..< or whatever you want
16:09:18BlaXpirit_EXetoC, yeah
16:10:44dom96Well. I want it to work the same way as Pythons `:`.
16:10:54EXetoCand you did not approve of x[-1 .. -1] -> []?
16:10:59dom96So [1,2,3,4][0 ..] should yield the full list.
16:12:05dom96implementing that will need compiler support I think
16:12:13EXetoCx[x.low .. x.find(y)]
16:12:44BlaXpirit_EXetoC pls
16:13:53BlaXpirit_dom96, you might be able convince Araq to make "^" be len just as "^1" is len-1
16:14:08BlaXpirit_then [0 .. ^] is not so bad
16:14:17*^aurora^ quit (Quit: Leaving.)
16:14:23*arnetheduck quit (Ping timeout: 252 seconds)
16:14:26BlaXpirit_and [.. n] is prefix so it's doable
16:14:39BlaXpirit_but it's just rambling, i dont actually think this is important enough
16:14:54Aszarshaon the subject of ranges, Dijkstra was very clear that the only reasonable way to express them is [0, n[. it sure is a strong opinion, but he gives very good arguments imho: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
16:14:56dom96I guess that could work.
16:15:15EXetoCit's weird to me because of the fact that 'low' might yield -1
16:15:28EXetoCI'm sure you'll be able to agree on a solution that doesn't suck. later
16:15:40*gokr quit (Quit: Leaving.)
16:18:04*saml_ joined #nim
16:18:14*comex quit (Quit: WeeChat 0.4.3)
16:18:37*comex joined #nim
16:18:45*banister joined #nim
16:19:02*BlaXpirit joined #nim
16:19:47*comex left #nim (#nim)
16:23:43*rkj-b quit (Quit: ChatZilla 0.9.91.1 [Firefox 36.0.1/20150305021524])
16:23:50EXetoCdid we not have quote buttons in the forum at some point?
16:26:47dom96nope
16:29:21*epichero quit (Remote host closed the connection)
16:30:37*epichero joined #nim
16:35:13*epichero quit (Ping timeout: 264 seconds)
16:37:16*Trustable quit (Remote host closed the connection)
16:47:09BlaXpiritpascal has qt bindings
16:47:14BlaXpiritthis gives hope
16:47:28BlaXpiriti dont understand how they evaded moc
16:48:52EXetoCdo I only have write access to certain repos? If so, can I get write access to all bindings and such in nim-lang?
16:49:11*matkuki quit (Quit: ChatZilla 0.9.91.1 [Firefox 35.0.1/20150122214805])
16:58:37*bcinman joined #nim
16:59:15EXetoCor just cairo
17:08:23*^aurora^ joined #nim
17:11:20AraqAszarsha: not that again. Dijkstra was wrong. get over it.
17:11:42Araqexlusive bounds only work when you have a last element that you don't care about
17:17:24reactormonkEXetoC, you ask the owners of the repo
17:23:13*pregressive quit (Ping timeout: 264 seconds)
17:26:58*pregressive joined #nim
17:27:06*gmpreussner|work quit (Read error: Connection reset by peer)
17:27:52*gmpreussner|work joined #nim
17:29:39*saml_ quit (Ping timeout: 244 seconds)
17:30:03*MyMind quit (Max SendQ exceeded)
17:30:05*saml_ joined #nim
17:31:13*MyMind joined #nim
17:31:26*epichero joined #nim
17:32:08EXetoCAraq: do you think that "x[0 .. -1] -> []" would make sense?
17:32:22EXetoCI do, because of how iterating through a slice works
17:32:48AraqEXetoC: it makes some sense but people expect it to mean "all of x"
17:34:32*BlaXpirit quit (Ping timeout: 246 seconds)
17:35:10AszarshaAraq: fair enough
17:35:20*banister quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
17:35:56*epichero quit (Ping timeout: 246 seconds)
17:39:00*epichero joined #nim
17:41:04flaviuAraq: Have you seen the first remark in that paper? Dijkstra also has a bit of experimental evidence.
17:41:33Araqflaviu: he completely ignores the fact that Pascal and Ada have strong type systems
17:41:46Araqwhere enum is not an int
17:45:26*epichero quit (Remote host closed the connection)
17:45:27flaviuI don't understand how enums not being ints is related here.
17:46:01flaviuAlso, Mesa *seems* to have enums
17:46:29Araqwell Mesa also has all 4 interval types
17:46:43Araqhe's simply wrong about this issue.
17:46:52Araqeven a Dijkstra can be wrong.
17:47:05flaviu"Extensive experience with Mesa has shown that the use of the other three conventions has been a constant source of clumsiness and mistakes, and on account of that experience Mesa programmers are now strongly advised not to use the latter three available features"
17:47:35Araqso you think Mesa programmers are encouraged to use the equivlent:
17:48:05Araqfor i in low(enum).. < enum(high(enum).ord + 1) ?
17:48:15Araqwhom are you kidding here
17:49:14Araqbtw the above might not even be defined and trigger a compiletime or runtime error
17:49:30Araqas the enum clearly has no element beyond its last element
17:54:28AraqEXetoC: btw I did use the mongo wrapper. so I don't think it should be deleted.
17:54:59AraqI didn't use every feature of the wrapper, but it used to work well enough. cannot speak about its current state though
17:55:16Araqbut either way it seems wrong to hide it
17:55:31Araqsomebody will come along and clone and maintain it
17:55:44Araqer I mean "fork", not clone
17:56:27EXetoCI assume you mean the one that was in the standard distribution, which was broken
17:57:16EXetoCit'd just be nice if the libs were held to high standards, but it's up to you
17:57:36EXetoCI'll try to work on it, but I've said that many times already
17:58:24Araqjust make a note in its description that you like some other guy to take over
17:59:00*gsingh93 joined #nim
18:01:29flaviuhmm, Mesa seems somewhat similar to Nim.
18:03:11EXetoCI think dom96 agreed that it was outside the scope of the organization anyway, but I'll do that if I haven't bothered to fix it within a few days
18:07:30*saml_ quit (Quit: Leaving)
18:10:59flaviuAraq: If I understand the Mesa spec correctly, `for i in myenum do` should work.
18:11:53AszarshaAraq: in the compiler, I see code like "result.add(name[0])" but also "add(result, c)". what is the convention you'd better see respected when making changes ?
18:16:56*banister joined #nim
18:17:07*banister quit (Max SendQ exceeded)
18:17:38Aszarshamy question is applicable to anyone used to work with the compiler code too :)
18:18:54*reem joined #nim
18:20:11*vendethiel quit (Quit: q+)
18:22:43flaviuAszarsha: I haven't done much on the compiler, but much of the code that you see is machine-converted from pascal to Nim
18:26:08Aszarshaflaviu: I'm sorry, I don't know Pascal that well. how does it help me with this question ? :)
18:29:31flaviuMachine-generated code is not usually idiomatic code. The best guess I have for "add(result, c)" is that the conversion program didn't bother use prefix notation.
18:32:42AraqAszarsha: flaviu is right, use result.add(c) if you feel like it
18:33:15EXetoCor "result.add c"
18:33:28EXetoC"add result, c" :p
18:33:41Araqflaviu: that doesn't really solve the problem: for x in someValue..high(enum), for x in 'A'..'Z' etc.
18:34:57flaviuAraq: that'd be `for x in [someValue..LAST[Enum] do` and `for x in ['A..'Z] do`
18:35:16flaviuoops, forgot a closing bracket on LAST[Enum]
18:35:26Aszarshaactually, I prefer add(result, c) myself, I don't fancy much universal calling syntax, but it might be because I'm not used to it. anyway, this is why I asked
18:35:41Araqflaviu: oh come on now. you argue only [a..b) is required
18:35:57Araqand that [a..b) should be used universally in Mesa
18:36:06Araqbut that's clearly wrong.
18:36:54Araqthere is a point when you have to accept that even geniuses can be wrong at times
18:38:01*goobles joined #nim
18:38:47AszarshaWhat about specifying the bounds, with [0, n-1] and [0, n[ or [0, n) (replace ',' with '..' if better) ? it's more verbose, but the intent is clear
18:39:05EXetoCAszarsha: I think it improves readability when calls are chained
18:39:38flaviuI suppose my opinion is somewhat more pragmatic than Dijkstra's. I think it's best when exclusive upper bounds are used, but I'm not really against using inclusive upper bounds if the problem calls for it.
18:39:53AszarshaEXetoC: sure, actually I like the minimalist of Lua, and even they added the ':' syntax for "method call" :)
18:41:02EXetoCthat's nice too
18:41:44EXetoCI just use moonscript nowadays
18:42:37*johnsoft quit (Ping timeout: 250 seconds)
18:43:57*johnsoft joined #nim
18:44:04AraqAszarsha: well simplicity demands to use one version universally. And **only** [a..b] is universally usable.
18:44:32Araqso there, Dijkstra is right in a way but he picked the wrong interval type
18:44:50Araqas [a..b) doesn't work
18:44:55flaviuAraq: What if I want 0 elements?
18:45:12Araqflaviu: a..a-1 ?
18:46:16*epichero joined #nim
18:46:25flaviuBut then there's the whole problem with -1 meaning last element.
18:47:23EXetoC?
18:47:42EXetoCat the moment you mean?
18:49:16*Demon_Fox joined #nim
18:50:03AszarshaAraq: well, you two (Dijkstra and youself) have strong opinions at least, that's for sure ;)
18:50:53*epichero quit (Ping timeout: 246 seconds)
18:51:21Araqflaviu: that's completely natural.
18:51:39Araqvar i = 0
18:51:46Araqwhile i <= -1:
18:51:49AszarshaAraq: quite frankly, a..a-1 looks like a hack to me, at the very minimum an ad hoc solution.
18:51:53Araqiterates 0 times.
18:52:13AraqAszarsha: see above. it's how math works.
18:53:04Araqif it were a hack, it would require special casing
18:53:08Araqbut it doesn't
18:53:23BlaXpirit_(actually, currently it does)
18:53:29AszarshaAraq: I still have to see one math paper that would define such an ill defined set [b, a], a<b...
18:53:59AraqAszarsha: so? I still have to see one math paper that sums from 0 to N but exclusively.
18:54:07EXetoCx.high
18:54:08Araqthey all do from 0 to N-1
18:54:16Araqor from 1 to N.
18:55:21AszarshaAraq: you're right, and it seems to me that it basically invalidates the "it's how math works" argument.
18:57:20*^aurora^ quit (Quit: Leaving.)
18:58:28dom96Araq: what do you think about my proposal?
18:58:58AszarshaI initially thought that [0, n) was universal enough, but you have very good arguments why it's not. It seems to me that there are equally good arguments why [0, n] wouldn't be enough either.
18:59:14flaviuWhy not have both!
18:59:57BlaXpirit_let me tell you why
19:00:08EXetoChere we go
19:00:14BlaXpirit_because libraries will pick an arbitrary behavior for the functions
19:01:01flaviuBlaXpirit_: type a, b: int, inclusiveUpper: bool
19:01:14BlaXpirit_whenever using slices doesn't make sense and you pass just one index, one library will make it an inclusive index, and the other will make it an exclusive index
19:01:41BlaXpirit_(not that this isn't what's already happening, because sensible libraries pick sensible exclusive index over consistency with the language)
19:02:00EXetoCthat's not the author's fault?
19:02:11*epichero joined #nim
19:02:40AszarshaBlaXpirit_: a 'range' type actually solves the problem and is actually give the exact intent
19:02:46*vendethiel joined #nim
19:02:56BlaXpirit_it solves the problem when there is a start and an end
19:03:18BlaXpirit_what if a function is only concerned with the end
19:03:34BlaXpirit_you make a slice garbage..end?
19:03:38dom96then the function will assume what the start is
19:03:49*TEttinger quit (Ping timeout: 264 seconds)
19:03:50Aszarshawell, len( array ) is there, isn't it ?
19:04:16dom96the idea of a 'range' type is a good one
19:04:21Aszarshafurthermore, either you require a range on which you can iterate, or a specific index
19:04:28dom96we already have a range type in Nim though
19:04:46Aszarshait seems that this is two semantically different cases
19:07:56BlaXpirit_gee, i'm having such hard time coming up with an example that it really starts to seem like what I just said is unimportant
19:17:50Aszarshadom96: if your suggestion is about having '..' and '...', from a notation standpoint it's very error prone imho
19:18:28dom96Aszarsha: I agree. I would prefer going full Python and using ':' instead but I doubt Araq would like that.
19:18:45flaviuWhy not just have [) and []?
19:19:11flaviu"abc"[0,1)
19:19:19Aszarshaflaviu: i think it's the best :)
19:19:20flaviuerr, "abc"[[0,1)]
19:19:21EXetoCdoes that not break the context-insensitivity?
19:20:04dom96that looks weird
19:20:20Aszarshaflaviu: why the double indexing ?
19:20:25BlaXpirit_messing with brackets like this has so many disadvantages
19:20:25dom96too many brackets
19:20:57flaviuAszarsha: It's a subscript operator with a range inside it.
19:21:16BlaXpirit_looks bad too
19:21:34Aszarshayes, but a sequence followed by a range doesn't make any other sence that "index the sequence with the range"
19:21:46AszarshaThere is no ambiguity from a parsing standpoint
19:22:07AszarshaIt's true that it include an implicit subscript call
19:22:34flaviuI'm not a big fan of implicitly doing things.
19:23:06flaviuhttps://gist.github.com/dadca9f19629fa075091 is what I'm thinking for the BNF.
19:23:38*Trustable joined #nim
19:23:58*TEttinger joined #nim
19:24:04dom96I would prefer to introduce "abc"[0:1] instead.
19:24:07Araqoh come on, are you stupid? we already have .. < and it works really well
19:24:19Araqa[0.. < N]
19:24:30Araqclear, concise, and scales to libraries
19:24:36Araqfoo(a, i, < N)
19:24:51flaviuAgain, the whole -1 == end of slice thing.
19:25:23dom96Araq: Let's not resort to ad hominem attacks.
19:25:47*Matthias247 quit (Quit: Matthias247)
19:25:51Araqwell that's there is to say about this topic. I'm out.
19:26:29dom96Araq: What are your thoughts about copying Python's syntax and semantics?
19:26:44EXetoCget it on the record if it's worth saying by contributing to the thread
19:26:53BlaXpirit_he just said all the thoughts
19:26:57flaviu.eval import macros; dumpTree:; "123"[1:-2]
19:26:59Mimbusflaviu: StmtList
19:27:18flaviu.eval import macros; dumpLisp:; "123"[1:-2]
19:27:19Mimbusflaviu: StmtList(BracketExpr(StrLit(123), Infix(Ident(!":-"), IntLit(1), IntLit(2))))
19:27:29EXetoCand then someone starts arguing again and some things have to be repeated
19:28:03flaviuPython's syntax seems good, although whatever macro does it is going to have to do some parse rewriting.
19:28:15dom96.eval import macros; dumpTree:; "123"[1:]
19:28:16Mimbusdom96: eval.nim(5, 10) Error: expression expected, but found ']'
19:28:25dom96The compiler will need to be modified for it.
19:28:57*Matthias247 joined #nim
19:29:27BlaXpirit_is this what we're gonna get? "123"[1 .. < ^1]
19:30:37flaviu.eval import macros; dumpLisp:; "123"[1 .. < ^2]
19:30:37*goobles quit (Ping timeout: 246 seconds)
19:30:38Mimbusflaviu: StmtList(BracketExpr(StrLit(123), Infix(Ident(!".."), IntLit(1), Prefix(Ident(!"<"), Prefix(Ident(!"^"), IntLit(2))))))
19:30:51flaviuwow, that works!
19:31:05EXetoCsuch elegance :p
19:31:41flaviu.eval import macros; dumpLisp:; "123"[1 .. ^2]
19:31:42Mimbusflaviu: StmtList(BracketExpr(StrLit(123), Infix(Ident(!".."), IntLit(1), Prefix(Ident(!"^"), IntLit(2)))))
19:32:11BlaXpirit_this is what is actually going to be present, according to Araq
19:32:23flaviuEXetoC: Well, the AST makes sense. Whatever macro does this isn't going to have to rewrite the parse.
19:32:43flaviuDoes this even need a macro?
19:33:05BlaXpirit_well yes because ^ can't magically know the length of the container
19:34:22flaviusure it can. type AwesomeRange = object; a, b: tuple[v: int, exclusive, backwards: bool]
19:35:16BlaXpirit_more like BloatedRange
19:35:46BlaXpirit_i am 100% sure this is not going to be considered
19:36:05flaviuIf scoped imports were possible, it would be possible to only have `^` available inside a range expression.
19:36:52flaviuie, template `..`(...): BloatedRange {.dirty.} =; import reversed_range; ...
19:37:14flaviubut that might overly confusing.
19:37:27BlaXpirit_i don't see a reason why we need different slices
19:38:04flaviuSo the container knows exactly what the intentions of the range passed to it are.
19:38:42BlaXpirit_range is always inclusive
19:38:47BlaXpirit_you know the intention
19:39:15flaviuBut I *don't* want my ranges to always be inclusive.
19:39:28*pregressive quit (Remote host closed the connection)
19:40:02*pregressive joined #nim
19:42:06*Asz joined #nim
19:43:22EXetoCso be it
19:44:12BlaXpirit_so do you want every function to manually implement behavior for inclusive, non inclusive, reverse, whatever ranges?
19:44:33EXetoCI want consistency and lack of redundancy
19:44:39*pregressive quit (Ping timeout: 256 seconds)
19:45:00BlaXpirit_the only redundancy here is -1 everywhere
19:45:29flaviuBlaXpirit_: I want every indexable collection to provide a common API, so that handling range complications only needs to be handled once.
19:45:54BlaXpirit_why even introduce any complications?
19:46:50flaviuBecause it makes things easier for the API clients, which is what the goal of a library is.
19:48:14BlaXpirit_no, it is important to make implementing collections easier
19:48:32EXetoCit's redundant to have all these things surely
19:48:44BlaXpirit_because I expect Nim's standard library will not be taken seriously, and if it gains any popularity, alternative collections of modules will spring up
19:49:20flaviuBlaXpirit_: Yes, that's an important goal. The collection author should provide a `[]`(self, int), and the stdlib should handle the rest.
19:49:46BlaXpirit_ok
19:49:52BlaXpirit_so that limits the implementation
19:50:28flaviuHow does that limit the implementation? The collection author always has the option to override the stdlib's implementation.
19:50:40BlaXpirit_do you realize that it is possible to implement a slice more optimally than just enumerating each of the elements separately from scratch?
19:51:04*TEttinger quit (Ping timeout: 245 seconds)
19:51:16flaviuSure. If a collection author wants that, they can write their own `[]`(self, BloatedSlice).
19:51:20BlaXpirit_i mean not generally speaking but for some collection type that doesn't just store all its items blah blah
19:51:43BlaXpirit_well then they're left with implementing all the branches and corner cases
19:51:57BlaXpirit_not to mention BloatedSlice is a big object to pass around
19:52:32flaviu4 extra bytes isn't that much
19:53:13BlaXpirit_don't forget performance too
19:53:40BlaXpirit_this al just so that users can use exclusive slices
19:53:47flaviutest for fast paths before starting iteration.
19:53:54flaviuand reverse slices.
19:54:09BlaXpirit_reverse slices you mean like what negative indices do now?
19:54:29flaviuyep
19:54:45BlaXpirit_the current idea is to not have them at all
19:55:39EXetoCit's an odd shortcut
19:56:21BlaXpirit_my idea, and what Araq seems to think as well, is to have this "^" be just a syntactic sugar for len or high
19:56:36BlaXpirit_(talking about this x[a .. ^1]
19:56:54flaviuI really hate special cases and magic in the compiler. It has enough problems because of it already.
19:56:58EXetoCum
19:57:14EXetoCwhat's the succeeding number for then?
19:57:33BlaXpirit_-1 -> ^1 -> x.len-1
19:58:10AszarshaBlaXpirit_: actually, if you're doing it right, the range type should only be a compile time thingy and the for loop is generated accordingly. I did it that way in a toy language of mine a few years ago. Their is one disadvantage: it only works for whole program compilation (which is the case for Nim I think!) and you have to choose one scheme for FFI (and C is king here, and in C ranges are exclusives).
19:58:27EXetoCand when you want to add instead you.. don't use ^ anymore?
19:58:58BlaXpirit_well it very rarely makes sense to go above len
19:59:15BlaXpirit_and if you do want that, i dont see a problem with ^-1 working
19:59:18EXetoCthat's true
19:59:24BlaXpirit_but my initial idea was ^-1 and not just ^1
19:59:31flaviuAszarsha: With macros, it's not even necessary for the compiler to be aware about how ranges work.
19:59:36BlaXpirit_making ^ an ordinary expression
20:00:00Aszarshaflaviu: well, great then, I guess... ? :)
20:00:34Aszarshait seems to me that it's one more argument for having both kinds of range
20:01:08EXetoCit really should mean high then, unless I've missed something
20:01:22BlaXpirit_len is not a safe choice, yeah
20:01:43BlaXpirit_we talk about len because -2 would be replaced by len-2
20:02:00BlaXpirit_and it's not so direct when you use high
20:02:52EXetoCwell, I assume that it's more common to specify up to the last element
20:13:54*reem quit (Remote host closed the connection)
20:17:56*reem joined #nim
20:27:46*TEttinger joined #nim
20:39:31*reem quit (Remote host closed the connection)
20:43:42*jholland joined #nim
20:46:42EXetoCAszarsha: it's not just about for loops is it?
20:49:06AszarshaEXetoC: no, of course not, thought range usually serve only two purposes in the end: iterating over their elements or knowing its lenght when not infinite
20:50:33*epichero quit ()
20:51:26Aszarshaand they shouldn't be limited to range of indices neither, and need to be properly defined for any partially ordered set
20:54:29EXetoCby range you mean slice? I don't like how the term slice is used, but we already have a range type used for another purpose
20:55:03Aszarshaactually, a sequence of T is itself a range, it's a set of T for which the order of insertion define an ordering. on this subject the works of A. Stepanov (Elements of Programming) and of A. Alexandrescu (D2.0 stdlib) are really great
20:57:26Aszarshathe best collections library is by far the one from D2.0
20:57:45Aszarshabecause of this whole formal ranges concept
20:58:12EXetoCI don't know why this is relevant. anyway, traits are broken so it'll be difficult to implement something like that now
20:59:37EXetoCor maybe not. errors would be triggered inside the function bodies though
21:07:44AszarshaEXetoC: I sure hope not, if the langage prohibit this kind library, while advertising itself as expressive, something is wrong :)
21:08:05flaviuAszarsha: D2.0?
21:08:34flaviuAh, Phobos.
21:12:15Aszarshahttp://dlang.org/phobos/std_range.html
21:14:40Aszarshaconceptually, slicing is a form of range compisition, a[0..5] is subrange( a.range, 0, 5 )
21:21:22EXetoCAszarsha: broken as in buggy implementation
21:22:11EXetoCAszarsha: yes, that's different from our slices
21:22:29*reem joined #nim
21:22:30EXetoCvar a = b .. c
21:22:40AszarshaEXetoC: Ho! I though your sentence meant "now that traits are broken, it'll be difficult to implement something like that from now on", my bad
21:25:38*epichero joined #nim
21:26:05sdwis slicing by reference on the todo list?
21:26:08*fizzbooze joined #nim
21:34:54AszarshaEXetoC: what do you mean "our slices" ? slicing is a very well defined operation: http://en.wikipedia.org/wiki/Array_slicing
21:44:52*gsingh93 quit (Ping timeout: 240 seconds)
21:53:12EXetoCthere are slice operations, but there's also the Slice type (or is it still TSlice)? the code that I posted creates such a slice
21:53:38*saml_ joined #nim
21:53:51EXetoCodd terminology as I said
21:55:48EXetoC.eval var x = TSlice[int](a: 0, b: 1); x = 1 .. 2; echo x
21:55:49MimbusEXetoC: (a: 1, b: 2)
22:00:17EXetoCsdw: I haven't heard of such plans, but some library has that
22:02:24*flaviu quit (Remote host closed the connection)
22:03:15EXetoChttps://github.com/AdrianV/nimrod-tools/blob/master/seqslices.nim
22:04:03*irrequietus joined #nim
22:06:19*xificurC quit (Ping timeout: 256 seconds)
22:08:33*topon joined #nim
22:14:26*davidhq quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
22:14:32*topon left #nim (#nim)
22:21:07*zipR4ND1 quit (Ping timeout: 245 seconds)
22:45:28*MagusOTB joined #nim
22:55:14*Jesin quit (Quit: Leaving)
22:56:10*banister joined #nim
22:57:32*pregressive joined #nim
22:58:39*jsudlow__ joined #nim
22:59:35*TEttinger quit (Ping timeout: 256 seconds)
23:00:26*jsudlow quit (Ping timeout: 246 seconds)
23:10:01*irrequietus quit ()
23:12:52*fizzbooze quit (Ping timeout: 265 seconds)
23:57:10*fizzbooze joined #nim
23:59:03*brson joined #nim