00:00:43 | EXetoC | a type declaration that includes the equal sign and then some metatype if you can call it that (object, tuple, enum..) |
00:01:19 | BitPuffin | EXetoC: hrm |
00:01:23 | * | DAddYE quit (Ping timeout: 240 seconds) |
00:01:35 | BitPuffin | EXetoC: but basically all of this is because the parameterization can't hold values? |
00:02:32 | EXetoC | the 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:29 | EXetoC | since it's as meaningless as "proc f()" on its own |
00:03:42 | BitPuffin | EXetoC: but type x = IS found on my side |
00:05:04 | EXetoC | not for Vector, if what you told me is accurate |
00:05:32 | BitPuffin | EXetoC: lemme paste |
00:05:42 | EXetoC | Vec3 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:13 | BitPuffin | EXetoC: exactly it's supposed to be an alias |
00:08:28 | BitPuffin | EXetoC: https://gist.github.com/BitPuffin/6e72164f232d12b16bff |
00:10:49 | BitPuffin | EXetoC: doesn't that count as an impl? |
00:12:20 | EXetoC | yes, but the compiler doesn't even accept the integers, so it's kind of hard to reason about |
00:12:54 | BitPuffin | EXetoC: yeah but if it did? |
00:13:48 | BitPuffin | then this would be correct wouldn't it? |
00:14:21 | EXetoC | BitPuffin: I guess, but another problem is that * is on the wrong side of the type parameter list |
00:14:27 | BitPuffin | because I'm not gonna change this code, it's the way it should be, they have to fix dat compiler :P |
00:14:50 | BitPuffin | EXetoC: okay, fixed that |
00:15:39 | BitPuffin | EXetoC: I also changed D to be int |
00:15:52 | BitPuffin | so now it's TVector[T, D: int] |
00:16:00 | BitPuffin | and now the error is type mismatch |
00:16:09 | BitPuffin | and I'm assuming that's the error because it can't hold the value |
00:16:53 | EXetoC | yup, that just adds a type constraint |
00:17:08 | BitPuffin | Well then |
00:17:13 | EXetoC | but I guess you can specialize that way |
00:17:19 | BitPuffin | that's enough for this evening |
00:17:36 | BitPuffin | EXetoC: yeah well 1..D pretty much means D should have the constraint |
00:18:07 | BitPuffin | EXetoC: 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:10 | BitPuffin | nighty night! |
00:18:13 | BitPuffin | thanks for the help |
00:18:19 | EXetoC | just check the issue tracker :p |
00:18:21 | EXetoC | cya |
00:19:08 | EXetoC | maybe it's zah who's working on this stuff. something similar at least |
00:20:01 | BitPuffin | EXetoC: don't see it on the tracker :o |
00:20:27 | EXetoC | no, but there's a huge pile there |
00:20:36 | EXetoC | but we'll see |
00:21:27 | BitPuffin | hmm |
00:21:31 | BitPuffin | Oh well |
00:21:48 | BitPuffin | we'll have to discuss further tomorrow, hopefully in the company of Araq |
00:21:53 | BitPuffin | see you |
00:25:14 | EXetoC | bbbbbb |
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:20 | DAddYE | hi thereeeeeeee |
05:46:32 | DAddYE | quick info how much bad a thing like: var s = cast[ref char](sizeof(char).alloc0) |
05:46:43 | DAddYE | casting to a ref means put back it to the gc? |
05:46:53 | DAddYE | Araq: ^^ |
05:48:47 | DAddYE | also if I want to create a unsafe no traced T is there some other than: sizeof(T).alloc ? |
05:49:03 | DAddYE | also if I want to create a unsafe no traced T is there some other than: cast[T](sizeof(T).alloc) ? |
05:49:11 | DAddYE | Araq: ^^ |
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:54 | Araq_ | DAddYE: casting ptr to ref doesn't work |
07:04:07 | Araq_ | another way to create an unsafe ptr is to use 'addr' |
07:05:33 | DAddYE | the pointer point in something that is still in the gc |
07:05:39 | DAddYE | here an example |
07:05:40 | DAddYE | https://gist.github.com/DAddYE/69c70bfcc5882ba3f039 |
07:06:14 | DAddYE | I need to know if this: https://gist.github.com/DAddYE/69c70bfcc5882ba3f039#file-works-nim-L6 |
07:06:40 | DAddYE | 1) is a good way, 2) if put this in the gc |
07:09:04 | DAddYE | http://fs.daddye.it/95St/29ItaFCq do you know why I've `dirty` things? |
07:11:18 | Araq_ | no it's not valid code |
07:11:26 | Araq_ | it'll crash one way or the other |
07:11:45 | Araq_ | you can use unsafeNew() for what you have in mind |
07:11:52 | Araq_ | ... perhaps |
07:15:09 | DAddYE | I thought about that for interop between ref and pointer |
07:15:22 | DAddYE | sometimes I need to manually alloc/dealloc |
07:15:24 | DAddYE | some not |
07:15:39 | DAddYE | so in my mind I mapped procs to get a ref |
07:16:01 | DAddYE | but if I need to manually alloc/dealloc |
07:16:09 | DAddYE | I'll use the cast in the gist |
07:16:24 | DAddYE | (just experimenting) |
07:16:24 | DAddYE | :D |
07:19:13 | Araq_ | do not cast from pointer/ptr to ref! |
07:19:28 | Araq_ | it's a crash waiting to happen |
07:24:30 | DAddYE | sure |
07:24:42 | DAddYE | can you explain me way? |
07:24:45 | DAddYE | can you explain me why? |
07:26:34 | Araq_ | because the write barrier assumes there is an RC field at a negative offset |
07:26:54 | Araq_ | when the memory comes from anywhere (include alloc) this is not the case |
07:27:07 | Araq_ | so it will access random memory instead |
07:27:22 | DAddYE | ok |
07:28:05 | DAddYE | so there is no easy way to do "duck typing" between pointers and refs |
07:28:44 | DAddYE | btw thanks for the explanation now sounds plausible to me |
07:37:40 | DAddYE | btw I almost finished the a web server with joyent/http_parser and libuv |
07:38:02 | DAddYE | I need only an event emitter |
07:38:11 | DAddYE | and I'm looking at events.nim |
07:40:42 | Araq_ | dunno if it has been updated to support closures |
07:42:08 | DAddYE | yes |
07:42:23 | DAddYE | (old syntax) but proc (){.closure.} |
07:42:26 | DAddYE | is 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:28 | EXetoC | moo |
14:36:46 | * | AndChat-320025 joined #nimrod |
14:36:47 | * | Araq0 quit (Read error: Connection reset by peer) |
14:38:58 | AndChat-320025 | Exetoc you can pass 1..n to a generic |
14:39:53 | AndChat-320025 | A range but not a single number for now |
14:40:25 | * | AndChat-320025 quit (Client Quit) |
14:49:17 | EXetoC | oh |
15:37:30 | EXetoC | I guess many people have needed that then. When was it added? |
16:33:53 | * | DAddYE joined #nimrod |
16:35:54 | DAddYE | mooooooooooooooooooooooooooooooooooooooooooooooooooooooooooorning |
16:42:03 | EXetoC | hi |
16:49:59 | DAddYE | EXetoC: do you know how I can alloc (unsafe) T ? |
16:50:15 | DAddYE | I mean there is T.sizeof.alloc |
16:50:33 | DAddYE | but then can be fine cast[T](T.sizeof.alloc) ? |
16:55:17 | EXetoC | unsafe how? there's also unsafeNew |
16:55:22 | EXetoC | I guess that's correct |
16:57:17 | EXetoC | it'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:07 | DAddYE | for unsafe I mean something that should run out of GC so non traced |
16:58:26 | DAddYE | unsafeNew can be a choice but the doc say that is traced so subject to be GC'd |
16:58:56 | dom96 | I wanna go to the emerging langs conference with Araq :( |
16:58:58 | EXetoC | yeah, so untraced seems to make more sense |
16:59:00 | dom96 | also hi |
16:59:27 | EXetoC | but yes your approach seems to be correct |
16:59:40 | EXetoC | dom96: me too, but can I get there somehow if I don't have any money |
17:00:14 | EXetoC | I have a bike, but it might take some time to get there, and it's a mountain bike |
17:01:01 | dom96 | hrm, how about we try to grab a ride all the way to St. Louis by hitchiking :P |
17:02:20 | EXetoC | c(:)-< |
17:02:36 | dom96 | I wonder what the record for the longest distance travelled by hitchiking is. |
17:03:02 | EXetoC | > 10 miles |
17:12:38 | EXetoC | is 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:04 | dom96 | why not 'win'? |
17:13:18 | dom96 | makes more sense IMO |
17:13:55 | EXetoC | I don't know |
17:13:57 | dom96 | DAddYE: What are you up to? |
17:16:19 | dom96 | And why are you using libuv and not the asyncio module? |
17:55:37 | Araq | wnd ... hm is pretty uncommon I think |
18:03:32 | EXetoC | oh well, it's easy to change |
18:05:59 | EXetoC | hwnd might be the culprit |
18:15:25 | DAddYE | dom96: is it just an exercise to learn a bit more the langauge |
18:35:17 | * | Mat2 joined #nimrod |
18:35:21 | Mat2 | hi @ all |
18:36:55 | Araq | hi Mat2 |
18:37:15 | Araq | in what way is IO's object model special |
18:38:27 | Araq | "Io is a prototype-based programming language inspired by Smalltalk (all values are objects, all messages are dynamic), ..." |
18:39:13 | Mat2 | you do not handle classes, only clone objects |
18:39:29 | Araq | how does that help? |
18:41:54 | Mat2 | each object can be used as prototype for a large set of variants without explicit declaration overhead |
18:43:27 | Araq | the context was python's small integer object caching |
18:47:18 | Mat2 | because 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:45 | Mat2 | so special cache-handling can be avoided |
18:50:14 | Mat2 | in 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:14 | Mat2 | cache misses can cost a lot of clock cycles... |
18:54:30 | Mat2 | specially for out-of-order, super scalar processor architectures with very large pipelines (like all Intel and AMD cpu's) |
18:57:24 | Mat2 | its 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:01 | Mat2 | IO'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:09 | Mat2 | whereby a class-based approach differenciate these dependent of the class type (virtual classes, abstract classes, template classes etc.) |
19:02:07 | Mat2 | so the last time I had taken a look at IO's sources, there VM do not cache anything (its not needed) |
19:03:31 | Araq | I can't really follow sorry |
19:03:45 | Araq | in python the caching is necessary because of the uniform object representation |
19:04:05 | Araq | where even for small ints NO ponter-tagging etc. is done |
19:04:13 | Araq | *pointer-tagging |
19:06:52 | Araq | so instead of newInteger(13) integers[13] is performed |
19:07:47 | Araq | my point was that with an explicit target you can do target.bigInt[0] = 13; setLen(target, 1); instead |
19:08:38 | Araq | CPU caches have nothing to do with it, it's about avoiding allocations and thus GC pressure |
19:09:25 | dom96 | If 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:54 | Mat2 | Araq: 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:57 | Mat2 | if 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:10 | Mat2 | if 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:32 | Mat2 | (read objects as nodes) |
19:26:40 | Mat2 | all these was done (last time a take a look at the sources) without explicit caching |
19:27:19 | Mat2 | IO like Smalltalk is somewhat typeless because of that |
19:30:50 | Mat2 | because 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:40 | Mat2 | take a look here: https://github.com/stevedekorte/io/blob/master/libs/iovm/source/IoCollector.c |
19:33:44 | Araq | well 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:37 | Mat2 | ehm, basical all values share only one type: An word-sized integer |
19:37:08 | Mat2 | sorry, IO define a float as single type |
19:37:28 | Araq | and then it uses NaN tagging? |
19:37:40 | Mat2 | seems so |
19:37:51 | Mat2 | just read the sources |
19:38:34 | Mat2 | it's crazy these VM seem to map even strings to floats |
19:39:30 | Mat2 | to be precise there exist an object for string handling and becuase all slots share the same type this can not handled otherwise |
19:39:35 | Mat2 | ^because |
19:47:37 | Mat2 | ok, I need some investigation to understand that code |
19:49:32 | Mat2 | but what I can say, each object includes the whole vm inclusive state (as written) |
19:55:21 | Mat2 | *head scratch* |
20:01:45 | * | BitPuffin joined #nimrod |
20:02:08 | Mat2 | hi BitPuffin |
20:02:33 | EXetoC | BitPuffin: "Exetoc you can pass 1..n to a generic" "A range but not a single number for now" |
20:02:51 | BitPuffin | Hi Mat2 |
20:02:53 | BitPuffin | and errbody |
20:02:56 | BitPuffin | is Araq atk? |
20:03:03 | BitPuffin | EXetoC: hrm |
20:03:10 | Araq | I'm here |
20:03:24 | BitPuffin | Araq: You gotta add value parameters do the generics!! :D |
20:03:28 | BitPuffin | I need em! |
20:03:36 | BitPuffin | to* |
20:03:53 | Araq | zahary implemented them already but his branch causes regressions |
20:04:10 | Araq | dunno when he'll fix and merge it |
20:04:13 | BitPuffin | Araq: can't you pull just those changes then? |
20:04:26 | BitPuffin | or are those the casue for regressions? |
20:04:31 | BitPuffin | And what kind of regressions |
20:05:13 | BitPuffin | EXetoC: it's kind of awkward to have to do type TVec2 = TVector[float, 1..2] |
20:05:29 | BitPuffin | but hmm |
20:05:31 | BitPuffin | however |
20:05:47 | BitPuffin | that allows the user to specify how the vector should be indexed |
20:07:55 | BitPuffin | EXetoC: doesn't seem like it works though |
20:08:32 | BitPuffin | https://gist.github.com/BitPuffin/b723ebe9813534adeb27 |
20:09:19 | EXetoC | bummer |
20:09:40 | BitPuffin | vector.nim(6, 29) Error: type expected |
20:13:03 | EXetoC | BitPuffin: I think he meant the actual range type. that seems to work |
20:13:24 | EXetoC | so, range[x..y] rather than just x..y |
20:16:39 | * | alexandrus joined #nimrod |
20:17:17 | BitPuffin | EXetoC: can I pass that when creating an array? |
20:17:35 | BitPuffin | array[range[1..2], float] |
20:18:43 | BitPuffin | seems like you can |
20:19:25 | Araq | lol I thought we fixed that so that you can pass 1..2 instead of range[1..2] oh well |
20:20:08 | BitPuffin | apparenty you didn't! |
20:21:47 | BitPuffin | How do I do a static if? |
20:21:51 | BitPuffin | Like compile time if |
20:22:31 | EXetoC | 'when' |
20:23:08 | BitPuffin | oh right |
20:23:28 | BitPuffin | EXetoC: does that work with checking the lenght of an array? |
20:24:36 | BitPuffin | when len(elements) is not len(result.elements) |
20:24:52 | EXetoC | float >= float64 and > float32, something like that, just so you know |
20:24:54 | EXetoC | I don't know |
20:25:22 | BitPuffin | EXetoC: for real? hmm |
20:25:36 | EXetoC | that overload of len might very well be available at compile time, but I've never tested that |
20:27:21 | EXetoC | BitPuffin: no, it's the fastest floating point type I think, but it can still be pretty much anything |
20:27:23 | BitPuffin | EXetoC: to create a compile time error |
20:27:52 | BitPuffin | EXetoC: well for opengl compability I made it float32 |
20:28:03 | BitPuffin | EXetoC: how do I do that :P |
20:29:28 | Mat2 | ciao |
20:29:31 | EXetoC | http://nimrod-code.org/manual.html#error-pragma_toc |
20:29:36 | EXetoC | cya |
20:29:46 | * | Mat2 quit (Quit: Verlassend) |
20:31:27 | BitPuffin | EXetoC: how do I specify the message? {.error: "Not enough/too many parameters".} ? |
20:32:03 | EXetoC | yes |
20:33:41 | * | XAMPP_ quit (Ping timeout: 248 seconds) |
20:34:48 | BitPuffin | EXetoC: made it a fatal |
20:34:54 | BitPuffin | FATALITY! |
20:35:41 | BitPuffin | well, 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:56 | Araq | static: |
20:37:03 | Araq | echo elements.len |
20:37:10 | Araq | echo result.elements.len |
20:37:27 | Araq | --> ask the compiler |
20:38:27 | BitPuffin | Araq: where should I put that? that assumes we know how many elements there is in elements |
20:39:39 | Araq | well assume it works then, I'm busy |
20:45:00 | BitPuffin | I'm just writing some testing code instead |
20:45:25 | BitPuffin | I wonder how the signature for the vector should look like, apparently it's incorrect as it is now |
20:45:47 | dom96 | hrm, isn't xilo new? |
20:45:53 | dom96 | hello xilo |
20:46:39 | BitPuffin | https://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:38 | EXetoC | so, is the constraint simply not allowed? possibly |
20:50:02 | EXetoC | no wait, wrong line |
20:51:04 | EXetoC | I isn't specified anywhere in that proc definition |
20:51:34 | EXetoC | TVector[T, elements.len]? |
20:51:39 | BitPuffin | EXetoC: Well like what should I do |
20:51:49 | EXetoC | actually, isn't varargs a runtime construct? |
20:51:57 | BitPuffin | it is?? |
20:52:39 | Araq | Warning: Cannot prove that 'vec' is initialized. lol the compiler is confused |
20:53:02 | EXetoC | yeah that's pretty common |
20:53:07 | Araq | you should try TVector*[T; I: range] # note the ; instead of the ',' |
20:54:43 | BitPuffin | Araq: what's the difference? |
20:56:27 | Araq | T, I: range # both T and I needs to be ranges |
20:56:37 | Araq | T; I: range # I needs to be a range |
20:56:45 | BitPuffin | aaaaaaahh |
20:56:48 | BitPuffin | yeah thanks |
20:57:01 | BitPuffin | Still doesn't compile though haha |
21:00:10 | BitPuffin | https://gist.github.com/BitPuffin/b723ebe9813534adeb27 |
21:00:41 | BitPuffin | I like the Info: "instantiation from here" Like oh really |
21:01:28 | EXetoC | 'I' still isn't specified anywhere |
21:01:44 | EXetoC | you want to omit that line in simples cases? |
21:02:49 | BitPuffin | EXetoC: Well I don't know if I need it or not xD |
21:03:29 | EXetoC | 'I' must be something |
21:03:44 | BitPuffin | the documentation doesn't mention anything about generics constructors all that much |
21:04:30 | Araq | look at your signature |
21:04:38 | Araq | proc initVector*[T, I](elements: varargs[T]): TVector[T, I] = |
21:04:47 | Araq | T can be inferred, I can't |
21:04:52 | Araq | it's really obvious |
21:05:05 | Araq | you don't mention I in the parameter list; return type doesn't count |
21:05:33 | BitPuffin | Hmm |
21:05:39 | BitPuffin | but TVector needs an I param |
21:08:45 | EXetoC | line 22 doesn't specify 'I', only 'T' |
21:09:40 | EXetoC | and initVector*[I, T] might be a better idea in this case, since T is inferred from the argument |
21:12:01 | BitPuffin | EXetoC: how would reversing the order make a difference? |
21:12:48 | EXetoC | it won't, so nevermind |
21:13:03 | Araq | I don't get your approaches to matrixes tbh |
21:13:23 | Araq | it's always "von hinten durch die Brust ins Auge" |
21:14:33 | Araq | proc `+`*[Idx, T](a, b: array[Idx, T]): array[Idx, T] = ... |
21:14:42 | BitPuffin | Araq: matrices? this is vectors |
21:14:45 | BitPuffin | although |
21:14:50 | Araq | etc. for the other operators |
21:14:55 | BitPuffin | one could make the argument that a vector is a matricx |
21:15:09 | Araq | and then you can [0.0, 0.2] + [0.2, 0.9] |
21:16:42 | BitPuffin | Araq: well, that will kind of start to fall apart when combining them with matrices |
21:16:57 | Araq | I don't think you want nominal typing because [0.0, 0.2].vector + [0.2, 0.9].vector is verbose |
21:17:51 | Araq | but why will it fall apart with matrices? |
21:18:26 | BitPuffin | Araq: well like, when checking of you can multiply them together etc |
21:18:54 | Araq | what do you check for the nominal type? |
21:19:12 | Araq | that dimensions fit? that can be done with arrays too |
21:19:22 | BitPuffin | hmm |
21:19:30 | BitPuffin | damn |
21:19:35 | BitPuffin | you might just be right |
21:20:11 | BitPuffin | Araq: will this allow swizzling? |
21:20:25 | Araq | I can't see why not |
21:21:03 | Araq | and btw people will call you names for starting with 1 |
21:21:40 | BitPuffin | Starting with 1? |
21:22:28 | Araq | Knuth 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:50 | BitPuffin | ah |
21:22:52 | BitPuffin | well |
21:22:59 | BitPuffin | I was just thinking it's more mathy |
21:23:06 | Araq | and so you have to wait another decade until it's debunked I guess |
21:23:49 | BitPuffin | Well what kind of good properties? |
21:24:55 | Araq | intervals split up nicely, 0.. <N, N .. <M, M .. < K |
21:25:22 | Araq | and ... I can't remember |
21:25:45 | Araq | but it's wrong anyway |
21:26:31 | Araq | biggest issue with it is that an exclusive upper bound often doesn't exist in computing |
21:26:47 | Araq | you can't perform < maxint+1 because maxint+1 doesn't exist |
21:27:43 | BitPuffin | hmm |
21:27:49 | BitPuffin | well I'll change it then |
21:30:38 | BitPuffin | well |
21:30:43 | BitPuffin | that changes errthing |
21:30:59 | BitPuffin | actually, no I'm not changing it I guess, I'm removing it because Araq told me to </3 |
21:31:22 | Araq | I told you to start with 0 |
21:31:37 | Araq | programmers get upset otherwise |
21:32:36 | BitPuffin | Araq: well you also told me to not create a tytpe |
21:32:38 | BitPuffin | type* |
21:34:03 | Araq | lol true |
21:34:38 | Araq | type TVector[T, I] = array[I, T] # perhaps |
21:35:03 | BitPuffin | hmm |
21:35:06 | BitPuffin | you know that's not bad |
21:35:28 | BitPuffin | Araq: isn't it kind of weird to allow all array operators on vectors though? |
21:35:52 | Araq | but system defines very little for 'array' |
21:36:03 | BitPuffin | what does it define? |
21:36:17 | BitPuffin | len for example |
21:36:25 | BitPuffin | that could easily be interpreted as magnitude |
21:36:30 | Araq | [] access and perhaps & and len of course |
21:36:52 | Araq | how so? 'len' has a defined meaning in nimrod |
21:37:03 | Araq | it always means "number of elements" |
21:38:19 | BitPuffin | well I plan do define a [] for temporary swizzling |
21:38:24 | BitPuffin | until it's in there |
21:39:35 | Araq | a[] can be overloaded for it |
21:39:42 | Araq | oh wait |
21:39:52 | Araq | that doesn't work |
21:40:02 | Araq | but you can overload a{} instead |
21:40:08 | Araq | a{"yxz"} |
21:40:43 | EXetoC | can 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:17 | EXetoC | and tuple unpacking is currently very limited IIRC |
21:41:42 | Araq | no argument list unpacking, no tuple unpacking unless you create a macro to do that |
21:42:16 | EXetoC | ok |
21:50:04 | BitPuffin | Araq: hmm, I don't know about {} |
21:51:19 | BitPuffin | Araq: 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:47 | EXetoC | maybe you want this then http://nimrod-code.org/manual.html#distinct-type |
21:53:02 | BitPuffin | EXetoC: No |
21:53:14 | BitPuffin | Because Vectors are supposed to also work with matrices |
22:08:14 | * | Smaehtin joined #nimrod |
22:09:56 | Smaehtin | Any 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:27 | Araq | that's what the C compiler does and it does it for good reasons |
22:11:54 | Araq | stdcall appends @size_of_params_in_bytes |
22:12:15 | Araq | I can't imagine why you would like to disable it |
22:12:28 | Smaehtin | I don't see why it's necessary for a dynamic library |
22:12:43 | Araq | well then don't mess with it |
22:14:12 | Smaehtin | What I meant was: I want to disable it for dynamic libaries |
22:14:26 | Smaehtin | But there's no way then? |
22:14:49 | * | BitPuffin can't decide what to do |
22:14:55 | BitPuffin | Keep the type or not |
22:15:19 | Araq | but 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:40 | Smaehtin | No, 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:13 | BitPuffin | Araq: 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:39 | Araq | Smaehtin: you can do DllImport("DllName.dll", "Initialize") anyway, it just works |
22:18:26 | Araq | BitPuffin: sure but a{} access is idiomatic in Nimrod |
22:18:34 | Araq | nothing weird about it |
22:18:35 | Smaehtin | Oh, my bad then haha |
22:19:16 | BitPuffin | Araq: what uses that access? |
22:19:44 | Araq | can't remember, BitPuffin, we use it internally in the compiler |
22:21:48 | Araq | a{i} is just like a[i] when a[i] is already taken |
22:21:54 | Araq | :P |
22:23:44 | BitPuffin | lol :P |
22:23:53 | BitPuffin | are people familiar with that? |
22:24:05 | BitPuffin | Araq: by the way, why doesn't it allow me to override [] really? |
22:24:12 | BitPuffin | Araq: I mean it's a different [] |
22:24:16 | BitPuffin | this one takes a string |
22:24:17 | BitPuffin | not an int |
22:24:22 | BitPuffin | so why doesn't it work |
22:25:44 | Araq | because [] is builtin in a special way for arrays |
22:25:48 | Araq | I can make it work |
22:26:31 | BitPuffin | Araq: You should! |
22:27:00 | Araq | sure. I owe you a lot |
22:27:04 | comex | nah, you should make it possible to implement array.yxz like in GLSL :) |
22:27:08 | comex | or is it already... |
22:27:32 | Araq | comex: welcome to nimrod's amazing world of term rewriting macros |
22:28:54 | BitPuffin | Araq: no you don't! |
22:29:06 | BitPuffin | But you owe it to your language :P |
22:36:11 | BitPuffin | Araq: 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:50 | Araq | nobody will use it if you start with 1 |
22:39:14 | BitPuffin | ana |
22:39:36 | BitPuffin | Araq: well I'm not going to start with 1 after you adviced me not to, so why the bitterness |
22:39:50 | comex | start with 0.5 |
22:40:30 | Araq | I'm not really bitter, it's just a fact that most programmers can't even program fizzbuzz |
22:44:37 | xilo | dom96: wut wut |
22:45:15 | xilo | Araq: are you serial |
22:45:27 | Araq | no but serious |
22:45:28 | xilo | how can you say you can program if you can't do fizzbuzz :O |
22:45:38 | EXetoC | either 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:55 | EXetoC | xilo: did he? :p |
22:46:38 | xilo | so tell me about nimrod |
22:48:21 | Araq | xilo: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html |
22:48:22 | EXetoC | it's awesome and stuff |
22:51:10 | EXetoC | it's a ridiculous situation |
22:52:04 | * | DAddYE_ joined #nimrod |
22:52:38 | Araq | xilo: btw welcome! :-) |
22:53:23 | xilo | howdy ho |
22:55:20 | xilo | i had a pretty difficult screening question recently |
22:55:37 | xilo | it was |
22:56:15 | xilo | given 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:40 | Araq | are the strings in the hypothetical set all of the length of your given input string? |
22:58:55 | xilo | they must contain every letter |
22:58:58 | xilo | for example |
22:59:07 | xilo | aaba |
22:59:09 | xilo | you'd have |
22:59:21 | xilo | aaab, aaba, abaa, baaa. so it's index is 1 |
22:59:30 | xilo | or 2 on a non-zero starting point |
22:59:46 | Araq | the alphabet size is given? |
22:59:50 | xilo | no |
22:59:55 | xilo | just the string |
22:59:58 | Araq | it's a-z ? |
23:00:00 | xilo | so far example calling it |
23:00:22 | xilo | calculate("aaba") should return 1 (starting at 0) |
23:00:28 | xilo | yes just ascii letters |
23:00:38 | * | DAddYE quit (*.net *.split) |
23:00:59 | Araq | that's just a simple string to int conversion |
23:01:09 | Araq | with a-z instead of 0-9 |
23:01:18 | xilo | no |
23:01:49 | xilo | how do you find out which place it appears on the list? :) |
23:02:05 | xilo | can't do that just converting "aaba" to an int |
23:02:30 | Araq | yeah you can but the question is: why is there no aaaa in your example? |
23:02:44 | xilo | because aaaa isn't the letters in the string |
23:03:00 | xilo | it has to have 3 a's and 1 b |
23:03:38 | Araq | I see |
23:04:08 | Araq | so sort it and calculate the difference |
23:04:50 | xilo | try it out |
23:04:53 | xilo | top would be 5 |
23:04:57 | xilo | (starting at 1) |
23:04:58 | Araq | the latter might be hard though |
23:05:47 | Araq | on the other hand, brute force is easy |
23:06:11 | xilo | yeah, you just make a list of all possible combinations until you hit the one passed in |
23:06:17 | comex | well, that's lame |
23:06:25 | xilo | but that's generally the you don't pass our test case |
23:06:48 | comex | you can, at least, chop off all letters at the beginning that are already sorted |
23:07:01 | Araq | sort it == minimum, increment the minimum until you reach X, don't count combinations that X doesn't allow |
23:07:17 | Araq | but it's lame, yeah |
23:08:03 | comex | no... you can do it much better than that... I think? |
23:08:06 | comex | well, if you disallow duplicate letters |
23:08:09 | comex | (hypothetically) |
23:08:59 | comex | for 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:09 | comex | s/of/in |
23:09:21 | Araq | I think you need to sort it and during the sort accumulate the sum |
23:09:32 | Araq | where each swap does something to your sum |
23:09:38 | Araq | but I'm not sure what :P |
23:10:30 | Araq | bubble sort works I think |
23:10:32 | comex | i 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:49 | Araq | but don't count a<->a swaps |
23:13:51 | comex | so, 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:24 | comex | no, that's not right |
23:16:39 | comex | with duplicate characters it depends on which character you pick... |
23:16:48 | comex | so if you fix that it comes out to be exponential |
23:17:03 | comex | well, that's still better than than brute force |
23:17:16 | comex | well... does it? |
23:17:18 | comex | no, it doesn't |
23:17:55 | Araq | I think bubble sort with a sum function works |
23:18:05 | Araq | but I need to sleep now |
23:18:07 | Araq | good night |
23:19:15 | EXetoC | good luck. bye |
23:19:29 | BitPuffin | Araq: what's fizzbuzz got to do with it |
23:19:37 | BitPuffin | night! |
23:22:22 | * | Smaehtin quit (Quit: Page closed) |
23:27:42 | xilo | http://pastebin.com/rp8BufrZ here's the solution if you interested |
23:31:16 | comex | calculate = 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:21 | comex | there, that's mine |
23:31:36 | comex | i blame python not actually being designed for functional one-liners |
23:31:41 | comex | on me taking forever for that :) |
23:32:14 | xilo | what number does it give you if you put in bookkeeper |
23:32:21 | comex | 10742 |
23:32:24 | xilo | gj |
23:32:26 | xilo | that was fast |
23:32:28 | xilo | :O |
23:32:39 | comex | it's O(n^2) |
23:32:56 | comex | i think |
23:34:03 | xilo | is that creating the list of chars then finding the index? |
23:35:52 | comex | for a given word, it calculates how many unique permutations you get by removing each character valued less than the first one |
23:36:03 | comex | and then recurses |
23:36:15 | xilo | ah |
23:36:22 | comex | probably more expensive than that, whatever |
23:36:38 | xilo | think mine is |
23:36:42 | xilo | O(n) |
23:36:54 | xilo | idk |
23:36:56 | comex | it is |
23:38:01 | * | comex wonders how much prettier that would have been in haskell |
23:38:09 | xilo | so 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:51 | EXetoC | beebeep |
23:51:10 | EXetoC | BitPuffin: is your lib epic yet? |
23:51:19 | BitPuffin | EXetoC: nope :) |
23:51:39 | BitPuffin | EXetoC: doesn't even have vectors yet, currently looking to get a job |
23:53:58 | xilo | me too |