<< 22-07-2013 >>

00:00:43EXetoCa type declaration that includes the equal sign and then some metatype if you can call it that (object, tuple, enum..)
00:01:19BitPuffinEXetoC: hrm
00:01:23*DAddYE quit (Ping timeout: 240 seconds)
00:01:35BitPuffinEXetoC: but basically all of this is because the parameterization can't hold values?
00:02:32EXetoCthe implementation issue doesn't have to do with that any way. if "type x" is declared, but "type x =..." isn't found at a later stage, then it's an error
00:03:29EXetoCsince it's as meaningless as "proc f()" on its own
00:03:42BitPuffinEXetoC: but type x = IS found on my side
00:05:04EXetoCnot for Vector, if what you told me is accurate
00:05:32BitPuffinEXetoC: lemme paste
00:05:42EXetoCVec3 is basically just an alias, but if the type it refers to (Vector) doesn't have an impl, then it's not valid
00:08:13BitPuffinEXetoC: exactly it's supposed to be an alias
00:08:28BitPuffinEXetoC: https://gist.github.com/BitPuffin/6e72164f232d12b16bff
00:10:49BitPuffinEXetoC: doesn't that count as an impl?
00:12:20EXetoCyes, but the compiler doesn't even accept the integers, so it's kind of hard to reason about
00:12:54BitPuffinEXetoC: yeah but if it did?
00:13:48BitPuffinthen this would be correct wouldn't it?
00:14:21EXetoCBitPuffin: I guess, but another problem is that * is on the wrong side of the type parameter list
00:14:27BitPuffinbecause I'm not gonna change this code, it's the way it should be, they have to fix dat compiler :P
00:14:50BitPuffinEXetoC: okay, fixed that
00:15:39BitPuffinEXetoC: I also changed D to be int
00:15:52BitPuffinso now it's TVector[T, D: int]
00:16:00BitPuffinand now the error is type mismatch
00:16:09BitPuffinand I'm assuming that's the error because it can't hold the value
00:16:53EXetoCyup, that just adds a type constraint
00:17:08BitPuffinWell then
00:17:13EXetoCbut I guess you can specialize that way
00:17:19BitPuffinthat's enough for this evening
00:17:36BitPuffinEXetoC: yeah well 1..D pretty much means D should have the constraint
00:18:07BitPuffinEXetoC: I hope I can get them to fix this like tomorrow or something, really hope I'm not gonna have to do it myself cuz I'm not sure I can!
00:18:10BitPuffinnighty night!
00:18:13BitPuffinthanks for the help
00:18:19EXetoCjust check the issue tracker :p
00:18:21EXetoCcya
00:19:08EXetoCmaybe it's zah who's working on this stuff. something similar at least
00:20:01BitPuffinEXetoC: don't see it on the tracker :o
00:20:27EXetoCno, but there's a huge pile there
00:20:36EXetoCbut we'll see
00:21:27BitPuffinhmm
00:21:31BitPuffinOh well
00:21:48BitPuffinwe'll have to discuss further tomorrow, hopefully in the company of Araq
00:21:53BitPuffinsee you
00:25:14EXetoCbbbbbb
00:26:35*BitPuffin quit (Ping timeout: 264 seconds)
00:52:47*EXetoC quit (Quit: WeeChat 0.4.1)
02:04:24*q66 quit (Quit: Leaving)
03:13:20*DAddYE joined #nimrod
04:06:54*XAMPP_ joined #nimrod
04:09:23*Araq__ joined #nimrod
04:18:29*Araq_ quit (*.net *.split)
04:18:29*XAMPP quit (*.net *.split)
05:09:15*DAddYE quit (Remote host closed the connection)
05:09:45*DAddYE joined #nimrod
05:14:43*DAddYE quit (Ping timeout: 276 seconds)
05:22:30*DAddYE joined #nimrod
05:29:50*Araq__ quit (Read error: Operation timed out)
05:30:54*Araq_ joined #nimrod
05:32:27*AndChat-320025 joined #nimrod
05:32:32*Araq0 quit (Read error: Connection reset by peer)
05:43:49*Araq_ quit (Read error: Operation timed out)
05:44:50*Araq_ joined #nimrod
05:46:20DAddYEhi thereeeeeeee
05:46:32DAddYEquick info how much bad a thing like: var s = cast[ref char](sizeof(char).alloc0)
05:46:43DAddYEcasting to a ref means put back it to the gc?
05:46:53DAddYEAraq: ^^
05:48:47DAddYEalso if I want to create a unsafe no traced T is there some other than: sizeof(T).alloc ?
05:49:03DAddYEalso if I want to create a unsafe no traced T is there some other than: cast[T](sizeof(T).alloc) ?
05:49:11DAddYEAraq: ^^
05:56:50*DAddYE quit (Remote host closed the connection)
06:08:58*DAddYE joined #nimrod
06:11:00*AndChat-320025 quit (Ping timeout: 268 seconds)
06:37:37*Araq0 joined #nimrod
06:42:55*DAddYE_ joined #nimrod
06:42:56*DAddYE quit (Read error: Connection reset by peer)
06:48:32*DAddYE joined #nimrod
06:48:32*DAddYE_ quit (Read error: Connection reset by peer)
07:03:54Araq_DAddYE: casting ptr to ref doesn't work
07:04:07Araq_another way to create an unsafe ptr is to use 'addr'
07:05:33DAddYEthe pointer point in something that is still in the gc
07:05:39DAddYEhere an example
07:05:40DAddYEhttps://gist.github.com/DAddYE/69c70bfcc5882ba3f039
07:06:14DAddYEI need to know if this: https://gist.github.com/DAddYE/69c70bfcc5882ba3f039#file-works-nim-L6
07:06:40DAddYE1) is a good way, 2) if put this in the gc
07:09:04DAddYEhttp://fs.daddye.it/95St/29ItaFCq do you know why I've `dirty` things?
07:11:18Araq_no it's not valid code
07:11:26Araq_it'll crash one way or the other
07:11:45Araq_you can use unsafeNew() for what you have in mind
07:11:52Araq_... perhaps
07:15:09DAddYEI thought about that for interop between ref and pointer
07:15:22DAddYEsometimes I need to manually alloc/dealloc
07:15:24DAddYEsome not
07:15:39DAddYEso in my mind I mapped procs to get a ref
07:16:01DAddYEbut if I need to manually alloc/dealloc
07:16:09DAddYEI'll use the cast in the gist
07:16:24DAddYE(just experimenting)
07:16:24DAddYE:D
07:19:13Araq_do not cast from pointer/ptr to ref!
07:19:28Araq_it's a crash waiting to happen
07:24:30DAddYEsure
07:24:42DAddYEcan you explain me way?
07:24:45DAddYEcan you explain me why?
07:26:34Araq_because the write barrier assumes there is an RC field at a negative offset
07:26:54Araq_when the memory comes from anywhere (include alloc) this is not the case
07:27:07Araq_so it will access random memory instead
07:27:22DAddYEok
07:28:05DAddYEso there is no easy way to do "duck typing" between pointers and refs
07:28:44DAddYEbtw thanks for the explanation now sounds plausible to me
07:37:40DAddYEbtw I almost finished the a web server with joyent/http_parser and libuv
07:38:02DAddYEI need only an event emitter
07:38:11DAddYEand I'm looking at events.nim
07:40:42Araq_dunno if it has been updated to support closures
07:42:08DAddYEyes
07:42:23DAddYE(old syntax) but proc (){.closure.}
07:42:26DAddYEis here
08:29:30*DAddYE quit (Remote host closed the connection)
08:30:02*DAddYE joined #nimrod
08:34:41*DAddYE quit (Ping timeout: 268 seconds)
08:37:04*zahary joined #nimrod
08:43:58*zahary left #nimrod (#nimrod)
09:30:30*DAddYE joined #nimrod
09:36:37*DAddYE quit (Ping timeout: 248 seconds)
10:11:45*q66 joined #nimrod
10:33:44*DAddYE joined #nimrod
10:40:53*DAddYE quit (Ping timeout: 240 seconds)
11:00:42*Araq_ quit (Quit: ChatZilla 0.9.90 [Firefox 22.0/20130618035212])
11:25:32*EXetoC joined #nimrod
13:13:32*Amrykid quit (Changing host)
13:13:32*Amrykid joined #nimrod
13:22:30*Araq_ joined #nimrod
13:42:26*Araq_ quit (Quit: ChatZilla 0.9.90 [Firefox 22.0/20130618035212])
14:31:28EXetoCmoo
14:36:46*AndChat-320025 joined #nimrod
14:36:47*Araq0 quit (Read error: Connection reset by peer)
14:38:58AndChat-320025Exetoc you can pass 1..n to a generic
14:39:53AndChat-320025A range but not a single number for now
14:40:25*AndChat-320025 quit (Client Quit)
14:49:17EXetoCoh
15:37:30EXetoCI guess many people have needed that then. When was it added?
16:33:53*DAddYE joined #nimrod
16:35:54DAddYEmooooooooooooooooooooooooooooooooooooooooooooooooooooooooooorning
16:42:03EXetoChi
16:49:59DAddYEEXetoC: do you know how I can alloc (unsafe) T ?
16:50:15DAddYEI mean there is T.sizeof.alloc
16:50:33DAddYEbut then can be fine cast[T](T.sizeof.alloc) ?
16:55:17EXetoCunsafe how? there's also unsafeNew
16:55:22EXetoCI guess that's correct
16:57:17EXetoCit's just a little ugly, because you're making it look like alloc is conceptually a member of int, but whatever floats your boat
16:58:07DAddYEfor unsafe I mean something that should run out of GC so non traced
16:58:26DAddYEunsafeNew can be a choice but the doc say that is traced so subject to be GC'd
16:58:56dom96I wanna go to the emerging langs conference with Araq :(
16:58:58EXetoCyeah, so untraced seems to make more sense
16:59:00dom96also hi
16:59:27EXetoCbut yes your approach seems to be correct
16:59:40EXetoCdom96: me too, but can I get there somehow if I don't have any money
17:00:14EXetoCI have a bike, but it might take some time to get there, and it's a mountain bike
17:01:01dom96hrm, how about we try to grab a ride all the way to St. Louis by hitchiking :P
17:02:20EXetoCc(:)-<
17:02:36dom96I wonder what the record for the longest distance travelled by hitchiking is.
17:03:02EXetoC> 10 miles
17:12:38EXetoCis anyone confused by the usage of wnd rather than window? I'm not, which is why I just made a gazillion changes to nim-glfw3
17:13:04dom96why not 'win'?
17:13:18dom96makes more sense IMO
17:13:55EXetoCI don't know
17:13:57dom96DAddYE: What are you up to?
17:16:19dom96And why are you using libuv and not the asyncio module?
17:55:37Araqwnd ... hm is pretty uncommon I think
18:03:32EXetoCoh well, it's easy to change
18:05:59EXetoChwnd might be the culprit
18:15:25DAddYEdom96: is it just an exercise to learn a bit more the langauge
18:35:17*Mat2 joined #nimrod
18:35:21Mat2hi @ all
18:36:55Araqhi Mat2
18:37:15Araqin what way is IO's object model special
18:38:27Araq"Io is a prototype-based programming language inspired by Smalltalk (all values are objects, all messages are dynamic), ..."
18:39:13Mat2you do not handle classes, only clone objects
18:39:29Araqhow does that help?
18:41:54Mat2each object can be used as prototype for a large set of variants without explicit declaration overhead
18:43:27Araqthe context was python's small integer object caching
18:47:18Mat2because the slots are non determinated at runtime the actual vm-state is identical to the object-state. For handling of internal caches of modern cpu's that's ideal
18:47:45Mat2so special cache-handling can be avoided
18:50:14Mat2in Phyton these equivalence can't be granted and this lead to an otherwise avoidable overhead for efficient object handling in relation to the type system
18:53:14Mat2cache misses can cost a lot of clock cycles...
18:54:30Mat2specially for out-of-order, super scalar processor architectures with very large pipelines (like all Intel and AMD cpu's)
18:57:24Mat2its an analog problem to the need of synchronisation between the virtual program-counter of a threaded VM and the cpu internal branch-target buffer for performance
18:59:01Mat2IO's VM can simple reuse the internal cpu caches because each object is a single entity and accesses to objects are always handled the same way, though accessing slots (indirect pointers)
19:00:09Mat2whereby a class-based approach differenciate these dependent of the class type (virtual classes, abstract classes, template classes etc.)
19:02:07Mat2so the last time I had taken a look at IO's sources, there VM do not cache anything (its not needed)
19:03:31AraqI can't really follow sorry
19:03:45Araqin python the caching is necessary because of the uniform object representation
19:04:05Araqwhere even for small ints NO ponter-tagging etc. is done
19:04:13Araq*pointer-tagging
19:06:52Araqso instead of newInteger(13) integers[13] is performed
19:07:47Araqmy point was that with an explicit target you can do target.bigInt[0] = 13; setLen(target, 1); instead
19:08:38AraqCPU caches have nothing to do with it, it's about avoiding allocations and thus GC pressure
19:09:25dom96If there is anyone out there who is bored and has no idea what project to start, maybe this will help: https://github.com/thekarangoel/Projects
19:17:54Mat2Araq: ok, in IO the vm do not need to perform newInteger(13) -> integers[13], because each object share the same state (I hope that is more understandable)
19:20:57Mat2if you clone an object, you create a whole new state inherented by the cloned object and shared between all future instantiations which do not modify the slots
19:25:10Mat2if I remember correctly the slots are simply copied. The VM traces a tree of objects and GC depending on an incremental collector which simply remove unneeded objects from the tree
19:25:32Mat2(read objects as nodes)
19:26:40Mat2all these was done (last time a take a look at the sources) without explicit caching
19:27:19Mat2IO like Smalltalk is somewhat typeless because of that
19:30:50Mat2because allocations are shared (if not modified) GC pressure is minimal (most memory reservations are part of the fixed heap which is allocated only once at vm startup)
19:33:40Mat2take a look here: https://github.com/stevedekorte/io/blob/master/libs/iovm/source/IoCollector.c
19:33:44Araqwell if you have a bignum taking 4 words, you need this memory temporarily somewhere and then you might determine the same value is already somewhere else and return a reference to that location instead
19:35:37Mat2ehm, basical all values share only one type: An word-sized integer
19:37:08Mat2sorry, IO define a float as single type
19:37:28Araqand then it uses NaN tagging?
19:37:40Mat2seems so
19:37:51Mat2just read the sources
19:38:34Mat2it's crazy these VM seem to map even strings to floats
19:39:30Mat2to be precise there exist an object for string handling and becuase all slots share the same type this can not handled otherwise
19:39:35Mat2^because
19:47:37Mat2ok, I need some investigation to understand that code
19:49:32Mat2but what I can say, each object includes the whole vm inclusive state (as written)
19:55:21Mat2*head scratch*
20:01:45*BitPuffin joined #nimrod
20:02:08Mat2hi BitPuffin
20:02:33EXetoCBitPuffin: "Exetoc you can pass 1..n to a generic" "A range but not a single number for now"
20:02:51BitPuffinHi Mat2
20:02:53BitPuffinand errbody
20:02:56BitPuffinis Araq atk?
20:03:03BitPuffinEXetoC: hrm
20:03:10AraqI'm here
20:03:24BitPuffinAraq: You gotta add value parameters do the generics!! :D
20:03:28BitPuffinI need em!
20:03:36BitPuffinto*
20:03:53Araqzahary implemented them already but his branch causes regressions
20:04:10Araqdunno when he'll fix and merge it
20:04:13BitPuffinAraq: can't you pull just those changes then?
20:04:26BitPuffinor are those the casue for regressions?
20:04:31BitPuffinAnd what kind of regressions
20:05:13BitPuffinEXetoC: it's kind of awkward to have to do type TVec2 = TVector[float, 1..2]
20:05:29BitPuffinbut hmm
20:05:31BitPuffinhowever
20:05:47BitPuffinthat allows the user to specify how the vector should be indexed
20:07:55BitPuffinEXetoC: doesn't seem like it works though
20:08:32BitPuffinhttps://gist.github.com/BitPuffin/b723ebe9813534adeb27
20:09:19EXetoCbummer
20:09:40BitPuffinvector.nim(6, 29) Error: type expected
20:13:03EXetoCBitPuffin: I think he meant the actual range type. that seems to work
20:13:24EXetoCso, range[x..y] rather than just x..y
20:16:39*alexandrus joined #nimrod
20:17:17BitPuffinEXetoC: can I pass that when creating an array?
20:17:35BitPuffinarray[range[1..2], float]
20:18:43BitPuffinseems like you can
20:19:25Araqlol I thought we fixed that so that you can pass 1..2 instead of range[1..2] oh well
20:20:08BitPuffinapparenty you didn't!
20:21:47BitPuffinHow do I do a static if?
20:21:51BitPuffinLike compile time if
20:22:31EXetoC'when'
20:23:08BitPuffinoh right
20:23:28BitPuffinEXetoC: does that work with checking the lenght of an array?
20:24:36BitPuffinwhen len(elements) is not len(result.elements)
20:24:52EXetoCfloat >= float64 and > float32, something like that, just so you know
20:24:54EXetoCI don't know
20:25:22BitPuffinEXetoC: for real? hmm
20:25:36EXetoCthat overload of len might very well be available at compile time, but I've never tested that
20:27:21EXetoCBitPuffin: no, it's the fastest floating point type I think, but it can still be pretty much anything
20:27:23BitPuffinEXetoC: to create a compile time error
20:27:52BitPuffinEXetoC: well for opengl compability I made it float32
20:28:03BitPuffinEXetoC: how do I do that :P
20:29:28Mat2ciao
20:29:31EXetoChttp://nimrod-code.org/manual.html#error-pragma_toc
20:29:36EXetoCcya
20:29:46*Mat2 quit (Quit: Verlassend)
20:31:27BitPuffinEXetoC: how do I specify the message? {.error: "Not enough/too many parameters".} ?
20:32:03EXetoCyes
20:33:41*XAMPP_ quit (Ping timeout: 248 seconds)
20:34:48BitPuffinEXetoC: made it a fatal
20:34:54BitPuffinFATALITY!
20:35:41BitPuffinwell, I don't seem to get a compile time error do I dare assume that "when len(elements) != len(result.elements):" works as it should?
20:36:56Araqstatic:
20:37:03Araq echo elements.len
20:37:10Araq echo result.elements.len
20:37:27Araq--> ask the compiler
20:38:27BitPuffinAraq: where should I put that? that assumes we know how many elements there is in elements
20:39:39Araqwell assume it works then, I'm busy
20:45:00BitPuffinI'm just writing some testing code instead
20:45:25BitPuffinI wonder how the signature for the vector should look like, apparently it's incorrect as it is now
20:45:47dom96hrm, isn't xilo new?
20:45:53dom96hello xilo
20:46:39BitPuffinhttps://gist.github.com/BitPuffin/b723ebe9813534adeb27
20:47:21*XAMPP joined #nimrod
20:47:21*XAMPP quit (Changing host)
20:47:21*XAMPP joined #nimrod
20:49:38EXetoCso, is the constraint simply not allowed? possibly
20:50:02EXetoCno wait, wrong line
20:51:04EXetoCI isn't specified anywhere in that proc definition
20:51:34EXetoCTVector[T, elements.len]?
20:51:39BitPuffinEXetoC: Well like what should I do
20:51:49EXetoCactually, isn't varargs a runtime construct?
20:51:57BitPuffinit is??
20:52:39AraqWarning: Cannot prove that 'vec' is initialized. lol the compiler is confused
20:53:02EXetoCyeah that's pretty common
20:53:07Araqyou should try TVector*[T; I: range] # note the ; instead of the ','
20:54:43BitPuffinAraq: what's the difference?
20:56:27AraqT, I: range # both T and I needs to be ranges
20:56:37AraqT; I: range # I needs to be a range
20:56:45BitPuffinaaaaaaahh
20:56:48BitPuffinyeah thanks
20:57:01BitPuffinStill doesn't compile though haha
21:00:10BitPuffinhttps://gist.github.com/BitPuffin/b723ebe9813534adeb27
21:00:41BitPuffinI like the Info: "instantiation from here" Like oh really
21:01:28EXetoC'I' still isn't specified anywhere
21:01:44EXetoCyou want to omit that line in simples cases?
21:02:49BitPuffinEXetoC: Well I don't know if I need it or not xD
21:03:29EXetoC'I' must be something
21:03:44BitPuffinthe documentation doesn't mention anything about generics constructors all that much
21:04:30Araqlook at your signature
21:04:38Araqproc initVector*[T, I](elements: varargs[T]): TVector[T, I] =
21:04:47AraqT can be inferred, I can't
21:04:52Araqit's really obvious
21:05:05Araqyou don't mention I in the parameter list; return type doesn't count
21:05:33BitPuffinHmm
21:05:39BitPuffinbut TVector needs an I param
21:08:45EXetoCline 22 doesn't specify 'I', only 'T'
21:09:40EXetoCand initVector*[I, T] might be a better idea in this case, since T is inferred from the argument
21:12:01BitPuffinEXetoC: how would reversing the order make a difference?
21:12:48EXetoCit won't, so nevermind
21:13:03AraqI don't get your approaches to matrixes tbh
21:13:23Araqit's always "von hinten durch die Brust ins Auge"
21:14:33Araqproc `+`*[Idx, T](a, b: array[Idx, T]): array[Idx, T] = ...
21:14:42BitPuffinAraq: matrices? this is vectors
21:14:45BitPuffinalthough
21:14:50Araqetc. for the other operators
21:14:55BitPuffinone could make the argument that a vector is a matricx
21:15:09Araqand then you can [0.0, 0.2] + [0.2, 0.9]
21:16:42BitPuffinAraq: well, that will kind of start to fall apart when combining them with matrices
21:16:57AraqI don't think you want nominal typing because [0.0, 0.2].vector + [0.2, 0.9].vector is verbose
21:17:51Araqbut why will it fall apart with matrices?
21:18:26BitPuffinAraq: well like, when checking of you can multiply them together etc
21:18:54Araqwhat do you check for the nominal type?
21:19:12Araqthat dimensions fit? that can be done with arrays too
21:19:22BitPuffinhmm
21:19:30BitPuffindamn
21:19:35BitPuffinyou might just be right
21:20:11BitPuffinAraq: will this allow swizzling?
21:20:25AraqI can't see why not
21:21:03Araqand btw people will call you names for starting with 1
21:21:40BitPuffinStarting with 1?
21:22:28AraqKnuth wrote a paper it has to be 0.. <N always because that has many good properties. This paper misses a lot but people didn't notice.
21:22:50BitPuffinah
21:22:52BitPuffinwell
21:22:59BitPuffinI was just thinking it's more mathy
21:23:06Araqand so you have to wait another decade until it's debunked I guess
21:23:49BitPuffinWell what kind of good properties?
21:24:55Araqintervals split up nicely, 0.. <N, N .. <M, M .. < K
21:25:22Araqand ... I can't remember
21:25:45Araqbut it's wrong anyway
21:26:31Araqbiggest issue with it is that an exclusive upper bound often doesn't exist in computing
21:26:47Araqyou can't perform < maxint+1 because maxint+1 doesn't exist
21:27:43BitPuffinhmm
21:27:49BitPuffinwell I'll change it then
21:30:38BitPuffinwell
21:30:43BitPuffinthat changes errthing
21:30:59BitPuffinactually, no I'm not changing it I guess, I'm removing it because Araq told me to </3
21:31:22AraqI told you to start with 0
21:31:37Araqprogrammers get upset otherwise
21:32:36BitPuffinAraq: well you also told me to not create a tytpe
21:32:38BitPuffintype*
21:34:03Araqlol true
21:34:38Araqtype TVector[T, I] = array[I, T] # perhaps
21:35:03BitPuffinhmm
21:35:06BitPuffinyou know that's not bad
21:35:28BitPuffinAraq: isn't it kind of weird to allow all array operators on vectors though?
21:35:52Araqbut system defines very little for 'array'
21:36:03BitPuffinwhat does it define?
21:36:17BitPuffinlen for example
21:36:25BitPuffinthat could easily be interpreted as magnitude
21:36:30Araq[] access and perhaps & and len of course
21:36:52Araqhow so? 'len' has a defined meaning in nimrod
21:37:03Araqit always means "number of elements"
21:38:19BitPuffinwell I plan do define a [] for temporary swizzling
21:38:24BitPuffinuntil it's in there
21:39:35Araqa[] can be overloaded for it
21:39:42Araqoh wait
21:39:52Araqthat doesn't work
21:40:02Araqbut you can overload a{} instead
21:40:08Araqa{"yxz"}
21:40:43EXetoCcan a varargs[expr] be turned into a an argument list or something? I could build an AST, but then it's not really worth creating a template in the first place
21:41:17EXetoCand tuple unpacking is currently very limited IIRC
21:41:42Araqno argument list unpacking, no tuple unpacking unless you create a macro to do that
21:42:16EXetoCok
21:50:04BitPuffinAraq: hmm, I don't know about {}
21:51:19BitPuffinAraq: seems weird to use that for access, maybe it's better to keep it as a type so I can overload []
21:52:40*OrionPK joined #nimrod
21:52:47EXetoCmaybe you want this then http://nimrod-code.org/manual.html#distinct-type
21:53:02BitPuffinEXetoC: No
21:53:14BitPuffinBecause Vectors are supposed to also work with matrices
22:08:14*Smaehtin joined #nimrod
22:09:56SmaehtinAny way to disable the name mangling when exporting a function from a dynamic library in Nimrod? Example: proc Initialize() {.exportc: "Initialize", stdcall, dynlib.} exports the Initialize function as _Initialize@0
22:11:27Araqthat's what the C compiler does and it does it for good reasons
22:11:54Araqstdcall appends @size_of_params_in_bytes
22:12:15AraqI can't imagine why you would like to disable it
22:12:28SmaehtinI don't see why it's necessary for a dynamic library
22:12:43Araqwell then don't mess with it
22:14:12SmaehtinWhat I meant was: I want to disable it for dynamic libaries
22:14:26SmaehtinBut there's no way then?
22:14:49*BitPuffin can't decide what to do
22:14:55BitPuffinKeep the type or not
22:15:19Araqbut what you're saying is: "I don't know the technical details of DLLs but I feel I know better than the C compiler"
22:16:40SmaehtinNo, I just don't want my DLL to be exporting mangled names, I want to decide the names myself, so I can DllImport("DllName.dll", "Initialize") and don't have to worry about the cryptic name mangling
22:17:13BitPuffinAraq: Hmm, maybe just make the vectors arrays for now and let the elements be accessed with indices with [] and then add the swizzling when it's finally in nimrod
22:17:39AraqSmaehtin: you can do DllImport("DllName.dll", "Initialize") anyway, it just works
22:18:26AraqBitPuffin: sure but a{} access is idiomatic in Nimrod
22:18:34Araqnothing weird about it
22:18:35SmaehtinOh, my bad then haha
22:19:16BitPuffinAraq: what uses that access?
22:19:44Araqcan't remember, BitPuffin, we use it internally in the compiler
22:21:48Araqa{i} is just like a[i] when a[i] is already taken
22:21:54Araq:P
22:23:44BitPuffinlol :P
22:23:53BitPuffinare people familiar with that?
22:24:05BitPuffinAraq: by the way, why doesn't it allow me to override [] really?
22:24:12BitPuffinAraq: I mean it's a different []
22:24:16BitPuffinthis one takes a string
22:24:17BitPuffinnot an int
22:24:22BitPuffinso why doesn't it work
22:25:44Araqbecause [] is builtin in a special way for arrays
22:25:48AraqI can make it work
22:26:31BitPuffinAraq: You should!
22:27:00Araqsure. I owe you a lot
22:27:04comexnah, you should make it possible to implement array.yxz like in GLSL :)
22:27:08comexor is it already...
22:27:32Araqcomex: welcome to nimrod's amazing world of term rewriting macros
22:28:54BitPuffinAraq: no you don't!
22:29:06BitPuffinBut you owe it to your language :P
22:36:11BitPuffinAraq: and it's not like this math library is exclusively made for me either, it's very much open source for everyone to use (Unlicense)
22:36:50Araqnobody will use it if you start with 1
22:39:14BitPuffinana
22:39:36BitPuffinAraq: well I'm not going to start with 1 after you adviced me not to, so why the bitterness
22:39:50comexstart with 0.5
22:40:30AraqI'm not really bitter, it's just a fact that most programmers can't even program fizzbuzz
22:44:37xilodom96: wut wut
22:45:15xiloAraq: are you serial
22:45:27Araqno but serious
22:45:28xilohow can you say you can program if you can't do fizzbuzz :O
22:45:38EXetoCeither way, if they are indeed writing code then they should get used to common conventions, but if it's optional then it's not that bad
22:45:55EXetoCxilo: did he? :p
22:46:38xiloso tell me about nimrod
22:48:21Araqxilo: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
22:48:22EXetoCit's awesome and stuff
22:51:10EXetoCit's a ridiculous situation
22:52:04*DAddYE_ joined #nimrod
22:52:38Araqxilo: btw welcome! :-)
22:53:23xilohowdy ho
22:55:20xiloi had a pretty difficult screening question recently
22:55:37xiloit was
22:56:15xilogiven a string, calculate the index of it. the index being where it falls in an alphabetized list of combinations that are possition with the letters in the string
22:58:40Araqare the strings in the hypothetical set all of the length of your given input string?
22:58:55xilothey must contain every letter
22:58:58xilofor example
22:59:07xiloaaba
22:59:09xiloyou'd have
22:59:21xiloaaab, aaba, abaa, baaa. so it's index is 1
22:59:30xiloor 2 on a non-zero starting point
22:59:46Araqthe alphabet size is given?
22:59:50xilono
22:59:55xilojust the string
22:59:58Araqit's a-z ?
23:00:00xiloso far example calling it
23:00:22xilocalculate("aaba") should return 1 (starting at 0)
23:00:28xiloyes just ascii letters
23:00:38*DAddYE quit (*.net *.split)
23:00:59Araqthat's just a simple string to int conversion
23:01:09Araqwith a-z instead of 0-9
23:01:18xilono
23:01:49xilohow do you find out which place it appears on the list? :)
23:02:05xilocan't do that just converting "aaba" to an int
23:02:30Araqyeah you can but the question is: why is there no aaaa in your example?
23:02:44xilobecause aaaa isn't the letters in the string
23:03:00xiloit has to have 3 a's and 1 b
23:03:38AraqI see
23:04:08Araqso sort it and calculate the difference
23:04:50xilotry it out
23:04:53xilotop would be 5
23:04:57xilo(starting at 1)
23:04:58Araqthe latter might be hard though
23:05:47Araqon the other hand, brute force is easy
23:06:11xiloyeah, you just make a list of all possible combinations until you hit the one passed in
23:06:17comexwell, that's lame
23:06:25xilobut that's generally the you don't pass our test case
23:06:48comexyou can, at least, chop off all letters at the beginning that are already sorted
23:07:01Araqsort it == minimum, increment the minimum until you reach X, don't count combinations that X doesn't allow
23:07:17Araqbut it's lame, yeah
23:08:03comexno... you can do it much better than that... I think?
23:08:06comexwell, if you disallow duplicate letters
23:08:09comex(hypothetically)
23:08:59comexfor each character, calculate its position of the letters you have remaining, multiply it by the number of possibilities for all following characters, and sum those values
23:09:09comexs/of/in
23:09:21AraqI think you need to sort it and during the sort accumulate the sum
23:09:32Araqwhere each swap does something to your sum
23:09:38Araqbut I'm not sure what :P
23:10:30Araqbubble sort works I think
23:10:32comexi suppose with duplicate characters it's the same, but you just have to calculacte the number of possibilities for the remaining characters correctly
23:10:49Araqbut don't count a<->a swaps
23:13:51comexso, calculate = lambda chars: sorted(chars).index(chars[0]) * (math.factorial(len(chars[1:])) / reduce(operator.mul, math.factorial(chars.count(c)) for c in chars)) + calculate(chars[1:])
23:16:24comexno, that's not right
23:16:39comexwith duplicate characters it depends on which character you pick...
23:16:48comexso if you fix that it comes out to be exponential
23:17:03comexwell, that's still better than than brute force
23:17:16comexwell... does it?
23:17:18comexno, it doesn't
23:17:55AraqI think bubble sort with a sum function works
23:18:05Araqbut I need to sleep now
23:18:07Araqgood night
23:19:15EXetoCgood luck. bye
23:19:29BitPuffinAraq: what's fizzbuzz got to do with it
23:19:37BitPuffinnight!
23:22:22*Smaehtin quit (Quit: Page closed)
23:27:42xilohttp://pastebin.com/rp8BufrZ here's the solution if you interested
23:31:16comexcalculate = lambda chars: 0 if not chars else (sum((lambda chars2: math.factorial(len(chars2)) / reduce(operator.mul, (math.factorial(chars2.count(c2)) for c2 in set(chars2)), 1))(chars[:chars.index(c)] + chars[chars.index(c)+1:]) for c in sorted(set(chars)) if c < chars[0]) + calculate(chars[1:]))
23:31:21comexthere, that's mine
23:31:36comexi blame python not actually being designed for functional one-liners
23:31:41comexon me taking forever for that :)
23:32:14xilowhat number does it give you if you put in bookkeeper
23:32:21comex10742
23:32:24xilogj
23:32:26xilothat was fast
23:32:28xilo:O
23:32:39comexit's O(n^2)
23:32:56comexi think
23:34:03xilois that creating the list of chars then finding the index?
23:35:52comexfor a given word, it calculates how many unique permutations you get by removing each character valued less than the first one
23:36:03comexand then recurses
23:36:15xiloah
23:36:22comexprobably more expensive than that, whatever
23:36:38xilothink mine is
23:36:42xiloO(n)
23:36:54xiloidk
23:36:56comexit is
23:38:01*comex wonders how much prettier that would have been in haskell
23:38:09xiloso i have this bad habbit of just looking at new languages than trying to learn a new one :|
23:40:59*alexandrus quit ()
23:49:51EXetoCbeebeep
23:51:10EXetoCBitPuffin: is your lib epic yet?
23:51:19BitPuffinEXetoC: nope :)
23:51:39BitPuffinEXetoC: doesn't even have vectors yet, currently looking to get a job
23:53:58xilome too