<<04-05-2013>>

00:00:05Araq var x {.gensym, global.} = false
00:00:09Araq if not x:
00:00:14Araq x = true
00:00:18Araq s
00:00:33Araqonce:
00:00:36Araq mystuff()
00:01:03*Araq adds 'once' to his notes
00:01:08fowlah ok
00:02:04*gradha quit (Quit: bbl, have youtube videos to watch)
00:02:41fowlso if you have a line like `foo(bar: x(); y(); 32)` are x() y() 32 inside bar's stmt list?
00:03:03fowlfoo(bar:
00:03:07fowl x()
00:03:08fowly
00:03:12fowl32)
00:03:45Araqno that's where the grammar gets ambiguous
00:04:09AraqI think ...
00:04:25Araqhave to try that :P
00:05:13Araqwell it shouldn't parse
00:05:18fowlyea its def ambiguous i would probably prefer bar: (x(); y(); 32)
00:05:37Araqthat should work
00:23:12NimBotAraq/Nimrod 8924736 Araq [+0 ±4 -0]: bugfixes
00:25:48*q66 quit (Remote host closed the connection)
00:35:14*fowl quit (Ping timeout: 252 seconds)
00:38:24*fowl joined #nimrod
00:38:48fowlvarargs[typedesc] doesn't compile:/
00:39:27Araqmeh why should it ... typedesc is ugly anyway :P
00:45:25fowlzah thinks it should <_<
00:46:54fowlbbl
00:47:23fowlbtw im leaving to travel around for a while on monday so you probably wont see me much
01:37:36*fowl quit (Ping timeout: 258 seconds)
02:15:10*fowl joined #nimrod
02:30:12*fowl quit (Ping timeout: 264 seconds)
02:43:12*fowl joined #nimrod
02:46:23*Boscop quit (Disconnected by services)
02:46:26*Boscop joined #nimrod
02:48:40*fowl quit (Ping timeout: 256 seconds)
02:53:36*fowl joined #nimrod
03:09:36*fowl quit (Ping timeout: 258 seconds)
03:45:29*Endeg joined #nimrod
04:12:11*fowl joined #nimrod
04:17:03fowli got around not having varargs[typedesc]
04:17:23fowlinstead i use varargs[int, `getComponentID`] which takes a typedesc
06:28:21*zahary joined #nimrod
06:42:59fowlzahary: https://gist.github.com/fowlmouth/5516425
06:52:55zaharyhttps://gist.github.com/fowlmouth/5516425
06:54:00*OrionPK quit (Read error: Connection reset by peer)
06:54:26Araqhi Endeg, welcome
06:56:37fowlzahary: by hashtable you mean TTable[]?
06:57:11zaharyyes, you'll have to write a hashing function that just xors all IDs for example
07:01:45fowlwhy xor?
07:05:13zaharyit was just an example, but xoring preserves the entropy of the input bits more than adding for example:
07:05:14zaharyhttp://stackoverflow.com/questions/5889238/why-is-xor-the-default-way-to-combine-hashes
07:08:02Araqhashes.nim contains everything you need
07:08:16fowlhow would i use this
07:09:01fowli would assume id get a mask of the components with mask = mask or (1 shl component.id) and check against that
07:09:35Araqresult = !$( id1 !& id2 !& id3) # !$ = finish, !& = combine
07:13:12fowlwhat do i need it for?
07:13:32Araqto compute a hash value?
07:15:48fowlbut why do i need it
07:17:49zaharywell, fowl, how do you use a hash table with a new data type (list of component IDs in our case)? you need to define hashing function and equals function
07:23:07Araqwell we need to add proc hash(x: openArray[T]): THash to hashes.nim
07:23:26Araqas there is already a generic version for tuples
07:24:27Araqthen all that's left for fowl to do it:
07:24:42Araqproc hash(c: PComponent): THash = c.id
07:25:15Araqer ... no
07:25:20Araqnever mind
07:25:24zaharyit's even easier, because he's already ...
07:25:39fowlthey come in as ID
07:33:38Araqback to the discardable problem:
07:33:49Araqproc q(): int {.discardable.} = 13
07:33:56Araqproc p(): int = q()
07:34:02Araqecho p() # 0
07:34:43Araqthe problem is here that the intuitive behavior depends on p's return type:
07:35:01Araqproc p(): string = q() # should compile too and discard the value
07:35:28Araqmaking that dependent on the return type however looks like a horrible idea for generics
07:36:38Araqso I think the current rule "if in any way discardable, discard it" is better
07:38:33Araqint {.discardable.} is more like 'void' than like 'int' :P
07:38:55zaharyin the string case, we have a type mismatch between p and q?
07:39:05zaharythat's why it's discarded?
07:41:41fowli dont like that
07:42:02fowlit should try hard not to discard
07:42:51zaharyit could just produce a type mismatch error in the string case
07:50:25fowlis this what you mean, implementing hash() for seq[int]: https://gist.github.com/fowlmouth/5516425#file-components4-nim-L71
07:52:22zaharyyep,, feel free to add the generic version Araq suggested. it will just call the hash function for each element in the sequence/openarray
07:52:59zaharyresult = result !& hash(it)
07:55:27zaharyalso, TTable could have a C++-like indexing operator that creates the record if it doesn't exist and returns a var access to the it
07:56:55zaharyah, but it would be a bit tricky to exploit here as we need var: var variables to make use of it.
08:00:22AraqI always thought of the C++-like indexing as an abomination
08:00:38Araqa hack for the lack of a []= operation
08:01:19Araqzahary: why would there be a type mismatch?
08:01:37Araqoh I see
08:02:00zaharythe C++ operator is not great, when it's the only way to access the hashtable, but it helps for efficiency in situations like this one here
08:02:23zaharyso, it's good idea to offer it
08:04:10Araqwhat's the use case again?
08:04:40zaharysearch for a key in the hashtable, if you don't find it, insert it a value for the key
08:05:04Araqthat's what []= does
08:05:33zaharythis doesn't work, because you don't want to modify anything if there is an existing value
08:05:45fowlzahary: you store the vtable in the componentinfo struct right
08:05:47Araqso you want some testOrSet()
08:05:50fowlfor messages and such
08:06:00zaharytestOrSet that is also lazy
08:06:29Araqmeh, just return a 'ptr'
08:06:53zaharyin C++, you can write it likey this. ComponentData& cacheHit = cache[components]; if cacheHit == 0 { cacheHit = newComponentData; ]
08:06:57zahary}
08:08:05fowlahh that would be nice
08:08:16Araqyeah got it
08:08:23zaharyfowl, no. the vtable for polymorphic messages is stored in the TypeInfo
08:09:13zaharythere are some pointers to functions in the componentInfo, but they are component-centric like destroy(ComponentPtr), copy(ComponentPtr), etc
08:10:54AraqI wonder if we can get better language support for components
08:11:39Araqdoesn't look too hard for now:
08:11:55Araqtype T = object {.component.}
08:12:04Araq a: X
08:12:08Araq b: Y
08:12:35zaharyif you remember, I described our component injection rules once - "every time you see a ModelData component (server-side component), add ModelRendering (client-side)" that's one thing we can improve much in the language
08:12:35AraqT(a: xx) # construction with 'a' means 'b' doesn't exist
08:13:57zaharythe other possible improvements are moving much of the run-time functions for assigning IDs and sorting them to compile-time, but we need some more features for globally visible compile-time variables (that also behave properly with regard to partial recompiles)
08:14:39Araqyeah fowl recently stumbled upon that
08:14:59zaharyin the current fowl design there is no need for explicit component pragma. components are just regular types
08:35:33Araqzahary: in semArrayConstr we do:
08:35:45Araq# turn any concrete typedesc into the abstract typedesc type
08:35:47Araqif typ.kind == tyTypeDesc: typ.sons = nil
08:36:19Araqwhere typ is determined by the first array element
08:36:43Araqbut how does this work?
08:36:50zaharythis is to allow stuff like var myTypes = @[int, float, string]
08:36:59Araqyeah I figured
08:37:02Araqbut it's wrong
08:37:12zaharythe problem was that int and float are technically different types with regard to sameType
08:37:23Araq'int' then has type typeDesc but float has typeDesc[float]
08:37:59AraqI'm changing semArrayCosntr to use the new commonType()
08:38:01zaharywell, the proper fix is to use your new commonType
08:38:33Araqok
08:39:02AraqI didn't want to add that logic to commonType but I guess it's fine for 'if' etc too
08:40:02Araqwe could also perform a union of literals:
08:40:19Araqtype(if true: 3 else: 5) == range[3..5]
08:41:44fowlcan i do
08:41:56zaharywe could work towards more accurate replacement of range[begin..end]. something like a set of possible values/ranges
08:42:06fowlproc getComponent*[T](entity: TEntity; typ: typedesc[T]): ptr T = ...
08:42:28*Trix[a]r_za is now known as Trixar_za
08:42:46fowlbecause proc getComponent(ent: TEntity; T: typedesc): ptr T isnt working
08:43:04zaharyhmm, it should work. what kind of error are you getting?
08:43:40fowla40.nim(95, 59) Error: type expected
08:43:56Araqranges have lots of useful properties, arbitrary sets ... not so much
08:45:20zaharywhat kind of useful properties?
08:46:13zaharyfowl, some simple test cases work for me
08:46:16zaharyproc foo(x: int, T: typedesc): ptr T = return cast[ptr T](nil)
08:46:16zaharydiscard foo(10, string)
08:47:36zaharywhat's exactly on line 95,59?
08:49:18fowlok the problem was it is comflicting with the original getComponent[T]()
08:49:38fowlthe error was from lines calling the older functin
08:51:12zaharyI'm using getComponent for illustrative purposes btw. go ahead and name it something shorter like: ent.get(THealth)
08:51:57fowlsure
08:52:04fowlthanks for all your help on this btw
08:53:07zaharywelcomed, I was planning to develop something like this myself at some point
08:56:04Araq+ on ranges behaves properly
08:56:28Araq+ for sets bloats up the resulting set type
08:57:59Araqbut ok N*M is not that bad ... but then why is it useful?
08:59:37fowlAraq: everyone i show nimrod to is confused by array[0.. <32, ..]
09:00:07Araqwell you already made a feature request
09:00:29Araqand how do you do: array['a'..'z', ...] otherwise? :P
09:01:05fowlim not saying it should be changed, its useful imo
09:01:27fowlbut 99% of the time you're going to start with 0 and end with MaxNum - 1
09:01:41zaharyAraq, I meant mostly for this internal types that the compiler use behind your back
09:03:28zaharyas for the old array[10, T] idea, it was Araq that originally proposed it :)
09:30:28fowldid you want hash[T] for seq[T] or openarray/varargs?
09:30:52fowli just thought about it and it couldmatch more than seq[]
09:50:53Araqopenarray[T]
09:55:25fowlzahary: where are the entities stored in your impl and are your "systems" like my implementation where they match a set of components and act on them
09:56:39zaharywe discussed this the other day. your game is likely to have some type like "World" or "Scene" where they will be collected
09:57:47zaharyare are probably going to use a physics engine with spatial partitioning or your own quad trees, portals, etc for Frustum Culling
09:59:17*shevy joined #nimrod
09:59:21shevyhi
10:02:04zaharyI'm not sure I understood your remark about "systems" that match a set of components and act on them. are these actions in the game loop or actions at creation time? in our system, components react to/implement messages (method calls) - the game loop code executes various messages over the entities and depending on what components build up the entity, it will perform different stuff
10:06:04fowlso when a message is sent out its sent to all entities? how do you know what entities get which messages? at creation they are basically bare
10:06:30zaharythat's what the vtable inside the TypeInfo is for
10:06:39Araqhi shevy, wb
10:07:11zaharythere are 3 types of messages - statically dispatched to a certain component. if has(Component): get(Component).doMessage(args)
10:08:11zahary2) dynamically dispatched to a single component
10:08:11zaharylet (offset, proc_ptr) = entity->typeinfo->vtable[messageID]
10:08:11zaharyproc_ptr(entity->data[offset], args)
10:09:53zahary3) dynamically dispatched to every component that implements them (multicast messages)
10:09:53zaharylet runlist = entity->typeinfo->multicast_vtable[messageID]
10:09:54zaharyfor msg in runlist: msg.proc(entity.data[msg.offset], args)
10:10:10zaharynow, the next question is how to populate these vtables
10:11:15zaharythis is a bit more complicated to explain, but it's done in 2 steps. First in addComponent we create a VTableFiller function for the component (this function walks over all the dynamically dispatched messages the component implements)
10:12:17zaharyin C++, I obtained the list with a special macro looking like this
10:12:17zaharyREGISTER_COMPONENT(Foo, MSG(Bar) MSG(Baz))
10:13:35zaharythis compiles into a function that does something like this void VTableFiller(VTableBuilder& builder) { builder.addImplementation(MessageID(Bar), &Foo::Bar); … }
10:15:25zaharythe CreateTypeInfo function sets up a VTable builder and executes the VTableFiller for each component type in the current TypeInfo - the end result is a properly populated vtable for this combination of components
10:23:48fowlok i think i understand
10:27:27*q66 joined #nimrod
10:30:06fowlwhat about behavior that depends on multiple components
10:33:31zaharywell, these are the multicast messages
10:34:17zaharyyou can have what we called "combiners" for them - an algorithm that reduces the return values of each component implementation to a single value
10:34:29zaharye.g. sum combiner for a "getSize" message
10:34:50zaharyI wrote you some more pseudo-code here:
10:34:50zaharyhttps://gist.github.com/zah/5517076
10:35:11*Trixar_za is now known as Trix[a]r_za
10:39:37*Araq wonders how long until zahary will do: template `->` (a,b: expr): expr {.immediate.} = a.b
10:41:06zaharysorry, just a habit :) I hate it, but still most of my days is spent writing C++
10:41:32fowl # expr[string] means compile-time string constant
10:41:41fowlwill this match "hi" and "hi" differently
10:42:10zaharyis there a typo here? "hi" == "hi" ?
10:42:47fowlno but they are different constants
10:43:44zaharyit will compare by value
10:43:53zaharyand instantiate for each unique value
10:46:34fowli need to read the docs again
10:46:54fowlStatic statement/expression never saw this before
10:48:31zaharyI think I've documented them, but you have to look in the 0.9.2 docs
10:50:33Araqno need to apologize ... in fact I've been playing with:
10:50:37Araqinclude cppmode
10:50:44Araqinclude pythonmode
10:50:47Araqinclude rubymode
10:51:02Araqthat emulate these things as far as possible/reasonable
10:52:01Araqwell it's obviously nothing serious, but it may show off the expressivity nicely
10:52:34zaharyand having aliases for standard APIs in the respective language is nice
10:53:12fowlAraq: you should definitely gist more things
11:21:50NimBotAraq/Nimrod c164994 Araq [+1 ±3 -0]: fixes #117
11:22:30Araqcan anyone please the newparser branch? it crashes our test system for unknown reasons
11:22:49Araqlikely the many branch switches screwed things up :-(
11:22:56Araqbut my master can compiler newparser
11:23:00Araq*compile
11:28:53zaharyI would, but I gotta go now. should be back in few hours
11:40:22*zahary quit (Quit: Leaving.)
11:49:30Araqfowl: sorry but I said openArray[T], not varargs[T]
11:50:35Araqvarargs should be used sparingly as it often matches too much "disabling" type checking and causing bugs
12:18:47*fowl quit (Ping timeout: 255 seconds)
13:30:49*xcombelle joined #nimrod
13:33:44*xcombelle quit (Read error: No route to host)
13:34:47*xcombelle joined #nimrod
14:13:07*shevy quit (Ping timeout: 264 seconds)
14:25:54*shevy joined #nimrod
14:25:56*gradha joined #nimrod
15:02:07*zahary joined #nimrod
15:08:09*Endy joined #nimrod
15:13:23reactormonkAraq, I assume you know the merits of mutable keys in #418
15:14:27Araqdo you mean "immutable", reactormonk?
15:15:34dom96hello
15:15:48Araqah finally!
15:15:50Araqhi dom96
15:16:03Araqthe test system crashes :-(
15:16:12dom96yeah, I saw.
15:17:00dom96that's weird
15:17:28dom96Can master compile newparser?
15:17:37Araqmy master can do it ... but hm
15:17:44Araqmy master ain't up to date
15:18:20dom96perhaps nimbuild should separate the nimrod binary based on the branch
15:18:35Araqmaybe
15:21:27reactormonkAraq, a seq is immutable?
15:21:58Araqreactormonk: no it's not but it doesn't matter, it's copied
15:22:12Araqimmutability has no advantage for dict keys, sorry
15:48:36*OrionPK joined #nimrod
16:26:24Araqzahary: your changes to semInstantiationInfo break bootstrapping
16:27:07Araqwell that changes assumes system.nim has the new signature for instantationInfo
16:27:18Araqwhich is not the case for the newparser branch
16:28:10Araqoh well I'll simply merge it into newparser ... never mind
16:39:53zaharyconstuction expressions cannot be used in const context - is this a known bug?
16:51:00*zahary quit (Ping timeout: 276 seconds)
16:52:30gradhawhat's the rationale for --def to tell about the line a symbol appears in and point to the end of the symbol rather than its beginning?
16:56:54Araqgradha: implementation reasons, I'll fix it
17:01:53gradhafor https://github.com/Araq/Nimrod/issues/415 it may be good if --def could throw in fuzzy suggestions when nothing matches, so even if there is no 100% match you still can get something
17:02:29gradhamaybe then idetools could return defSuggest instead of just def to imply it's not 100% match
17:03:02Araqthat's what --suggest does already ... fuzzy matching
17:03:13Araqit's a good idea to denote that in the output
17:03:37gradhabut def only returns one, right?
17:05:13gradhaI think there's a slight difference between --def and --suggest
17:05:38gradha--def is when you want to jump to somewhere, --suggest is when you are not sure of a name or want to autocomplete
17:06:57Araqyeah ... indeed --def and --suggest are not the same thus we used 2 different names :P
17:07:12gradhait's a corner case anyway, having written the proc name and not remembering the parameters, so it's like a --def --suggest at the same time
17:07:35gradhaI just find it convenient to jump to --def to see the prototype without having to grab the docs
17:08:22gradhanot that it matters much, I remove the parenthesis and it tends to work then
17:08:30Araqhmm
17:08:40Araqthat "tends to work" is the real problem
17:08:55Araqonce we got past that stage we can make it smarter
17:10:39gradhamaybe what I want could be achieved with the vim plugin first using --def and if nothing comes out throwing an additional --sugest to see if there's something similar
17:11:59Araqno --def should deal with partial declarations
17:12:11Araqif nothing else matches
17:12:37Araqbut as I said, I need to get the basics working reliably
17:13:41Araqer ... did someone modify osproc?
17:14:13Araqor nimrod.cfg?
17:15:11Araqhuh ... strange ... first step of boot doesn't produce any output anymore
17:15:22gradharecently I removed the executable bits
17:15:37Araqthat shouldn't affect anything
17:15:53Araqwell ... it works again now ... weird
17:16:09gradhamaybe your machine is failing like mine did with the osproc tests
17:19:33Araqso I merged master into newparser and bootstrapping rises from 2.7s to 3s again ... what are you guys doing on master?
17:19:51gradhaparty hard?
17:20:46NimBotAraq/Nimrod 2c8fe3e Araq [+0 ±2 -0]: fixes #395
17:20:46NimBotAraq/Nimrod defe341 Araq [+1 ±0 -1]: added distinct array test
17:20:46NimBotAraq/Nimrod 7aa2b3e Araq [+0 ±1 -0]: fixes #394
17:20:46NimBotAraq/Nimrod ce9809c Araq [+0 ±1 -0]: fixes #393; now works with backticks
17:20:46NimBotAraq/Nimrod 1e10a2b Billingsly Wetherfordshire [+0 ±1 -0]: Update evals.nim
17:21:28Araqthat's not the relevant history, dom96 :P
17:23:10Araqhi Endy, welcome
17:23:13dom96huh?
17:23:27dom96what do you mean?
17:23:38Araqwell I committed things to newparser and then merged with master
17:23:48Araqnimbot only lists the merge though
17:24:14dom96Maybe it stripped the other commits
17:25:20dom96ugh, what the hell.
17:25:31dom96oh nvm
17:38:47gradhawhat should I import to get access to compiler/ast:TSymKind?
17:40:14Araqimport compiler/ast ?
17:40:38gradhaError: cannot open 'compiler/ast'
17:41:05Araqwell that's some path problem
17:41:48gradhaah, compiler is not in the stdlib
17:47:04Araqnor should it
17:50:49*shevy left #nimrod ("I'll be back ... maybe")
18:54:53gradhaI'm parsing the output of --def and it sometimes idetools returns 7 or 8 columns
18:55:21gradhait returns 7 columns when you ask it for a proc which is being defined on the very same line, so idetools doesn't return the prototype signature
18:56:21gradhahmm... or maybe split() does "group" the empty columns together with the next
19:01:05*Endy quit (Ping timeout: 255 seconds)
19:01:51gradhaaaah, was using the split version which uses the set
19:18:50*xcombelle quit (Remote host closed the connection)
20:28:53*zahary joined #nimrod
20:29:53Araqzahary: nope ... nkObjConstr should work at compile time
20:32:12zaharyI got disconnected, but the problem was that object types are not allowed for const values
20:32:33Araqyeah well that is not supported by the C backend
20:33:59zaharyyeah, I remember that we've discussed it before
20:35:45Araqit's easy to implement for objects without the RTTI field
20:36:40zaharyand I guess some compile-time values don't reach the run-time at all, which is another attack vector
20:40:38Araqok, here is a new problem:
20:40:50Araqproc jsonToBSon*(j: PJsonNode, oid: TOid): TBSon =
20:40:52Araq init(result)
20:40:53Araq add(result, "_id", oid)
20:40:55Araq for key, val in items(j.fields):
20:40:56Araq jsonToBSon(result, key, val)
20:40:58Araq finish(result)
20:41:10Araq'finish' is a discardable 'cint'
20:41:36gradhawarning
20:41:59Araqwhich luckily doesn't match TBSon
20:42:10Araqso it now simply doesn't compile anymore
20:42:38Araqhowever good luck finding the bug if TBSon should be an alias to int
20:43:26AraqI implemented the rule that 'result = x' triggers some enforced void context to deal with this
20:43:36Araqso that
20:43:39Araqproc p(): int =
20:43:41zaharyit's true that result variables and implicit returns are somewhat scary combination
20:43:43Araq result = 13
20:43:51Araq q()
20:44:04Araqwhere q() is an discardable int
20:44:16Araqdiscards the value as obviously you want to return 13 here
20:44:23Araqand not what 'q' returns
20:44:41Araqhowever the TBSon example doesn't even contain an assignment to 'result'
20:44:54gradhawhy would q() be assigned to result?
20:44:56zaharywell, it uses result in a var context
20:45:06Araqyeah
20:45:29Araqwell so the new rules would be "usage of 'result' enforces a void context"
20:46:26dom96
20:46:56gradhadom96 is trying to say something here
20:47:14*dom96 is trying to program in Whitespace
20:47:54gradhaAraq: why is a problem having a discardable expression as the last one? does it get assigned to result implicitly?
20:48:05Araqgradha: exactly
20:48:42gradhaI thought you HAD to assign to result, or return something
20:52:25Araqthat used to be the case ...
20:53:04Araqthen we allowed proc p(): T = q() to return implicitly
20:53:08Araqbut not:
20:53:12Araqproc p(): T =
20:53:15Araq q()
20:53:40Araqbut that was mostly an implementation bug :P
20:57:49gradhadom96: your exams are in whitespace? sounds like fun
20:58:02dom96gradha: I wish
21:00:21Araqwell? any solutions?
21:01:00gradhaI would implicitly assing q() to result
21:01:19Araqgradha: that's bug prone
21:01:28gradhabugs are fun
21:01:36Araqnot for me
21:02:06gradhaI don't think it's obvious you want to return 13 in that case
21:02:17gradha13 could be the default value, with q() performing the actual calculation
21:03:02gradhaif you feel like it's bug prone, maybe let the compiler warn users to explicitly assign q() to result or discard it
21:03:47gradhaso let's say that before q() you have p(), which is also a discardable
21:04:10gradhaand you discard q(), would then p() get assigned implicitly to result or that only counts for the last REALLY last expression?
21:04:25Araqlast expression.
21:04:48gradhaok, pedantic warning then and force the user to write code defensively
21:05:24Araqmeh warning suck
21:05:30gradhaI can already hear the screams of all the people getting warnings for the one liner case
21:05:46Araqand I don't want to 'discard' a discardable
21:05:50Araqexplicitly
21:05:55Araqas that misses the point
21:06:02Araqalso consider this:
21:06:12Araqproc sumfile(): int =
21:06:19Araq f = open(...)
21:06:25Araq result = sum(f)
21:06:32Araq f.close
21:06:53Araqwhere 'close' is C-like returning an int for error codes
21:07:17Araqit doesn't make sense to assign that to 'result'
21:07:29gradhamaybe we can improve upon that, how would the code be if you used a finally: as a statement to close the file?
21:08:51gradhawould the finally: block be assigned to result despite not being logically writen as the last expression?
21:08:52Araqthat's another problem that I ignored for now
21:09:00Araqand yes
21:09:06Araqthat's exactly what the compiler does
21:09:09gradhalovely
21:09:36Araqthat's easily fixable though
21:09:37dom96Araq: What happened to determining if 'result' has been assigned to?
21:09:50gradhaso you dislike warnings, make it an error then
21:10:08Araqwhat's the error condition?
21:10:28gradhaanything discardable as the last expression, with the fix being a new keyword "wantit"
21:10:36gradhaor maybe wanted
21:10:38Araq"I could discard that value here and that's what you meant, but I make you write 'discard' instead"?
21:11:11gradharather, "I won't allow you to write ambiguos code, so you either discard it or want it"
21:11:27Araqdom96: I don't understand your question; in the mongodb example there is no assignment to 'result'
21:11:37gradhawanted would be like the hint to the compiler that you want the discardable value
21:11:44Araq"wantit" would be "return" btw
21:11:54gradhathere you have it, problem solved
21:11:58dom96Araq: What about init(result) and add(result, "_id", oid) ?
21:12:23Araqdom96: that solution looks fishy to implement :P
21:12:42Araqbut if there no better ideas ...
21:12:44dom96trust me :P
21:12:58gradhanote however that "return" alone is not enough, the compiler would still error with a discardable as the last expression unless you used discard on it
21:13:24gradhamaking the last expression explicit seems to solve all the ambiguity
21:15:34zaharybtw, it's very unlikely that result will be mentioned in non-writable context so the rule could be really crude - if there is result identifier appearing at all, switch to safe mode
21:15:42dom96the whole point of all this is to allow implicit return of things though.
21:16:20zaharystill, having such a safe mode is rather peculiar, but without it I guess we better drop implicit returns altogether
21:17:35zaharyI could enjoy the result rule - it's more unfriendly to novice users
21:17:43dom96combining implicit returns, the implicit result variable and {.discardable.} is starting to seem like a start to a lot of trouble.
21:18:23gradhaimplicit returns are contrary to discardable, they would be ok if discardable didn't exist at all
21:19:03gradhain a way both discardable and implicit returns introduce ambiguity in a non ambiguos system, mixing both is what leads to the problems
21:19:24Araqzahary: yeah well I'll try the really crude rule now
21:19:49Araqas I said it's ugly to implement but meh
21:20:50gradhabtw the compiler is lacking a --pedantic switch for serious adoptions, you can't ignore the market for pedantic programmers
21:21:44gradhain the future I'll make my own language, with an --anal compiler switch
21:21:58Araqthe pedantic programmers are all still in the "macros are evil mmmkay" mood
21:22:13Araqwe lost them by making >= a template
21:22:23gradhaand negation IIRC
21:24:34gradhathe correct way of checking for not nil was "not blah.isNil()", right?
21:24:52Araqblah != nil ?
21:25:15gradhadidn't that have problems for strings because the equality had some "deep" stuff going on?
21:26:22gradhamaybe not http://forum.nimrod-code.org/t/122
21:26:24Araqthat was for sequences
21:26:59Araqbut sure if you never know what type you're dealing with, use isNil
21:41:44zaharyAraq, should I push new commits to master? why haven't you merged the newparser into master, but the other way around? there are still some outstanding issues?
21:42:25AraqI did it the other way run for nimbuild; once everything compiles again I'll merge back to master
21:43:06Araqbut as you can see I'm still fighting to get all the details of expr/stmt unification right
21:43:24Araqwhat do you want to push to master?
21:45:33zaharyI'm using my work laptop now and I found some commits here from 2 months ago :) beside that, I have fixes for my caas tests from yesterday.
21:46:02Araqwhat about that varargs vs generics test case btw?
21:46:18Araqisn't that pretty arbitrary anyway what to choose?
21:46:44zaharyyes, I guess we need to discuss it
21:48:17Araqyour 'withVarargs "string"' should match the generic version I think
21:48:23gradhaall praise the hyperlink, it's awesome
21:49:00zaharyseemed right at the time I filled the bug, because the original problem was that I was not able to define stream.write(strings) # like echo
21:49:11zaharybut since then, I have some doubts myself
21:50:03Araqwell what it currently produces is exactly what I would have imagined
21:50:19Araqalso it's not free to build an array to pass it
21:53:29Araqbtw do an iterator items(x: varargs) and you can "iterate" over everything; varargs are pretty dangerous that's why they are now separate from openArray
21:53:47Araqlen(myObject) used to work for everything and produce 1 ...
21:54:01Araq~> len([myObject])
21:55:09zaharyif varargs reads as "zero or more strings", and the rule is "exact matches are preferred to generic matches", I could argue that these are still "zero or more exact matches"
21:56:33Araqyou could argue that but then I'd argue that varargs should really be "zero, 2 or more"
21:57:01Araqand 1 being a special non-exact match :P
21:57:24zaharyI wanted to support this in my hypolang btw. foo(x: varargs[string], y: varargs[int])
21:57:55zaharynot related, but I wanted to mention it
22:00:01Araqwhat's the problem with stream.write(strings) ?
22:00:46zaharythere is stream.write(T) that gets picked up. you could do stream.write(string, varargs[strings])
22:01:14Araqyeah but then what's wrong with that?
22:01:22Araqdoes the T version the wrong thing?
22:04:37zaharythe T version does binary writing, which is wrong for the string type (it writes the pointer values).
22:04:45Araqtrue
22:05:04Araqbut then there is: proc write*(s: PStream, x: string)
22:05:15Araqor is that new?
22:05:59zaharyno, that's old. this is the one I hoped to change to varargs, but failed
22:06:12Araqin fact ... the generic and yet low level proc should be deprecated
22:06:17Araqlooks suspicious
22:06:33Araqyou can always use writeData for low level writing
22:06:59zaharythat could be the case there, but this just served as a motivating example to ask these questions
22:07:12Araqyeah sure ok
22:28:11gradhawhat could I try/except to catch ctrl+c in a commandline program?
22:29:07Araqsystem.setControlCHook ?
22:31:49gradhahmm... so how would I install a proc which aborts a while loop but resumes after it? maybe make the hook be actually the cleanup/end code and call it unconditionally at the end?
22:32:38gradhasetControlCHook(nil) uninstalls the hook?
22:33:51AraqI dunno just make the while loop check some global flag that the control hook sets
22:34:38gradhagood idea
22:42:56*zahary quit (Ping timeout: 255 seconds)
22:45:44gradhasweet, 45 minutes to process itself and generates 4MB of html
22:53:56*gradha quit (Quit: bbl, have youtube videos to watch)