<<31-08-2012>>

00:01:37EfTwelveg'night
00:19:23fowlEfTwelve: the csfml wrapper isnt 100%, i have left out some of it like mutexes and the networking parts, you should be able to do raw opengl in it no prob
00:20:00EfTwelvethanks.
00:36:22reactormonkEfTwelve: I think there are ranges, but I'm not sure
00:36:37reactormonkand I'd call it ASCII_UPPER and _LOWER ;-)
00:37:34EfTwelveyeah, sampling from a range would be more elegant i think.
00:38:40reactormonkEfTwelve: there are subranges
00:38:47reactormonkoverload random in such a way it takes a subrange
00:38:52reactormonkhttp://nimrod-code.org/tut1.html#subranges
00:39:08reactormonkyou could even add that overload code to math.nim and submit a pull request
00:39:30reactormonkproblem is that a subrange is a type, not a variable
00:40:29reactormonkthere is indeed no range type
00:43:53*EfTwelve_ joined #nimrod
00:45:06EfTwelve_well, random should def be a float and take 2 args for min and max imo
00:47:20reactormonkEfTwelve_: tell Araq
00:48:24EfTwelve_ya i think i wil, i'll write the function first.
00:53:18*EfTwelve quit (*.net *.split)
00:53:18*silven quit (*.net *.split)
00:57:37*silven joined #nimrod
01:30:36*q66 quit (Quit: Quit)
02:32:50*EfTwelve joined #nimrod
02:35:29*EfTwelve_ quit (Ping timeout: 252 seconds)
04:40:51EfTwelvewhat is the equivalent argc argv in nimrod?
04:43:16fowlEfTwelve: os.paramCount and paramStr
04:43:52fowlalso see parseopt module
04:44:47EfTwelvehmm, what about a c function that expects argc, argv? such as gluInit() http://force7.de/nimrod/glut.html#283
04:49:25EfTwelvearrrgg!! theres no documentation!!!!!
04:51:03fowlhmm i dunno, never tried glut
04:52:13fowlI think that should be a cstring
04:52:20fowler cstringarray
04:53:13fowlwhat is that for anyways, sending command line args to glut?
05:00:44EfTwelveif the first function to initialize glut is glutinit() and takes argv,argc
05:00:50EfTwelveits*
05:03:36fowlEfTwelve: this seems to work https://gist.github.com/3549219 at least, it compiles and runs without error
05:06:05fowlLike argcp, the data for argv will be updated because glutInit extracts any command line options understood by the GLUT library. weird o_O
05:07:36EfTwelvedear lord! how would i even know that kind of syntax exists? there is nothing like that in the docs. lol
05:07:50EfTwelvethanks btw
05:08:26fowlEfTwelve: surprised about which syntax?
05:13:05EfTwelvethe 'addr' statement
05:13:51EfTwelvei think if you hadn't shown me, there is no way i would that exists. ive never seen it in the tutorials or docs
05:14:16EfTwelve i would *know
05:15:36fowlo
05:21:09EfTwelvehmm, that code you posted wont compile for me. is that something in a later version than 8.14?
05:23:51EfTwelvebinary or is 'or' ?
05:25:02fowlyes for binary or^
05:25:48fowlim not on 8.14 im on a week old HEAD
05:28:07fowlEfTwelve: what was the error
05:28:29EfTwelvethe 'addr' needed parens around the var
05:31:40Araqgood morning
05:31:53Araqyeah 'addr' requires parens in 0.8.14
05:32:18Araqand there is a way to get argv and argc but I forgot how
05:33:13Araq var
05:33:14Araq cmdCount {.importc: "cmdCount".}: cint
05:33:16Araq cmdLine {.importc: "cmdLine".}: cstringArray
05:33:17Araqthere you go
05:33:38Araqbut they can't work for a windows UI app
05:34:45EfTwelvefowls method works well
05:34:58Araqyeah fowl's method is preferable
05:35:45Araqand the tutorial doesn't mention 'addr' because it's unsafe :P
05:36:09Araqin general the manual is better if you can already program in C
05:40:57EfTwelvehow is this supposed to be handled?: http://force7.de/nimrod/glut.html#327
05:41:12EfTwelveglutDisplayFunc wants a function pointer, doesnt like the one i give it
05:43:27fowlit needs a function like this: TGlutVoidCallback* = proc () no args, no return
05:44:43*XAMPP quit (Ping timeout: 245 seconds)
05:47:04EfTwelvehmm, nimrod doesnt like anything about that syntax
05:47:43Araqtype T = proc () # a new *type*
05:47:57Araqproc p() = ... # a new *proc*
05:48:11Araqq(p) # pass p to q
05:58:26fowlor q(proc() = echo "hello") would work
06:01:13EfTwelvei dont understand any of that :(
06:02:04fowlEfTwelve: TGlutVoidCallback describes a proc that takes no arguments and returns nothing, any proc like that will be compatible
06:04:25EfTwelveexcept that nimrod wont even except that kind of syntax
06:05:19EfTwelveyou mean a proc defined such as: TGlutVoidCallback* = proc display() =
06:05:21EfTwelve?
06:05:24fowl? can you paste your code somewhere
06:05:26fowloh no
06:05:36fowlyou dont have to use the type name at all
06:06:28fowlproc display() = ...
06:07:07EfTwelvegltest.nim(30, 18) Error: type mismatch: got (proc ())
06:07:09EfTwelvebut expected one of:
06:07:11EfTwelveglutDisplayFunc(f: TGlutVoidCallback)
06:08:25fowlcan you paste your code
06:08:42fowlnot here, somewhere in the cloud
06:09:25EfTwelvehttps://gist.github.com/3549552
06:13:40AraqEfTwelve: you need to use the correct calling convention for display
06:13:42fowlEfTwelve: i figured it out, the type has cdecl pragma and apparently that doesnt come through the docs gen
06:14:00AraqI think it does in 0.8.15 :P
06:14:44EfTwelvehmm
06:14:55fowlEfTwelve: change your display func to proc display() {.cdecl.} =
06:15:33fowlAraq: i just generated docs locally and they didnt
06:15:35EfTwelvei see..
06:16:28Araqfowl: oh yeah the docgen
06:16:41Araqbut the error message should mention the calling convention
06:17:18fowli got the same error message he did
06:25:32*XAMPP joined #nimrod
06:29:06EfTwelvecan a proc have static vars?
06:30:53Araqno, use globals instead
06:31:04EfTwelvewha!?
06:31:33fowlyou have a variable local to the module outside the proc that you only use in the proc
06:31:42fowlsame thing as a static var, i think
06:32:44Araqwell you can also use 'var myStatic {.global.}: int' I think
06:32:49Araqbut not in 0.8.14
06:36:40EfTwelveok, i finally got triangles drawing on the screen..
06:36:55EfTwelvethanks for all the help with that..
06:38:46EfTwelvestrange though.. this works: angle = angle + 0.5
06:39:21fowlangle += 0.5 should work
06:39:22EfTwelvebut: angle += 0.5 complains about the var not being passed.
06:39:44EfTwelve"Error: for a 'var' type a variable needs to be passed"
06:41:04EfTwelveangle is defined globally as float32
06:43:13fowlhmm when i try it locally it works https://gist.github.com/3549682
06:44:11AraqI think there is no += for floats in 0.8.14 :P
06:50:18EfTwelveok
06:51:35fowlEfTwelve: the problem with the documentation is that its boring to read so you skip sections of it without realizing
06:53:17EfTwelveya, l'll go over the docs with more detail tomorrow.
06:53:30EfTwelvegotta get some sleep. Thanks for all the help!
06:53:42fowlno problem
06:54:01Araqfowl: which docs are particularly boring?
06:54:26Araqand how to fix it?
06:56:54fowlim not sure how to fix it, the tutorial looks like a big wall of text to me ._.
07:14:57AraqI dunno, I think the tutorial should be a big ball of examples instead
07:15:15Araqbut I barely read anything anyway
07:15:40AraqI'm not the average tutorial reader ;-)
07:27:27*zahary joined #nimrod
07:31:32Araqhi zahary
07:32:21fowlyea i dont usually read them either
07:34:05Araqwe need a cookbook
07:34:45*zahary quit (Ping timeout: 246 seconds)
08:33:00shevyI thought about the nimrod tutorial
08:33:09shevyAraq said that experienced users are bored by too much details
08:33:18shevybut newcomers need information desperately
08:33:31shevyand I think right now, a wealth of information is not available for newcomers
08:34:28shevyone addition that could be useful, would be extended and working .nim files in addition to the documentation
08:34:44Araqhey there is an examples/ folder :P
08:34:56Araqbut the examples are not too good :D
08:35:01shevyyeah but take the gtk examples, without dom96's link, I am not sure I would have found them
08:35:21Araqwell yeah that's the cookbook I'm talking about
08:35:33Araqit should start with basic snippets
08:35:34shevythe gtk examples were a big help to try and understand how things work btw
08:35:55Araqand then show some GTK examples and OpenGL examples
08:36:18fowlshevy: you could take a look at aporia's code
08:36:57Araqwell aporia's code is - ugh - not the best way to learn :D
08:37:11*Araq is afraid of aporia's code
08:38:26shevyfowl yeah, I was too scared of it though, I like to digest in small snippets, aporia seemed daunting
08:39:16shevyfor now that is :)
08:39:52shevyI know gtk a bit because I used ruby-gtk for two or three years, often had to look at the official C docu in Gtk
08:52:08*Boscop quit (Disconnected by services)
08:52:09*Boscop joined #nimrod
08:57:04Araqfowl: getting rid of forward declarations is a pita
08:57:31AraqI'm planning a hackish solution with yet another pragma:
08:58:21Araq{.foward.} # pull any proc headers that come afterwards in here
08:58:25Araq*forward
08:58:51Araqand yes, it can only work for procs
08:59:19Araqwhat do you think?
09:00:41fowli dont get it.. i only forward procs when I have to
09:01:39fowllike if proc A calls proc B but im trying to keep them orderly
09:02:03Araqwell yeah but people like order independence for procs
09:02:25Araqso you'd stick a {.forward.} pragma after your imports and type definitions
09:02:40Araqand the compiler would generate proc headers for you
09:02:54fowlthat sounds awesome
09:02:57Araqand insert the forward declarations where the {.forward.} is
09:03:59Araqwell it's not exactly "awesome" but better than nothing :-)
09:04:22Araqand seems the only solution that is feasable without lots of tinkering with all of the compiler's internals
09:04:48Araq*feasible
09:09:22fowlyea
09:09:26fowlsounds gr8 to me
09:10:26Araqalright
09:20:28*zahary joined #nimrod
09:20:38zaharyhi Araq
09:20:45*Boscop quit (Disconnected by services)
09:20:46*Boscop joined #nimrod
09:20:55Araqhi zahary, I've implemented term rewriting macros :D
09:21:07zaharyI noticed :)
09:21:11Araqstill working on that feature though :-)
09:21:23zaharybtw I studied the implementation of varargs and gensym and varags don't work the way I expected
09:22:08Araqwell I have another feature in mind: tyParamList
09:22:20Araqmaybe that's what you I expected?
09:22:24zaharyhaven't we talked about how varargs will be reduced to a possible heterogenous tuple?
09:22:42Araqwell we talked about it
09:22:53Araqbut that's tyParamList, aka '*'
09:23:14zaharyI'd like to be able to say varargs[expr] or varargs[static{string}] or varargs[int or string] and so on
09:23:31zaharythat's tyParamList?
09:23:38Araqwell I dunno
09:23:50AraqtyParamList is supposed to be used for perfect forwarding
09:24:11Araqif you store it in an object, it'll transform to a tuple
09:24:29Araqhowever it will be unpacked for you again in: f(X)
09:24:33zaharyis openarray obsolete now?
09:24:41fowldefShapeProp(CpFloat, e, Elasiticity, false) >_> <_<
09:25:01Araqno, openarray now means seq|array
09:25:18Araqexcept there are no generics involved
09:25:43Araqso openarray is just the way it always was but you can't pass multiple arguments to it
09:25:50zaharyI see - do you agree about the interaction between varargs and the type classes I propose? I can try to implement it
09:26:49Araqwell in fact, I'm still puzzled why I broke ttypedesc1.nim
09:27:24zaharyhmm, haven't noticed. I'll look into it
09:27:48Araqand there is also bug 186 waitin' on you :-)
09:29:06zaharyfowl, what was your goal in the example code?
09:29:06zaharyhttps://github.com/Araq/Nimrod/issues/186
09:29:57Araqwhat's the difference between static{string} and expr{nkStrlit} ?
09:30:24zaharyfowl, I think you meant to say t: typedesc{TestPkt}, but I'll look why such an error is produced
09:31:17zaharyAraq, no difference right now - we talked once about changing expr{} to static{}, because it's more obvious for newcomers
09:31:26fowlzahary: i thought you could make a proc like that, i believe type(testpkt) would return typedesc{testpkt}
09:31:47Araqreally? 'static' now means something completely different IMO
09:31:55zaharyI does actually, but I never tested it this way
09:32:20zaharystatic = compile-time ?
09:32:22Araq"static" means "enforce compile time evaluation"
09:32:29zaharyso compile-time param
09:32:49Araqbut that's not what expr{nkStrLit} means
09:33:10Araqand I really need expr{nkStrlit} for TR macros
09:33:51Araqbtw varargs[expr] already works
09:34:06zaharybut only for macros?
09:34:20zaharydidn't work for me in a simple example
09:34:22Araqdon't think so, but I only tested it with macros
09:34:45Araqwell it works for macros, it should work the same for procs?
09:34:56Araqoh wait
09:35:00Araqdamn
09:35:27zaharyI don't plan to change expr to static - It was just an example for a "match a category of parameters and not some concrete type"
09:35:28Araqwell no, there is no special casing for varargs[expr]
09:35:44Araqgood, I really prefer 'expr'
09:37:10zaharymy plan about varargs was turn such params into implicit generics (maybe only when the underlying type is a type class) - so any va: varargs[int or string] proc will be instantiated once for any unique set of parameter types and va.len will be compile-time constant
09:40:05Araqwhat's the use case?
09:42:01Araqand I wonder whether is has anything to do with tyParamlist :D
09:42:03Araq iterator chain[S, T](a, b: *S->T, args: *S): T =
09:42:04Araq for x in a(args): yield x
09:42:06Araq for x in b(args): yield x
09:42:23zaharystyledEcho comes to mind - it takes varargs[StyleEnum or Printable]
09:42:29AraqI use *S to mean "list of parameters"
09:42:33zaharyI thing there are many use cases
09:44:03Araqthe compile would transform *S into a tuple when you store it somewhere
09:44:17Araqand unpacks it in f(X)
09:44:52AraqI think C++ got the same feature?
09:45:09Araqcan't think how its futures can work otherwise
09:45:11zaharyimplicit unpacking of varargs tuples is something I planned to talk about
09:45:46Araqwell, maybe explicit pack and unpack primitives are easier to comprehend
09:46:09zaharyyes, C++ has it, but there it's more needed, because generic varargs are handled only recursively
09:46:32zaharythe nimrod way makes some use cases easier to handle
09:49:49Araqwell we need something similar to *S for patterns:
09:50:16Araqtemplate t{s[key] = f(X)} ...
09:50:32Araqit an important optimization for string tables
09:50:34zaharyif you want me to generalize what's the use case for varargs conforming to some type class, such uses arise when you have some symbol-based DSL which produces configuration out of some expression tree
09:51:16zaharystyledEcho is one example - in C++ I can also cite libraries such as http://www.rasterbar.com/products/luabind/docs.html
09:52:26*Boscop quit (Disconnected by services)
09:52:27zaharyor http://www.boost.org/doc/libs/1_48_0/libs/spirit/doc/html/spirit/introduction.html
09:52:28*Boscop joined #nimrod
09:53:26Araqas it can take ownership if the expression is a function call
09:53:49Araq(thanks, was aware of both spirit and luabind but don't know how they work in detail)
09:55:43zaharyhmm, wasn't this kind of varargs matching in patterns always in the plan?
09:56:08Araqsure but I'm cutting features ;-)
09:56:11zaharytemplate t{ f(X) } (X: varargs[expr])
09:57:37Araqwell that can't work with the current implementation
09:58:05Araqas f(1, 2, 3) doesn't match f(X) as a raw AST
09:58:14Araqwe need to special case that in the matcher
09:58:34Araqand then we need nkArgList so that (1, 2, 3) can be captured properly
09:58:52Araqand template instantiation needs to consider nkArgList specially
09:59:39zaharywhat's the pipeline? we once talked about how f(X) is parsed first, then the param list is processed so X becomes argList at this step and finally the AST is matched
10:00:32Araqcurrently I reused the code that does template body semchecking
10:00:40Araqfor {patterns}
10:01:00Araqand pattern matching is perfomed bottom up in semExpr
10:01:18Araqand in semStmt
10:01:32Araqand I guess it need to be done again after transform()
10:02:06Araqso patterns are "precompiled" in a fuzzy way
10:02:14Araqlike template bodies are
10:02:22zaharyso X got assigned to skParam symbol?
10:02:32Araqyes
10:02:34zaharynkIdent pointing to such symbol
10:02:51Araqit's simply an nkSym with skParam
10:02:59Araqwith the proper owner
10:03:00zaharyI see
10:03:08Araqand it has the proper type too
10:03:19Araqso it's not hard to make it match (1, 2, 3)
10:03:34zaharyyes, and you could use that to implement the matching rules, I see
10:04:49Araqmatching is a simple tree matcher with unification
10:05:20Araqwhich doesn't work for nkStmtList, but I'm implementing that right now
10:05:27Araqthe problem is:
10:05:39Araq{write a; write b}
10:05:45Araqdoesn't match:
10:05:58Araq{dummy; write a; write b}
10:06:13Araqas the pattern length is 2 and the actual tree's length is 3
10:06:26Araqthe matching is really simplistic for now ;-)
10:07:20zaharyI see - should be easy to fix
10:07:23AraqI figured that this fuzzy nkStmtList matching needs to be special cased everywhere and can not work recursively
10:07:41zaharyhmm, why everywhere?
10:08:03Araqyou need to split up the nkStmtList into prefix, middle and suffix
10:08:12Araqand then pass only middle to the macro
10:08:24Araqas it only deals with the middle which matched
10:08:27zaharyyou mean after it's matched?
10:08:31Araqyes
10:08:40Araqand then you need to merge it again
10:09:01zaharyI'm already doing splicing on the nkStmtList because of destructors and finally, etc
10:09:45Araqha, true it's needed there too
10:10:47Araqwell it's simple to fix as it doesn't need to be done recursively
10:11:20Araqperformance will be absymal I guess
10:12:32zaharyin the very distant future we can compile the multiple patterns in the DFA so the scan can be linear
10:13:11AraqI dunno if that works for arbitrary patterns
10:13:18Araqdoes it?
10:13:32zaharykind of, if your alphabet is node kinds
10:13:46zahary… and symbol names (a bit harder)
10:14:38Araqyeah well we have side effects on patterns, order does matter
10:14:50Araqbut I guess it works nevertheless
10:14:54zaharybut let's see the performance hit first :)
10:15:05Araqlexer generators have the same problem after all
10:15:48zaharyso what about varargs[type class] ?
10:16:15Araqwell it should work without introducing special rules IMO
10:16:26Araqmuch like it does for varargs[expr]
10:16:51zaharythe main difference is how it produces implicit generics - I'll have to make sure that works right
10:17:20Araqwell about the generics ...
10:17:30zaharywhere is the missing special case for varags[expr] you mentioned?
10:17:48Araqno I mean, it shouldn't require special casing
10:17:55Araqand it already works for macros
10:18:12Araqand there is no special casing in sigmatch for it
10:18:15zaharywell, macros are inlined - no instantiations there
10:18:33zaharythe sigmatch part is probably pretty close to working
10:18:45Araqoh I see
10:19:07Araqyou've been talking about the instantiation process all the time
10:19:16zaharyyes
10:19:25Araqthere is another generics bug
10:19:30Araqwhich I haven't yet looked into
10:19:42Araqlet me create a proper bug report ...
10:21:18Araqbug #194
10:21:55Araqwell I don't care much about the instantiation process so go ahead
10:22:07Araqhowever
10:22:44AraqI really dislike symbol binding in generics
10:23:02Araqand we need to come up with a solution
10:24:08zaharydo we want the optimization that concrete types are still handled as the old openarray? (it reduces code bloat, but produces the inconsistency I mentioned before args.len is compile-time value with type classes and run-time value with concrete types)
10:24:35zaharysymbol binding? you mean the koenig lookup?
10:24:49Araqhu? len is already sometimes a compile time value and sometimes not
10:25:18Araqyeah I mean the koenig lookup
10:25:38Araq(which I think isn't really koenig lookup ...)
10:25:45zaharyyeah
10:26:34zaharywell, what about it? one solution could be to just scratch it - always require distinct types
10:27:39Araqproc find[T, S]{eq=`==`, items}(container: T, e: S): int =
10:27:41Araq for x in items(container):
10:27:42Araq if eq(x, e): return
10:27:44Araq inc(result)
10:27:45Araq return -1
10:27:50Araqis an old idea of mine
10:28:23Araqso every symbol is bound at definition time but you can have explict "open" symbols like 'items' and '=='
10:28:40zaharyaha, so you both document the requirements and provide means to capture them from the outer scope
10:28:50Araqyes
10:29:04zaharystill doesn't solve the conflict problem, which is the bigger issue for me
10:29:22Araqand it's not overspecified like 'items(x: T): S'
10:29:51Araq(what if it's 'items(x: T, default = 0): var S' instead?
10:30:12Araqand then a hash table declaration would look like:
10:30:37Araqvar t: TTable[string, string]{eqIgnoreCase, hashIgnoreCase}
10:31:07Araqand we need generic type and symbols inference for:
10:31:21Araqproc put(t: TTable, key: TKey, val: TValue)
10:32:46zaharyI didn't quite follow the last remarks
10:33:01zaharyI get your frustration with overspecified requirements
10:33:18zaharybut you don't want to repeat them on each proc I think
10:34:22Araqyeah that was my point
10:34:34Araqwell my original idea was to have:
10:34:56Araqproc put(t: TTable, key: TKey, val: TValue) # compile recognizes generic type TTable
10:35:01Araq*compiler
10:35:02zaharyif the HashKey type class lists everything needed with proper error messages, then the distinct type solution is clean enough - you create a new borrowAll key type with hash and equals overridden
10:35:44Araqand so inserts [Tkey, TValue]{eq, hash} in the param list
10:36:14Araqand I prefer {eq, hash} over the distinct type solution tbh
10:37:57Araqhowever I don't know at all how that {list_of_symbols_here} syntax works out with more complex generics
10:39:00zaharybut then you need a whole new set of semantics for specifying which symbols will be captured (and from which scope, etc) - you are much closer to the abandoned C++ concepts effors
10:39:42zaharywhat worries me personally is that even these (both distinct types and {hash, equals}) are not enough to capture all use cases
10:40:07Araqwhy? {hash, equals} capture all use cases for me
10:44:07*zahary quit (Ping timeout: 240 seconds)
10:46:26*Trix[a]r_za is now known as Trixar_za
10:57:48dom96hello
10:59:59Araqhi dom96
11:04:20*q66 joined #nimrod
11:18:34*Trixar_za is now known as Trix[a]r_za
11:27:37*Boscop quit (Disconnected by services)
11:27:38*Boscop joined #nimrod
11:57:11*Boscop quit (Disconnected by services)
11:57:13*Boscop joined #nimrod
12:57:26*Boscop quit (Disconnected by services)
12:57:28*Boscop joined #nimrod
13:07:21*Boscop quit (Disconnected by services)
13:07:22*Boscop joined #nimrod
13:52:46*zahary joined #nimrod
13:54:00Araqwb zahary
13:54:33zaharysorry, I have connection issues today
13:54:45Araqnp
13:58:33Araqso, I wonder how explicit symbol binding like {`+`, `-`, `/`} etc. would scale for generic numerical code
14:05:57zaharysounds painful if you have to specify it everywhere in order to solve the not so common problem of per-client customization of generics
14:06:48Araqwell as I said it would be bound to the generic type and infered
14:07:35*Boscop quit (Disconnected by services)
14:07:37*Boscop joined #nimrod
14:07:51zaharyso, you walk over all usages and implicitly bind any used procs?
14:08:48zaharywhere is the point where it gets different from the current design?
14:19:45zaharyalso, it's not clear to me what happens when multiple generic types are involved:
14:19:46zaharyif I have a proc that depends on a generic like AreIntersected (accepting shape types such as lines, circles, rectangles, etc)
14:19:46zaharyproc GeometricAlgorithm(a, b: Shape) =
14:19:46zahary
14:19:46zahary if AreIntersected(a, b): …
14:19:46zaharywill the correct AreIntersected overload somehow be bound to the pair of types?
14:19:47zaharyalso, the "interface" of a type have to be open after the type is defined, because it's not possible to know upfront all the generic operations that would be defined over it
14:21:03zaharywhy do you dislike distinct btw? it adds exactly one line to the program
14:26:25Araqhrm, I'd simply use a union of type params and symbol lists for muiltiple generic types
14:26:27Araqbrb
14:33:54Araqwell you may want to check how it's currently done:
14:34:19Araqthere is a pass over the generic's body that captures symbols
14:34:43Araqwhich has issues because it resolves templates and macros
14:35:03Araqto gain information about possibly injected symbols
14:35:33Araqand you can use 'bind' to close over a set of symbols so that helper procs can't be redefined
14:35:45Araqaccidently in client code
14:36:33Araqit's really quite like the pass that is now done over a template's body except that for templates we don't invoke templates/macros
14:37:09Araqand it's the wrong default, it should 'bind' every symbol that's not explicitely declared "open"
14:37:38Araqthe open symbols are exactly which should turn up in my proposed {symbol_list}
14:37:56Araqas they are part of the interface of a generic proc
14:39:22Araqwe can't really resolve templates/macros in a generic body anymore btw because they are now part in overloading resolution
14:39:33Araqwe can only do that for immediate macros
14:40:00Araqor for macros with 0 parameters for compatibility with tables.nim etc.
14:44:03Araqit's really messy and needs to be fixed ...
14:45:19zaharyand this pass is not equivalent to just calling semStmt on the generic body?
14:46:52Araqyes it's not
14:46:55zaharyyou say "open is the wrong default, because the client can accidentally have a symbol with the same signature as what would have been bound if bind was the default"
14:47:02zaharybut that should produce ambiguity error, no?
14:47:20Araqtrue
14:48:31AraqI played with the code a bit and it turned into an ambiguity error for 'nextTry'
14:48:50Araqas both astalgo.nim and tables.nim have that
14:49:41Araqin fact the current implementation turns an nkOpenSymChoice of length 1 into the concrete symbol
14:49:54Araqso that 'nextTry' is bound
14:50:27Araqif 'nextTry' in tables.nim would have been overloaded it fails
14:50:49Araqit works by chance :-)
14:51:06Araqas nextTry is not overloaded but == and 'hash' are
14:51:23zaharyit seems to me that explicitly stating open symbols falls into the realm of what I call "babysitting the compiler" - most of the time my intentions are obvious from the code and if the accident happens, there is still the safety net provided by the ambiguity error
14:52:22zaharywhat is nextTry problematic here?
14:52:57Araqit's the code that made me realize how broken the compiler is IMO
14:53:18zaharybut what will happen if I provide a local overload?
14:53:30Araqambiguity error
14:53:44Araqthe problem is however not a "local" overload
14:54:12Araqimport tables, astalgo # assume astalgo has a public 'nextTry' too
14:54:40Araqt["key"] # wtf? ambuity error for 'nextTry'?
14:54:47zaharyI see
14:55:35zaharybut this doesn't get fixed under any regime - your {boundSymbol} have the same problem?
14:55:51zaharythere would be less such symbols, that's your point?
14:55:58Araqnow of course tables.nim could use 'bind nextTry' to get around the problem
14:56:32Araq{boundSymbol} don't have the problem because it's now explicit
14:56:50Araqthe problem is that open per default, closed via 'bind' is wrong
14:57:00zaharythe old closeness rule could kick in here - the tables module's scope is closer to the user's scope, so its implementation for nextTry is picked up
14:57:21Araqit should be closed per default and open explicitely
14:57:29Araqeither via {boundSymbol}
14:57:33Araqor via:
14:57:51Araq mixin symbolA, symbolB
14:58:31Araqbut yeah the old closeness rule would work too and would be consistent with template overriding, right?
15:02:12zaharyeven if I agree about the open vs closed question, I guess this is not what worries me. open vs closed affects lexical scoping and symbol resolution in the code - what's not clear to me is how bound symbols become part of the generic type when it comes to the instantiation cache
15:03:13zaharyare the bound symbols examined on a per-proc level or on a per-type level?
15:03:40Araqcurrently they are not examined at all
15:03:48zaharyalright, but what's the plan?
15:03:52Araqbut in my mind they would be per-proc level
15:04:04zaharyok, that's better - I imagine how it can work that way
15:04:26zaharyeach proc is only concerned with the symbols it actually used
15:08:08*Boscop quit (Disconnected by services)
15:08:10*Boscop joined #nimrod
15:08:30zaharymy vote would go for a mixin statement that could be used both at top level and inside a proc
15:09:07AraqI'm thinking about merging type params and symbol params as I think [T, S]{symA, symB} is a bit overkill
15:09:22Araqmaking it exactly like C++'s <> I think
15:09:31zaharyhmm, but bound symbols are not part of the type I think
15:09:42Araqyeah I dunno
15:09:50Araqit's wrong to mix up types and symbols
15:10:14zaharyinstead the cache criteria looks like this - generic types: T = string, U = seq[int], bound procs = user.hash, user.equals
15:10:28zaharyand that's on a proc level
15:10:52zaharythis can work for my AreIntersected example
15:11:04Araqbut the bound symbols need to be attached to the type so that {eq, hash} does not need to be repeated again and again
15:11:22Araqbut hrm that would be your module wide 'mixin' statement, right?
15:11:40zaharythat's why I propose that you just write once at top level in the module
15:11:40zaharymixin hash, equals
15:11:57zaharyah, you beat me to it :)
15:12:20AraqI always had the idea of:
15:12:28Araqgeneric [TKey, TValue]:
15:12:37Araq # lots of generic code here
15:13:14Araqto avoid the excessive type lists that plague the current design
15:13:25Araqit's easy to generalize to:
15:13:41Araqgeneric [TKey, TValue]{eq = `==`, hash}:
15:13:50Araq('generic' is a keyword)
15:14:20zaharylots of generic code - you mean lots of procs?
15:14:38Araqand types
15:14:54zaharywhat about my shorthand syntax:
15:14:54zaharyproc get(t: TTable, k: TTable.key) =
15:15:04zaharynot a lot of types here
15:15:43Araqwell excuse me, it's the first time you showed me that syntax ;-)
15:16:09zaharythat's the implicit generics? you haven't seen the TTable.Key part probably?
15:16:57zaharywhen you have type = TTable[Key: Hashable, Value] - you can use Key and Value later as nested types
15:18:23AraqI see
15:20:01Araqhow does that all work out with:
15:20:13Araqproc get(t, k) = ...
15:20:19Araq?
15:20:37zaharywell, that just get[T, U](t: T, k: U)
15:20:50zaharyno any interdependencies here
15:21:19Araqhm
15:21:31zaharyget(t: Table, k: Table.Key) will be different
15:21:31zaharyget[T](t: Table[T], k: T)
15:22:16AraqI suppose 'proc get(t,k)' is useful only if it's not exported
15:23:58zaharyyes - when you are lazy
15:29:07Araqwell hrm so we agree 'bind' should be the default and 'mixin' be explicit (somehow)?
15:29:44zaharyyes, I can see your point there
15:32:17zaharybut's since it's symbol lookup thing (which is connected to lexical scoping), I think the mechanisms to control it should be concerned with scopes, not types (i.e. similar to the bind statement)
15:34:41Araqoh well for a start, an unknown symbol should trigger a compilation error :D
15:35:10Araqcurrently an unknown symbol in a generic is no error ...
15:35:20AraqI think
15:35:44zaharyhu? can't imagine how that works :)
15:36:08Araqit's an nkIdent that will be looked up at instantiation time I think
15:36:34zaharyah, you mean the error will be produced later
15:36:54Araqyeah
15:37:34Araqhrm I like this {} stuff:
15:37:58Araqsort{cmp}(a) # no need for a proc var now
15:38:44zaharywell, this is a code bloat decision - generics vs run-time dynamism
15:39:04zaharyyou could have had sort(a) right now too
15:40:22Araqtrue
15:41:43Araqnow some different topic: about constructors
15:42:11zaharygotta go btw, we should leave it for tommorow
15:42:23Araqwell I now think a constructor is a nullary function
15:42:34Araqso that reserveSpace(mySeq, 10)
15:42:41Araqcan construct the elements
15:42:56Araqand 'var v: T' continues to work
15:43:07Araqthink about it ;-)
15:43:11zaharynullary? you mean it never accepts arguments?
15:43:16Araqyeah
15:43:23zaharywhat's wrong with C++ default constructors?
15:43:32Araqnothing
15:43:40Araqbut it's the only *constructor* there is
15:43:49zaharythere just may be some types for which var v: T is not allowed
15:43:50Araqthe other things are just weird functions
15:44:05Araq:P
15:44:47zaharyI liked your previous "everything is constructor" mindset better :)
15:45:20zaharybut if you mean - the nullary constructor is the only one where you'll use the constructor keyword/pragma - then ok, I guess that's right
15:48:03zaharyanother topic that I haven't mentioned in a while is placement constructors - or rather in-place construction of the return value of any proc
15:48:04zaharymem = alloc(sizeof(T))
15:48:04zaharymem <-- someProcReturningT()
15:49:44Araqwell we can talk tomorrow, but only I won't have much time tomorrow
15:55:59zaharyI'll be more frequently around next week
15:56:14zaharyI'm still recovering from my vacation habits - bye for now :)
15:57:31*zahary quit (Quit: Leaving.)
16:08:23*Boscop quit (Disconnected by services)
16:08:25*Boscop joined #nimrod
16:36:00*shevy quit (Ping timeout: 252 seconds)
16:48:18*shevy joined #nimrod
17:05:42reactormonkAraq: what if I need a random float?
17:31:19shevyI shall give you 42.0 !
17:54:55dom96We should just hire humans to randomly generate numbers for us :P
18:03:45shevyhehe
18:05:28reactormonkthey will suck
18:05:47reactormonkwhich might be good or bad, depending on who you hire
18:06:26reactormonkI suppose you know the part where humans can't generate random numbers
18:58:52reactormonk /join lisp
19:24:30shevy /join #pls-dont
19:26:25*mal``` quit (Ping timeout: 265 seconds)
19:26:34reactormonkshevy: had a space left in the buffer :-P
20:05:42*mal`` joined #nimrod
20:53:28Araqreactormonk: find and wrap the C proc that does it
20:59:35fowlAraq: i wrote template filterIt(seq, cond: expr; body: stmt): stmt but its clashing with the one from sequtils that only takes two args
21:00:19AraqI'm working on overloading resolution for templates that take a 'stmt' as last param
21:00:45Araqit's very easy to do, but term rewriting macros are much more fun :P
21:01:04fowlah
21:01:16Araqfor now you can simply do:
21:01:26Araqfrom sequtils import the_others_I_need
21:01:29Araqright?
21:01:54fowli didnt need anyhting from sequtils at the moment i just didnt want it to clash
21:02:10Araqalright
21:02:29fowlim going to start compiling useful scripts and examples on gist.github
21:03:33AraqI consider TR macros Nimrod's killer feature btw
21:03:52Araqyou simply can't do what they enable in C++ or D
21:04:18Araqand most Lisps don't come close either
21:05:51fowlI was going to do a STFL wrapper
21:06:00fowlbut i dont feel like doing a wrapper for wchar >_>
21:06:18Araqthere already is a wrapper for wchar
21:06:24Araqbut it's hidden :P
21:06:39AraqI needed that for nimrod's unicode support on windows
21:06:52fowlo
21:08:38fowlso its only in windows.nim?
21:08:45Araqno
21:08:52Araqstill searching, wait a sec
21:09:57fowlcast[LPTSTR](cast[ULONG_PTR](ToU16(i)))
21:10:04fowlim starting to regret opening windows.nim
21:10:19Araqdon't use windows.nim
21:10:23Araquse winlean.nim
21:10:38Araqand copy what's really needed from windows.nim to something else
21:10:56Araqwindows.nim is a disease
21:12:07Araqfinally found it
21:12:15Araqit's in lib/system/widestrs.nim
21:12:22Araqand already exported for you:
21:12:31AraqallocWideString
21:13:08fowlaha cool
21:13:44Araqand yeah you need to dealloc the string
21:13:49Araqno GC for it :P
21:16:01Araqlooking at the code it's not windows specific
21:16:16Araqbut it assumes wchar_t == utf-16
21:16:25Araqwhich is wrong on linux I guess :-/
21:17:10fowli cant find wchar_t wchar.h says to look in stddef.h but i dont have it
21:29:20fowlis there wrappers for langinfo.h and locale.h? :D
21:29:35Araqno and I don't want them
21:29:42Araqlocale.h is braindead
21:30:32Araqstrtod("1.3") # what do you mean, it depends on the locale? o.O
21:30:59Araqhow am I supposed to use that for parsing numbers in a configuration file then?
21:31:18Araqoh right, you can hack around it with setlocale
21:31:25Araqoh wait, that's not threadsafe ...
21:31:44Araqlocale dependency is a bug, not a feature
21:32:06Araqespecially in an otherwise barebones stdlib
21:33:11fowlstfl is too much work then
21:33:23Araqwhy?
21:33:35Araqwhat has it to do with locale.h anyway?
21:36:06Araqand don't get me wrong, you can of course wrap locale.h and langinfo.h
21:36:25AraqI don't really want them in the stdlib though
21:36:52fowlstfl needs it to initialize http://svn.clifford.at/stfl/trunk/example.c
21:37:26Araqomg
21:37:39Araqlol
21:37:44Araq"STFL is a library which implements a curses-based widget set for text terminals. The STFL API can be used from C, SPL, Python, Perl and Ruby. Since the API is only 14 simple function calls big and there are already generic SWIG bindings it is very easy to port STFL to additional scripting languages. "
21:37:54Araqonly 14 simple function calls
21:37:58Araqthat's good
21:38:38Araqit would be better if those 14 function calls wouldn't use obscure C features like langinfo and wide strings ...
21:39:11fowlyea it translated over with no issues https://gist.github.com/3559478
21:39:37fowlyes damn near every function takes widestring
21:40:39Araqdoes stfl work on windows?
21:40:56Araqthere are also ncurses wrappers somewhere
21:41:11fowli dont think so
21:43:01Araqlib/wrappers/pdcurses.nim
21:43:10Araqbut it needs a cleanup
21:54:25fowlis ncurses the same thing as pdcurses?
21:55:37Araqpdcurses is the portable version of it
21:55:43Araqwith minor api changes I think
21:56:22fowlok ill check it out in a few mins