00:00:35 | FromGitter | <alehander42> what do you mean "compile" |
00:00:39 | FromGitter | <alehander42> by "compile" |
00:00:56 | FromGitter | <zacharycarter> I think I know what he means |
00:00:58 | FromGitter | <yyyc514> compile(parseStmt(“””code””")) for example |
00:01:16 | FromGitter | <zacharycarter> you want to resolve the concrete syntax that calling the macro would produce? |
00:01:30 | FromGitter | <zacharycarter> I think I have a gist of this somewhere |
00:01:41 | FromGitter | <yyyc514> seems i should be able to write a compile macro if nothing else |
00:01:45 | FromGitter | <yyyc514> but i’m getting somethign wrogn |
00:02:56 | FromGitter | <yyyc514> ok passing the string itself work |
00:03:03 | FromGitter | <yyyc514> macro compile*(t: string) : untyped = return parseStmt(t.strVal) |
00:03:27 | FromGitter | <zacharycarter> I guess I don't understand :P |
00:06:14 | FromGitter | <yyyc514> ha cause everything inside the block becomes AST |
00:06:20 | FromGitter | <yyyc514> ok so the only way it can work is if you pass a string |
00:06:26 | FromGitter | <yyyc514> youc an’t do `compile(parseStmt(“""` |
00:06:42 | FromGitter | <yyyc514> since you’ll just get `Call ... Sym “parseStmt”` AST |
00:27:31 | * | darithorn quit () |
00:48:50 | * | abm joined #nim |
00:50:03 | * | smt joined #nim |
00:56:45 | FromGitter | <yyyc514> @alehander42 If I lose the type from the intial call then I don’t known what type I need to use for the do dispatch |
00:56:54 | FromGitter | <yyyc514> :-/ |
00:59:06 | * | vlad1777d_ quit (Ping timeout: 268 seconds) |
01:07:12 | FromGitter | <alehander42> honestly I am not sure if you need it at all |
01:07:27 | FromGitter | <yyyc514> doesn’t work without it |
01:07:27 | FromGitter | <alehander42> I mean the user writes e.g. `field` somewhere |
01:07:44 | FromGitter | <alehander42> and you generate an invocation of a method taking instance.field |
01:07:54 | FromGitter | <alehander42> the nim type system takes care of it |
01:08:01 | FromGitter | <alehander42> if there is not such a field, compile error |
01:08:05 | FromGitter | <yyyc514> i’m talking about the do syntax |
01:08:12 | FromGitter | <alehander42> give me an example |
01:08:20 | FromGitter | <yyyc514> `(form_for(paste, action = "/pastes/") do (f: FormForHelper[Paste]) -> string:` |
01:08:30 | FromGitter | <yyyc514> that’s crazy verbose |
01:08:33 | FromGitter | <alehander42> that's what I mean |
01:08:57 | FromGitter | <alehander42> honestly I don't think now you need a FormForHelper to know anything about Paste |
01:09:26 | FromGitter | <yyyc514> ok you might be right there, but how does that help |
01:09:51 | FromGitter | <yyyc514> it wants a “concrete type" |
01:10:32 | FromGitter | <yyyc514> i mean you are right since FormHelper is a templtae/generic anyways :) |
01:10:41 | FromGitter | <yyyc514> but i’m not yet sure i get how that lets us shorten it |
01:11:18 | FromGitter | <alehander42> honestly, do people really need `f` |
01:11:23 | FromGitter | <alehander42> I remember rails had a variant |
01:11:25 | FromGitter | <yyyc514> lol |
01:11:30 | FromGitter | <alehander42> where you directly write text_field |
01:11:31 | FromGitter | <alehander42> etc |
01:11:37 | FromGitter | <alehander42> I guess in more complicated forms |
01:11:43 | FromGitter | <alehander42> you can have more than one builder? |
01:11:54 | FromGitter | <yyyc514> maybe not, but it’s pretty nice :) |
01:11:59 | FromGitter | <alehander42> but isn't |
01:12:05 | FromGitter | <yyyc514> well the alternative is repeating the object everywhere |
01:12:24 | FromGitter | <yyyc514> well a macro can rewrite it but it has to have enough context to know what to rewrite : |
01:12:41 | FromGitter | <yyyc514> i have a nice macro for just emptry blocks already |
01:12:44 | FromGitter | <alehander42> ```form_for(paste, action="/pastes/"): ⏎ textField(body) ⏎ ..``` [https://gitter.im/nim-lang/Nim?at=5bcbd28bbbdc0b250573b59f] |
01:12:51 | FromGitter | <alehander42> even simpler |
01:13:08 | FromGitter | <alehander42> that's what I meant |
01:13:11 | FromGitter | <yyyc514> you can have subcontexts though |
01:13:18 | FromGitter | <yyyc514> nested fields |
01:13:20 | FromGitter | <alehander42> ah |
01:13:31 | FromGitter | <yyyc514> you might need top_level.name right next to option.name |
01:13:38 | FromGitter | <yyyc514> where optiion is a list of options |
01:13:45 | FromGitter | <yyyc514> options belongs_to top_level, etc |
01:14:14 | FromGitter | <yyyc514> <%= div() do %> some junk <% end %> works really nice already with a macro |
01:14:25 | FromGitter | <yyyc514> turns do into do -> string, etc :-) |
01:14:32 | FromGitter | <yyyc514> but that’s easy cause we don’t need a helper |
01:15:43 | FromGitter | <alehander42> so can't form-for be a macro |
01:15:45 | FromGitter | <alehander42> which just rewrites |
01:15:48 | FromGitter | <alehander42> form_for(paste, action="/pastes/") do (f): |
01:16:00 | FromGitter | <alehander42> to internal_form_for(...) do (f: FormBuilder) -> ..: |
01:16:14 | FromGitter | <yyyc514> it needs to know the type of Paste though |
01:16:25 | FromGitter | <alehander42> but that's my theory : does it |
01:16:56 | FromGitter | <alehander42> give me an example of a method |
01:16:59 | FromGitter | <yyyc514> so far all these are procs and the rewrite magic is macros |
01:17:10 | FromGitter | <alehander42> e.g. f.radio_button(paste.attr) |
01:17:28 | FromGitter | <yyyc514> you’d just have the name there not paste.attr |
01:17:38 | FromGitter | <alehander42> so f.radio_button(attr) ? |
01:18:01 | FromGitter | <yyyc514> yeah, but it’d have to be static, or else you need to compile a lookup table for runtime |
01:18:08 | FromGitter | <yyyc514> f.radio_button(“time_mode”) |
01:18:19 | FromGitter | <alehander42> and time_mode is a field of paste ? |
01:18:23 | FromGitter | <yyyc514> yes |
01:18:33 | FromGitter | <alehander42> then you just mechanicaly |
01:18:39 | FromGitter | <alehander42> generate paste.<name> |
01:18:48 | FromGitter | <alehander42> you don't need to know the fields for the rewrite |
01:19:03 | FromGitter | <alehander42> because the user already typed them |
01:19:15 | FromGitter | <yyyc514> but right now i need to know the Type |
01:19:24 | FromGitter | <alehander42> why? |
01:19:57 | FromGitter | <yyyc514> we might be coming at this from diff angles… i’m always thinking a bit more abstractly beyond this single use case… I want helpers to be usable things |
01:20:58 | FromGitter | <yyyc514> and i want to use language features of nim when possible |
01:21:25 | FromGitter | <yyyc514> right now all the scoping and blocks and everything i get for “Free” with do |
01:21:32 | FromGitter | <yyyc514> if i have to rebuild that all with macros... |
01:21:34 | FromGitter | <alehander42> I am saying this, because I have experience with this untyped vs typed approach: e.g. for pattern matching I've tried both and I found out ⏎ I can fully do it with untyped in a simpler way ⏎ importantly, with typed I was just reimplementing stuff the compiler should do anyway |
01:21:50 | FromGitter | <alehander42> and I get it for free with simpler logic |
01:21:56 | FromGitter | <alehander42> sometimes it's the opposite |
01:22:00 | FromGitter | <yyyc514> i guess i’d have to see a full example :) |
01:22:01 | FromGitter | <alehander42> of course |
01:22:33 | FromGitter | <yyyc514> it doesn’t have to be 100% pretty, i just need to see the whole thing conceptually |
01:23:03 | FromGitter | <yyyc514> are you talking about using macros to just inject the |f| as a var or something? |
01:23:57 | FromGitter | <alehander42> so you want custom helpers, like color_field time_field number_field etc ? |
01:24:11 | FromGitter | <alehander42> I am just not sure why do you need the macro to know the type |
01:24:21 | FromGitter | <alehander42> because I expect that the final code would be still |
01:24:39 | FromGitter | <yyyc514> IF i use the “do” syntax internaly it seems to need it |
01:24:44 | FromGitter | <alehander42> f.color_field(paste.attr) |
01:24:57 | FromGitter | <yyyc514> if you throw that out the window then you have to rebuild what do gives you |
01:25:10 | FromGitter | <alehander42> but if you use do |
01:25:16 | FromGitter | <alehander42> you can always generate |
01:25:26 | FromGitter | <alehander42> do (f: FormBuilder) -> string |
01:25:48 | FromGitter | <yyyc514> oh wait you’re sayign just lose the type of FormBuilder |
01:25:52 | FromGitter | <alehander42> or if it's very important ⏎ do (f: paste.type) -> string |
01:25:55 | FromGitter | <alehander42> (I think) |
01:26:11 | FromGitter | <alehander42> (maybe you need import typetraits for the last one) |
01:26:19 | FromGitter | <alehander42> f: FormBuilder[paste.type] * |
01:26:26 | FromGitter | <alehander42> but yeah I am not sure |
01:26:30 | FromGitter | <yyyc514> can that even work? |
01:26:34 | * | FromGitter * yyyc514 trying |
01:26:39 | FromGitter | <yyyc514> i’ already using typetraits :) |
01:26:43 | FromGitter | <alehander42> the second one not sure |
01:27:15 | FromGitter | <alehander42> but I am not sure that you need FormBuilder to know about InstanceType at all |
01:27:40 | FromGitter | <alehander42> it depends: do helpers often need other data about an instance except the field args |
01:28:44 | FromGitter | <yyyc514> not form helpers but i could imagine more complex stuff where it’d be useful |
01:29:22 | FromGitter | <yyyc514> ok paste is actually a ref |
01:29:28 | FromGitter | <yyyc514> how do i turn a ref type into a type type :) |
01:31:26 | FromGitter | <alehander42> not sure what you mean |
01:31:35 | FromGitter | <alehander42> the type of it should be available as paste.type |
01:31:46 | FromGitter | <yyyc514> ye but that is “ref Paste" |
01:31:46 | FromGitter | <alehander42> but not sure if it's directly usable in proc |
01:31:48 | FromGitter | <yyyc514> when we want Paste |
01:31:51 | FromGitter | <alehander42> aaaaah |
01:32:07 | FromGitter | <alehander42> well, you want the type of paste |
01:32:16 | FromGitter | <alehander42> if it's ref Paste indeed |
01:32:21 | FromGitter | <alehander42> let it be? |
01:32:50 | FromGitter | <alehander42> I am not sure how did it end up like that, is Paste = ref object .. |
01:33:32 | FromGitter | <alehander42> (otherwise I guess something like (paste[]).type) |
01:33:40 | FromGitter | <yyyc514> var paste = Paste() |
01:33:48 | FromGitter | <yyyc514> oh duh :) [] |
01:34:36 | FromGitter | <yyyc514> whoa :) |
01:34:53 | FromGitter | <yyyc514> and that just works |
01:35:13 | FromGitter | <alehander42> does it |
01:35:24 | FromGitter | <yyyc514> yes :) |
01:35:34 | FromGitter | <yyyc514> `(form_for(paste, action = "/pastes/") do (f: FormForHelper[paste[].type]) -> string:` |
01:35:35 | FromGitter | <alehander42> nice |
01:35:51 | FromGitter | <yyyc514> should it not be a ref? that’s just what Paste() is giving me |
01:35:58 | FromGitter | <yyyc514> so i just ran with it |
01:36:06 | FromGitter | <alehander42> well, I'd just use paste.type |
01:36:24 | FromGitter | <alehander42> some objects might be ref, some not (I guess) |
01:36:42 | FromGitter | <alehander42> so now one can |
01:36:42 | FromGitter | <yyyc514> my new() returns Paste type |
01:37:01 | FromGitter | <alehander42> usually you don't need new() |
01:37:14 | FromGitter | <alehander42> almost always people just do a = A() |
01:37:20 | FromGitter | <yyyc514> oh i wrote my own that just makes a new paste now the new that allocs |
01:37:23 | FromGitter | <yyyc514> might want to rename it |
01:37:27 | FromGitter | <yyyc514> yeah that’s what new does :) |
01:37:45 | FromGitter | <yyyc514> it has a DateTime which evidentaly can’t be empty |
01:37:49 | FromGitter | <alehander42> yeah please rename it, as new is usually different |
01:37:49 | FromGitter | <yyyc514> so Paste() is actually a no go |
01:38:07 | FromGitter | <yyyc514> i’d use newPaste() but i thought Paste.new() was prettier :) |
01:38:25 | FromGitter | <yyyc514> or is that why i have a ref? some wierd interaction there? |
01:39:01 | FromGitter | <yyyc514> lol |
01:39:02 | FromGitter | <yyyc514> yep |
01:39:07 | FromGitter | <yyyc514> cause i never exported my new ROFL |
01:39:40 | FromGitter | <alehander42> haha probably |
01:39:54 | FromGitter | <yyyc514> i still need to figure out the point |
01:39:56 | FromGitter | <alehander42> but maybe use init |
01:40:00 | FromGitter | <yyyc514> aren’t objects already by reference? |
01:40:05 | FromGitter | <alehander42> it's more nim-ish |
01:40:33 | FromGitter | <yyyc514> or i guess a ref lets me literally copy the ref where-as maybe by default the other is more of a copy-on-write? |
01:40:39 | FromGitter | <alehander42> if A is object |
01:40:48 | FromGitter | <alehander42> a = A(..) : a is object too |
01:40:51 | FromGitter | <alehander42> if A is ref object |
01:40:55 | FromGitter | <alehander42> a = A(..) is ref object too |
01:41:02 | FromGitter | <alehander42> if you do a = new A(..) |
01:41:07 | FromGitter | <alehander42> I think it will be a ref ref object |
01:41:20 | FromGitter | <alehander42> (I guess it will allocate a ref to the val) |
01:41:26 | FromGitter | <yyyc514> going to go read: https://forum.nim-lang.org/t/1207 |
01:42:29 | FromGitter | <alehander42> good idea |
01:42:37 | FromGitter | <alehander42> ok, I am going to bed as it's 4 am here |
01:42:43 | FromGitter | <yyyc514> night |
01:42:47 | FromGitter | <alehander42> good luck |
01:42:51 | FromGitter | <yyyc514> afaik it seems to be largly about stack vs heap |
01:42:57 | FromGitter | <yyyc514> refs are dynamicly allocated |
01:43:45 | FromGitter | <yyyc514> "The primary between a plain object and a reference is that assignment makes a copy of the original object. " |
01:43:59 | FromGitter | <alehander42> yeah, ref is basically a gced pointer |
01:46:33 | * | darithorn joined #nim |
01:51:30 | FromGitter | <yyyc514> yeah |
01:51:43 | FromGitter | <yyyc514> normal objects are either copy or copy on write |
01:54:32 | * | enthus1ast quit (Ping timeout: 252 seconds) |
02:04:58 | * | banc quit (Quit: ZNC - http://znc.in) |
02:05:56 | FromGitter | <yyyc514> hmmm doe embedsrc literally supposed to put nim code beside the C? |
02:05:58 | FromGitter | <yyyc514> i’m not seeing that |
02:20:47 | * | banc joined #nim |
02:42:23 | * | zachk quit (Quit: Leaving) |
02:44:36 | * | platoff quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
03:08:27 | * | chemist69 quit (Ping timeout: 252 seconds) |
03:10:14 | * | chemist69 joined #nim |
04:04:18 | * | abm quit (Ping timeout: 252 seconds) |
04:22:23 | * | darithorn quit () |
04:37:13 | * | oky joined #nim |
04:50:50 | * | smt quit (Read error: Connection reset by peer) |
05:13:13 | * | nsf joined #nim |
05:39:08 | * | narimiran joined #nim |
06:14:43 | * | dddddd quit (Remote host closed the connection) |
06:23:27 | * | tefter joined #nim |
06:45:07 | * | stefanos82 joined #nim |
06:59:15 | FromGitter | <mratsim> Is there a IRC/Gitter split? |
06:59:34 | narimiran | i see your comment here |
07:00:10 | FromGitter | <mratsim> cool |
07:00:18 | * | stefanos82_ joined #nim |
07:00:33 | * | stefanos82 quit (Ping timeout: 252 seconds) |
07:00:41 | FromGitter | <kayabaNerve> @mratsim I see your comment |
07:00:49 | * | stefanos82_ quit (Client Quit) |
07:00:55 | FromGitter | <kayabaNerve> #Helping |
07:15:22 | * | nsf quit (Quit: WeeChat 2.2) |
07:32:16 | * | stefanos82 joined #nim |
07:45:12 | FromGitter | <tim-st> Is there a reason why nim doesnt support variable length array (fixed array of runtime size)? I read c supports it |
07:47:25 | * | Vladar joined #nim |
07:51:49 | * | TheLemonMan joined #nim |
07:52:25 | TheLemonMan | "fixed array of runtime size" ? it's either fixed-sized or growable at runtime... |
07:54:05 | FromGitter | <tim-st> if the size is determined at runtime of course it can be fixed size |
07:55:04 | TheLemonMan | oh, so a non-growable vector. There's the rtarray module for that |
07:55:22 | FromDiscord | <exelotl> like `int arr[x];` in C where x is some variable. The array will still be allocated on the stack |
07:55:53 | FromGitter | <tim-st> yes, I meant that type, I think the problem is that's not supported in c++ only in c99 |
07:56:08 | FromGitter | <tim-st> https://en.wikipedia.org/wiki/Variable-length_array |
07:56:14 | TheLemonMan | using VLAs that way is a horrible practice |
07:56:33 | FromGitter | <tim-st> I read it's up to 5 times quicker than vector |
07:57:51 | TheLemonMan | that's because you just bump the SP in order to allocate them |
07:58:28 | FromGitter | <tim-st> ok, so it's not a candidate for nim? |
07:59:39 | TheLemonMan | https://wiki.sei.cmu.edu/confluence/display/c/MEM05-C.+Avoid+large+stack+allocations |
08:00:27 | FromGitter | <tim-st> yes, that's a good point with "controlled by attacker" |
08:00:39 | TheLemonMan | I guess it's not (you can still wrap alloca & use it but beware it may break in unexpected ways) |
08:01:06 | FromGitter | <tim-st> ok, thanks |
08:01:28 | FromGitter | <tim-st> isn't that type is used by java all the time^^ |
08:01:56 | TheLemonMan | java runs on a VM so no ? |
08:02:08 | FromGitter | <tim-st> oh, no they dont, it's to long ago I used java :\ |
08:03:06 | Araq | C99 is not a standard worth reading, it's written by a bunch of C++ haters that add features that will cause the maximum amount of friction for C/C++ interop |
08:03:33 | FromGitter | <tim-st> ok^^ |
08:03:57 | Araq | sure, let's add complex numbers to C, but still offer no sane way to detect integer overflows |
08:04:20 | Araq | criminals at work. |
08:05:26 | Araq | and afterwards they added a threading model, incompatible with Posix's while still not offering a sane way to detect integer overflows... |
08:06:31 | Araq | oh and overloading is so bad, so we will add it, but based on some preprocessor magic, incompatible with C++'s model |
08:06:47 | TheLemonMan | you must really like integer overflows |
08:07:40 | TheLemonMan | is it? I thought _Generic was handled by the compiler and not by the preprocessor |
08:07:53 | Araq | I enjoy detecting them until the hardware devs embrace my sticky saturated integer arithmetic (patent pending...) |
08:09:17 | Araq | TheLemonMan: I probably misremember |
08:09:17 | TheLemonMan | "sticky saturated" -> that's almost as bad as silent wraparounds :) |
08:09:45 | Araq | no, you can compute for a while and if it's +/-Inf you know you screwed up :-) |
08:10:20 | Araq | and alloc(Inf) fails so you don't get heap corruptions |
08:11:58 | TheLemonMan | it's so crazy it may even work heh |
08:13:08 | Araq | I analyzed plenty of programs, it's the best way to do it, especially if hardware assisted exception handling is off the table |
08:13:49 | Araq | and since proving at compile-time that overflows cannot happen seems unfeasible for most programs out there |
08:14:15 | Araq | bbl |
08:18:21 | FromGitter | <mratsim> @tim-st bad idea, you might overwrite your return stack |
08:18:55 | FromGitter | <mratsim> But if you feel adventurous, here you go: https://github.com/status-im/nim-ranges/blob/master/ranges/stackarrays.nim |
08:19:00 | TheLemonMan | that's a good idea if you write your program as a huuge ROP chain :) |
08:19:55 | FromGitter | <mratsim> Otherwise just use a stack array of fixed size but implement dynamic like features like I do in Arraymancer: https://github.com/numforge/laser/blob/master/laser/dynamic_stack_array.nim <— this is a stand alone version |
08:21:18 | FromGitter | <mratsim> Or if you want, part stack to optimize for small stuff and still allow more elements on the heap use or implement something like LLVM’s SmallVector: http://llvm.org/doxygen/SmallVector_8h_source.html |
08:22:48 | TheLemonMan | iirc SmallVector behaves like RtArray does |
08:23:19 | FromGitter | <mratsim> rtarrays have no doc :P |
08:25:56 | FromGitter | <mratsim> actually there are not implemented: https://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/rtarrays.nim |
08:27:14 | TheLemonMan | the api is quite...minimal? but the functionality is there |
08:27:28 | FromGitter | <mratsim> btw @TheLemonMan, I started the refactoring of Arraymancer backends here: https://github.com/numforge/laser/blob/master/laser/tensor/datatypes.nim. THis should be much easier than seqs for Numpy interface |
08:27:31 | TheLemonMan | allocate with initRtArray and get a pointer with getRawData |
08:28:43 | TheLemonMan | heh I was wondering what `laser` was |
08:29:15 | FromGitter | <mratsim> An experiment at creating the fastest and flashiest tensor backend ever :P |
08:29:39 | FromGitter | <mratsim> Have to compare with the stuff done by Halide-lang but I’m sure I compile much faster than it :P |
08:30:22 | FromGitter | <mratsim> For now, there is runtime cpu capabilities detection, the dynamic stack arrays, and variadic parallel strided loops |
08:30:36 | TheLemonMan | the use of TRM is also pretty nice |
08:31:25 | FromGitter | <mratsim> OpenMP templates with tuning including chunk processing. |
08:31:54 | FromGitter | <mratsim> so I can use copyMem on parallel chunks for example |
08:35:13 | TheLemonMan | I just got my libclang-based bindings generator to build bindings for libclang :D |
08:35:39 | TheLemonMan | bootstrap acheived! |
08:35:59 | FromGitter | <mratsim> we’re not far from the singularity :P |
08:44:06 | FromGitter | <Vindaar> @mratsim looking at laser: so the `DynamicStackArray` is purely used to store meta information of a tensor like shape, yes? And wasn't one goal of arraymancer to support up to 7D tensors for video processing? |
08:44:19 | FromGitter | <mratsim> only need 6D |
08:44:49 | FromGitter | <Vindaar> ah, then I misremembered |
08:45:00 | FromGitter | <mratsim> batch_size, time, color, depth, height, width |
08:45:17 | FromGitter | <mratsim> and that’s for 3D videos ;) |
08:45:25 | FromGitter | <Vindaar> hehe, makes sense, yeah |
08:45:27 | FromGitter | <mratsim> a stack of 3D videos even |
08:46:13 | FromGitter | <mratsim> limiting to 6 dimensions allows me to keep a complete tensor metadata in 2 cache lines. |
08:47:08 | FromGitter | <Vindaar> yup, that's what I got from the comments in the code. I have no intuition for the efficiency improvement that brings, but sounds useful :) |
08:48:02 | FromGitter | <mratsim> 33% improvement :P |
08:48:14 | FromGitter | <Vindaar> :P |
08:48:30 | FromGitter | <Vindaar> I guess it's not /that/ easy, is it? |
08:49:13 | FromGitter | <Vindaar> (purely for `DynamicStackArrays` I guess it is) |
08:49:27 | * | Sembei joined #nim |
08:50:03 | * | Pisuke quit (Ping timeout: 245 seconds) |
08:50:46 | FromGitter | <mratsim> The improvement happen here: https://github.com/numforge/laser/blob/master/benchmarks/loop_iteration/iter02_pertensor.nim#L23-L25 ⏎ ⏎ Basically this is a tight loop to compute the next offset to yield when the tensor is strided |
08:51:08 | FromGitter | <mratsim> strided meaning [0, 0, 1] isn’t just after [0, 0, 0] in memory |
08:52:13 | FromGitter | <mratsim> assuming you loop over 3 tensors to do C = A + B. You would need 9 cache lines = 900 CPU cycles (assuming no prefetch) vs 6 cache lines = 600 CPU cycles |
08:52:42 | FromGitter | <mratsim> if we assume the cost of loading from a cache at 100 cycles |
08:53:18 | FromGitter | <mratsim> and that cost is just for loading data. Compared to that, floating point addition takes 1 cycle |
08:53:35 | FromGitter | <mratsim> i.e. I could add 300 more numbers in the time I wait for data |
08:54:26 | FromGitter | <mratsim> —> lots of stuff on tensors are memory-bound (i.e. you spend a lot of time waiting for memory) so reducing the costs of memory accesses is a must. |
08:56:49 | FromGitter | <Vindaar> the 9 vs 6 would be for 3 vs 2 cache lines for one `DynamicStackArray`? That's beginning to make a lot more sense, thanks! |
08:56:54 | narimiran | "mhm, yeah yeah, i know some of these words" |
08:57:58 | * | tdc quit (Ping timeout: 245 seconds) |
08:58:02 | FromGitter | <mratsim> well I’m exagerating the latency if the data is already in Cache, but 100 cycles is true if data is in RAM: https://www.7-cpu.com/cpu/Haswell.html |
08:59:15 | FromGitter | <mratsim> in L1 or L2 cache it’s in the order of 10 cycles apparently. |
09:03:26 | * | gmpreussner_ quit (Ping timeout: 272 seconds) |
09:03:39 | * | gmpreussner joined #nim |
09:04:28 | FromGitter | <Vindaar> where do the additional specific latencies in ns come from? is that based on a specific clock speed? |
09:05:05 | FromGitter | <mratsim> it’s based on the number of channels in your RAM and it’s clock speed yes (like 2100Mhz, 2666Mhz …) |
09:05:31 | FromGitter | <Vindaar> ah :) |
09:58:18 | * | enthus1ast joined #nim |
10:00:46 | * | nsf joined #nim |
10:07:39 | * | tdc joined #nim |
10:36:57 | * | elrood joined #nim |
10:41:16 | planetis[m] | hey, does anyone have a hierarchical fsm example for spare? I m writing a fsm macro and could use an example |
10:54:20 | FromGitter | <tekjar> Has anyone tried using nim on nuttx rtos? |
10:54:35 | FromGitter | <tekjar> It has full posix compliance |
11:14:58 | * | TheLemonMan quit (Quit: "It's now safe to turn off your computer.") |
11:20:30 | * | kapil____ joined #nim |
11:47:49 | * | abm joined #nim |
11:53:54 | FromDiscord | <hotdog> @planetis I would be interested in seeing what you create, please ping me if you put it online |
11:54:09 | FromDiscord | <hotdog> A nice hfsm dsl is on my to-do list |
11:59:15 | * | narimiran quit (Quit: Konversation terminated!) |
12:01:16 | planetis[m] | its more like a toy |
12:01:40 | planetis[m] | it uses the state pattern to write a procedural fsm |
12:02:03 | planetis[m] | thus doesn't support state variables |
12:02:14 | planetis[m] | sure i will upload it soon |
12:14:22 | planetis[m] | @hotdog if you had an example that help a lot |
12:43:05 | * | platoff joined #nim |
12:44:16 | * | platoff quit (Client Quit) |
12:45:14 | * | vlad1777d_ joined #nim |
13:01:40 | FromGitter | <mratsim> that’s something I wanted to write 2 weeks ago as well :P |
13:08:15 | * | tefter quit (Remote host closed the connection) |
13:15:27 | FromDiscord | <hotdog> I don't have an example I'm afraid, I haven't started it yet |
13:18:45 | * | smt joined #nim |
13:34:03 | * | dddddd joined #nim |
13:34:19 | planetis[m] | I just need an example of a simple (standalone) hfsm. I still searching but haven't found smthng nice |
13:34:47 | * | enthus1ast quit (Read error: Connection reset by peer) |
13:39:05 | planetis[m] | anyway tough luck I guess, here it is https://github.com/b3liever/macromachining I hope you like it |
13:39:39 | planetis[m] | but probably doesn't do what hfsm should I havent tested it. |
13:58:40 | planetis[m] | you all wanted to write one, Iam waiting for your suggestions ;) |
14:01:24 | * | smt` joined #nim |
14:05:04 | * | smt quit (Ping timeout: 272 seconds) |
14:11:04 | FromGitter | <xmonader> guys how can i encode `binary data` using base64 encode ? |
14:19:56 | FromGitter | <tim-st> is it possible to add an url to a git repo as dependency of a nimble package? |
14:20:11 | FromGitter | <tim-st> (which is itself a nimble package) |
14:22:31 | FromGitter | <tim-st> oh, it is possible :) https://github.com/nim-lang/nimble/issues/270#issuecomment-257834625 |
14:23:50 | * | Trustable joined #nim |
14:23:51 | * | vlad1777d_ quit (Ping timeout: 268 seconds) |
14:24:16 | FromGitter | <tim-st> dom96: when I use the method above is it a problem when the package name is already used by another person? |
14:51:27 | * | abm quit (Ping timeout: 240 seconds) |
14:51:29 | copygirl | Mhh.. two questions, guys. |
14:52:04 | copygirl | First of all, apologies for essentially asking you to do my work as a programmer for me. |
14:52:54 | copygirl | I would like to make a couple of Either[T0, T1] types which will be case types that contain either a value of type T0 or T1, but the order shouldn't matter. |
14:53:33 | copygirl | So if I create an `either("string", int)` or an `either(5, string)` it would turn out the same.. or so. |
14:54:17 | leorize | quite simple actually |
14:54:27 | leorize | make an `Either[T, U]` |
14:54:38 | copygirl | I was thinking of creating a hashset of types and just iterating the types, but I'm not quite sure how to handle the types property (`type(value)`, `typedesc`?) |
14:54:44 | leorize | and a template `either` to put the stuff in the correct order |
14:55:05 | copygirl | Or a template. But.. how? |
14:55:07 | FromGitter | <alehander42> `type T` I think |
14:55:42 | FromGitter | <alehander42> e.g. eitherT, U (a: T, b: type U): Either[T, U] |
14:55:46 | FromGitter | <alehander42> `e.g. eitherT, U (a: T, b: type U): Either[T, U]` |
14:57:17 | copygirl | Yeah but then `either("string", int)` is an incompatible type with `either(t, string)`. |
14:57:28 | copygirl | (`t` was meant to be `5`) |
14:58:37 | copygirl | I probably still don't know the proper powers of templates as well.. |
14:58:42 | FromGitter | <alehander42> ahh |
14:58:43 | FromGitter | <alehander42> I see |
14:58:57 | FromGitter | <alehander42> basically you want Either[T, U] to be equivalent to Either[U, T] |
14:59:34 | copygirl | Or the method creating an either to always return the same type, perhaps. |
14:59:55 | copygirl | If you give it the same types, regardless of order. |
15:00:02 | leorize | or make a `converter`? |
15:00:35 | FromGitter | <alehander42> crafty, a converter might be the simplest solution |
15:00:36 | copygirl | I think that's just going to cause weirdnesses. |
15:00:50 | leorize | why? |
15:02:48 | copygirl | Well I'd have to write a bunch of converters first of all. Imagine an Either[T0, T1, T2, T3]. |
15:03:45 | leorize | are you gonna use that kind of `Either`? |
15:04:27 | copygirl | Yes. I'm writing a json schema validator and converter that is supposed to allow properties of various possible types. |
15:05:20 | copygirl | And it can be more than just `string or int or bool`, but `string or SomeObj or SomeElement[] or ...` |
15:07:26 | leorize | hmmmm |
15:07:39 | leorize | write a macro that generates a bunch of converters? :P |
15:08:19 | copygirl | But then I could also just write a macro that sorts the types. |
15:08:50 | leorize | do you have a good idea on how to sort them? |
15:11:15 | copygirl | Not sure if default HashSet iterator would always sort them the same. |
15:12:20 | copygirl | Only problem would occur if you had to type `Either[X, Y, Z]` and had to know said order but... I think the type itself is not something you use in regular code. It'd just be.. an way to offer utility functions to get at the actual values inside..? |
15:12:34 | copygirl | a way* |
15:13:01 | leorize | overload the `[]` operator then? |
15:13:37 | leorize | the only problem is that typedesc is a compile time value... |
15:17:05 | leorize | how 'bout a `[]` macro? |
15:17:38 | leorize | it could easily traverse the type tree to retrieve the correct variable |
15:17:50 | leorize | or "field" |
15:18:02 | copygirl | Yeah I'm doing either[string] to get the string of that either variable, for example. |
15:30:36 | leorize | copygirl: https://ptpb.pw/z4fK |
15:30:58 | leorize | that's my small template contraption |
15:32:54 | copygirl | Mhh maybe I can work it.. |
15:33:58 | copygirl | The thing is I'll have an object that has a property of type `Either[T, U, V]` and I need to set it to something. |
15:34:11 | * | Trustable quit (Remote host closed the connection) |
15:34:19 | copygirl | And I need to generate code that sets it depending on the incoming type. |
15:34:38 | copygirl | Or.. wait. Hm. |
15:34:49 | copygirl | Maybe it *doesn't* matter. |
15:36:27 | copygirl | Though now if I want to generate a bunch of functions and type definitions for various-size Either types - what would be the best way to do that? |
15:36:46 | leorize | macros all the way |
15:37:50 | copygirl | I just wonder if I can use `quote` for that. |
15:38:11 | dom96 | tim-st: a little bit, yes. |
15:38:41 | copygirl | Because the macros for the functions especially will just be a pain to write with only newTree and newNimNode and such. I might as well just write it manually. |
15:39:17 | leorize | sure, you could use `quote`, but not for the type def if it's arbitrary sized |
15:39:28 | * | elrood quit (Quit: Leaving) |
15:39:33 | * | kapil____ quit (Quit: Connection closed for inactivity) |
15:40:12 | * | edcragg quit (Quit: ZNC - http://znc.in) |
15:41:41 | * | edcragg joined #nim |
15:43:47 | * | tdc quit (Ping timeout: 240 seconds) |
15:45:02 | * | darithorn joined #nim |
15:50:28 | * | abm joined #nim |
16:00:35 | * | tdc joined #nim |
16:04:45 | * | stefanos82 quit (Quit: Quitting for now...) |
16:21:04 | FromDiscord | <hotdog> @planetis just had a look, I like it |
16:21:25 | FromDiscord | <hotdog> I recognise the miner example, is that from game programming patterns? |
16:21:49 | planetis[m] | thank you :) |
16:21:56 | FromGitter | <tim-st> dom96: Ok, I wasnt sure, maybe the package from the url repo is also placed inside the package that has it as dependency, then it wouldnt be a problem |
16:22:11 | planetis[m] | no from Programming game ai by example |
16:23:12 | planetis[m] | It pbl doesn't work correctly since I am just getting to understand fsm's |
16:23:14 | planetis[m] | and its also hard-coded |
16:25:54 | * | wildlander quit (Quit: Konversation terminated!) |
16:29:16 | FromDiscord | <hotdog> Ah yeah I knew I recognised it from somewhere |
16:29:38 | * | tdc quit (Ping timeout: 245 seconds) |
16:30:52 | FromDiscord | <hotdog> I think the best way to understand fsms would just be to use it in a real project |
16:31:10 | FromDiscord | <hotdog> Hypothetical examples in tutorials aren't great |
16:39:54 | * | leorize quit (Remote host closed the connection) |
16:40:17 | * | vlad1777d_ joined #nim |
16:41:21 | * | leorize joined #nim |
17:34:05 | * | mech422__ joined #nim |
17:40:15 | FromDiscord | <Jérôme> Hello, how are you ? :) |
17:40:15 | FromDiscord | <Jérôme> |
17:40:15 | FromDiscord | <Jérôme> I want your opinion on whether this is possible or not. |
17:40:16 | FromDiscord | <Jérôme> |
17:40:16 | FromDiscord | <Jérôme> My project is to create a website that retrieves information via JSON and displays the latest news directly on the homepage. |
17:40:16 | FromDiscord | <Jérôme> |
17:40:18 | FromDiscord | <Jérôme> I want to know if I can do my project with KARAX? |
17:40:20 | FromDiscord | <Jérôme> Can I also add SQLite or PostgreSQL with KARAX? |
17:40:21 | FromDiscord | <Jérôme> |
17:40:22 | FromDiscord | <Jérôme> Thank you |
17:44:41 | dom96 | You can do anything with Karax |
17:44:52 | dom96 | mech422__: hard to say without seeing code |
17:47:39 | dom96 | that's inheritance |
17:47:51 | dom96 | you're declaring an object that inherits from RootObj |
17:48:52 | dom96 | it's a keyword |
17:48:57 | dom96 | it's a type of kind |
17:49:35 | FromDiscord | <Jérôme> @gitterirc I do not have a code yet because I have not started yet, but if you tell me that SQLite can work with KARAX or even POSTGRESQL and that the JSON passes well then my project can see the day ^^ |
17:51:28 | dom96 | Jérôme: The Nim forum is written in Karax and it uses SQLite |
17:52:27 | dom96 | You're defining an `object` |
17:52:30 | dom96 | That's why it's there |
17:52:52 | FromDiscord | <Jérôme> @gitterirc Super I go then, thank you for you is the return |
17:53:19 | FromDiscord | <Jérôme> ok i take note of you is advice |
17:53:37 | FromDiscord | <Jérôme> 🙂 😃 |
17:54:38 | dom96 | Here is NimForum's source code: https://github.com/nim-lang/nimforum |
17:56:06 | dom96 | You should read " Foo = ref object of RootObj" as "Foo is a reference object that inherits from RootObj" |
17:57:39 | FromDiscord | <Jérôme> Good thank you very much, one last question that has nothing to do with my project. |
17:57:39 | FromDiscord | <Jérôme> |
17:57:39 | FromDiscord | <Jérôme> Do you think that NIM could be registered on learning platforms or code games like https://www.codingame.com/start because it will make the language known to a larger audience, it would be good |
17:58:36 | FromGitter | <alehander42> you still need a server lib probably, karax is a SPA |
18:00:27 | FromDiscord | <Jérôme> Sorry my english is not ready yet |
18:00:34 | FromDiscord | <Jérôme> 🙂 |
18:20:29 | * | PMunch joined #nim |
18:33:47 | FromGitter | <alehander42> no problem, have you used other languages for web sites before? |
18:35:07 | * | Senketsu quit (Quit: WeeChat 2.2) |
18:35:20 | * | PrimHelios quit (Ping timeout: 276 seconds) |
18:37:38 | * | Senketsu joined #nim |
18:57:53 | FromDiscord | <Jérôme> @gitterirc Yes, HTML, CSS, JS and a can Python |
18:57:55 | FromDiscord | <Jérôme> 😃 |
19:02:09 | * | PMunch quit (Remote host closed the connection) |
19:13:50 | FromGitter | <tim-st> is there a way to give two different variants in a object variant the same field name? |
19:14:00 | FromGitter | <tim-st> is it a bug or a feature? |
19:20:09 | * | tdc joined #nim |
19:35:41 | * | kapil____ joined #nim |
19:39:14 | FromGitter | <alehander42> @Jérôme ok, so nim + karax is the equivalent of typical html + JS |
19:39:44 | FromGitter | <alehander42> but to write the equivalent of the server side code which you would do in Python (e.g. Django or Flask) you would use nim + e.g. Jester |
20:05:22 | * | glassofethanol joined #nim |
20:18:42 | * | anamok joined #nim |
20:18:45 | anamok | hi |
20:19:34 | anamok | Nim has some pseudo-types, like Number. Where are they defined? Where can I see what Number is actually? |
20:19:43 | * | Vladar quit (Remote host closed the connection) |
20:22:17 | FromDiscord | <Epictek> Would is be possible to make Karax attach to a shadow DOM? Would I need to edit the karx source code or could I do it with the existing implementation? |
20:23:57 | anamok | What's the difference between Number and SomeNumber? |
20:31:02 | FromGitter | <citycide> anamok: a lot of types like that are defined in `system.nim`. I don't think there is a `Number` type but `SomeNumber` is basically any of int/float, signed/unsigned |
20:31:49 | FromGitter | <citycide> https://nim-lang.org/docs/system.html#SomeNumber - you can click the types there, so you can follow the breadcrumbs on what they are |
20:32:14 | anamok | my bad, there is really no Number |
20:37:12 | anamok | If I have `func myMax(a: SomeNumber, b: SomeNumber): SomeNumber = ...`, then I can call it with myMax(int, int) and myMax(float, float), but myMax(int, float) is not allowed. Why is it? int is some number, float is some number... |
20:37:46 | * | nsf quit (Quit: WeeChat 2.2) |
20:37:51 | * | glassofethanol left #nim (#nim) |
20:40:07 | * | tdc quit (Ping timeout: 240 seconds) |
20:42:57 | * | xet7 quit (Ping timeout: 250 seconds) |
21:00:38 | * | xet7 joined #nim |
21:02:24 | * | xet7 quit (Remote host closed the connection) |
21:04:53 | * | xet7 joined #nim |
21:12:32 | FromGitter | <kayabaNerve> anamok: I have a guess |
21:12:41 | FromGitter | <kayabaNerve> It's hooking into the generic system |
21:12:46 | FromGitter | <kayabaNerve> SN1 == SN2 == SN3 |
21:12:54 | FromGitter | <kayabaNerve> But your SN1 != SN2 |
21:12:59 | FromGitter | <kayabaNerve> So it doesn't know what to return |
21:13:43 | * | elrood joined #nim |
21:14:57 | anamok | So if I specify SomeNumber several times in the signature of a function, they can be any number, but they must have the same type? |
21:15:38 | FromGitter | <kayabaNerve> I'm guessing it's because you made SomeNumber the return type |
21:15:39 | FromGitter | <kayabaNerve> One sec |
21:18:28 | FromGitter | <kayabaNerve> Nope. They all have to be the same. |
21:18:33 | FromGitter | <kayabaNerve> Looks like a bug |
21:19:27 | FromGitter | <kayabaNerve> anamok: Here's a test I whipped up. https://gist.github.com/kayabaNerve/40cfdbf1b804b1ce68b8e53bb4b9a8df |
21:19:38 | * | Widdershins quit (Ping timeout: 245 seconds) |
21:19:50 | FromGitter | <kayabaNerve> I used Nim Playground for it. |
21:22:15 | * | Widdershins joined #nim |
21:23:28 | anamok | Thanks. But I don't think it's a bug. |
21:25:59 | FromGitter | <kayabaNerve> I don't think SomeNumber is meant to work like this :P |
21:26:19 | FromGitter | <kayabaNerve> But maybe *shrugs* |
21:37:19 | masterm | what is the idiomatic way to pass an instance of a struct to a C function that expects a pointer to said struct? |
21:37:29 | masterm | something like this doesn't seem to work: https://pastebin.com/yJ0ttXGd |
21:37:48 | masterm | I feel like I'm missing something |
21:52:11 | anamok | bye |
21:52:16 | * | anamok quit (Remote host closed the connection) |
21:52:32 | * | rockcavera joined #nim |
22:05:20 | masterm | ok, got it. one cannot take addr of immutable variable :) |
22:25:00 | FromGitter | <xmonader> how do i get reference to a proc in? |
22:26:37 | FromGitter | <kayabaNerve> var a: proc(a: int): int = myProc) |
22:27:34 | FromGitter | <xmonader> @kayabaNerve ⏎ it's more of this ⏎ ⏎ ```timeoutable(app.zosReachable)``` ⏎ ... [https://gitter.im/nim-lang/Nim?at=5bccfd56ae7be94016947c8a] |
22:27:57 | FromGitter | <xmonader> problem is app.zosReachable `calls` the proc not just a reference to the zosReachable method |
22:28:15 | * | elrood quit (Quit: Leaving) |
22:28:58 | FromGitter | <kayabaNerve> ... because you're passing it an argument. |
22:29:04 | FromGitter | <kayabaNerve> timeoutable(zosReachable) |
22:29:21 | FromGitter | <xmonader> @kayabaNerve it's a method on object `app` |
22:29:40 | FromGitter | <kayabaNerve> It's a method that takes in `app`. |
22:29:57 | FromGitter | <kayabaNerve> Nim doesn't have... class functions/nested functions/whatever. |
22:30:06 | FromGitter | <xmonader> i understand what you're saying due to ucfs .. |
22:30:11 | FromGitter | <kayabaNerve> app.zosReachable translates to zosReachable(app) |
22:31:26 | FromGitter | <kayabaNerve> ```proc createReachable(app: App): proc () = ⏎ proc () = ⏎ app.zosReachable()``` [https://gitter.im/nim-lang/Nim?at=5bccfe3def4afc4f28ae8dce] |
22:31:36 | FromGitter | <xmonader> yeah i changed it thanks :) |
22:31:44 | FromGitter | <kayabaNerve> Alrighty. Happy to help :P |
22:44:19 | FromDiscord | <smitop> i'm trying to use the opengl bindings |
22:44:28 | FromDiscord | <smitop> where do i put openglut.dll |
22:44:58 | FromDiscord | <smitop> putting it in the compilation directory doesn't work |
22:49:01 | FromGitter | <kayabaNerve> Then you have the wrong DLL |
22:52:38 | FromDiscord | <smitop> when i try to compile i get "could not load: (freeglut.dll|glut32.dll)" |
22:52:50 | FromDiscord | <smitop> But I have freeglut.dll in my source directoru |
22:54:14 | * | Sentreen quit (Remote host closed the connection) |
22:58:48 | FromGitter | <xmonader> can someone tell me what's wrong here? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bcd04a8ab17df2631cc5e6a] |
22:59:26 | FromGitter | <kayabaNerve> smitop: That doesn't mean it's the right DLL. It means that it has the same name. |
22:59:34 | FromGitter | <kayabaNerve> There's multiple architectures and versions. |
23:29:42 | * | smt` quit (Read error: Connection reset by peer) |
23:30:39 | * | seni quit (Ping timeout: 252 seconds) |
23:30:47 | * | seni joined #nim |
23:33:24 | * | smt joined #nim |
23:37:23 | * | seni quit (Quit: Leaving) |
23:53:02 | * | kapil____ quit (Quit: Connection closed for inactivity) |