<< 21-10-2018 >>

00:00:35FromGitter<alehander42> what do you mean "compile"
00:00:39FromGitter<alehander42> by "compile"
00:00:56FromGitter<zacharycarter> I think I know what he means
00:00:58FromGitter<yyyc514> compile(parseStmt(“””code””")) for example
00:01:16FromGitter<zacharycarter> you want to resolve the concrete syntax that calling the macro would produce?
00:01:30FromGitter<zacharycarter> I think I have a gist of this somewhere
00:01:41FromGitter<yyyc514> seems i should be able to write a compile macro if nothing else
00:01:45FromGitter<yyyc514> but i’m getting somethign wrogn
00:02:56FromGitter<yyyc514> ok passing the string itself work
00:03:03FromGitter<yyyc514> macro compile*(t: string) : untyped = return parseStmt(t.strVal)
00:03:27FromGitter<zacharycarter> I guess I don't understand :P
00:06:14FromGitter<yyyc514> ha cause everything inside the block becomes AST
00:06:20FromGitter<yyyc514> ok so the only way it can work is if you pass a string
00:06:26FromGitter<yyyc514> youc an’t do `compile(parseStmt(“""`
00:06:42FromGitter<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:45FromGitter<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:54FromGitter<yyyc514> :-/
00:59:06*vlad1777d_ quit (Ping timeout: 268 seconds)
01:07:12FromGitter<alehander42> honestly I am not sure if you need it at all
01:07:27FromGitter<yyyc514> doesn’t work without it
01:07:27FromGitter<alehander42> I mean the user writes e.g. `field` somewhere
01:07:44FromGitter<alehander42> and you generate an invocation of a method taking instance.field
01:07:54FromGitter<alehander42> the nim type system takes care of it
01:08:01FromGitter<alehander42> if there is not such a field, compile error
01:08:05FromGitter<yyyc514> i’m talking about the do syntax
01:08:12FromGitter<alehander42> give me an example
01:08:20FromGitter<yyyc514> `(form_for(paste, action = "/pastes/") do (f: FormForHelper[Paste]) -> string:`
01:08:30FromGitter<yyyc514> that’s crazy verbose
01:08:33FromGitter<alehander42> that's what I mean
01:08:57FromGitter<alehander42> honestly I don't think now you need a FormForHelper to know anything about Paste
01:09:26FromGitter<yyyc514> ok you might be right there, but how does that help
01:09:51FromGitter<yyyc514> it wants a “concrete type"
01:10:32FromGitter<yyyc514> i mean you are right since FormHelper is a templtae/generic anyways :)
01:10:41FromGitter<yyyc514> but i’m not yet sure i get how that lets us shorten it
01:11:18FromGitter<alehander42> honestly, do people really need `f`
01:11:23FromGitter<alehander42> I remember rails had a variant
01:11:25FromGitter<yyyc514> lol
01:11:30FromGitter<alehander42> where you directly write text_field
01:11:31FromGitter<alehander42> etc
01:11:37FromGitter<alehander42> I guess in more complicated forms
01:11:43FromGitter<alehander42> you can have more than one builder?
01:11:54FromGitter<yyyc514> maybe not, but it’s pretty nice :)
01:11:59FromGitter<alehander42> but isn't
01:12:05FromGitter<yyyc514> well the alternative is repeating the object everywhere
01:12:24FromGitter<yyyc514> well a macro can rewrite it but it has to have enough context to know what to rewrite :
01:12:41FromGitter<yyyc514> i have a nice macro for just emptry blocks already
01:12:44FromGitter<alehander42> ```form_for(paste, action="/pastes/"): ⏎ textField(body) ⏎ ..``` [https://gitter.im/nim-lang/Nim?at=5bcbd28bbbdc0b250573b59f]
01:12:51FromGitter<alehander42> even simpler
01:13:08FromGitter<alehander42> that's what I meant
01:13:11FromGitter<yyyc514> you can have subcontexts though
01:13:18FromGitter<yyyc514> nested fields
01:13:20FromGitter<alehander42> ah
01:13:31FromGitter<yyyc514> you might need top_level.name right next to option.name
01:13:38FromGitter<yyyc514> where optiion is a list of options
01:13:45FromGitter<yyyc514> options belongs_to top_level, etc
01:14:14FromGitter<yyyc514> <%= div() do %> some junk <% end %> works really nice already with a macro
01:14:25FromGitter<yyyc514> turns do into do -> string, etc :-)
01:14:32FromGitter<yyyc514> but that’s easy cause we don’t need a helper
01:15:43FromGitter<alehander42> so can't form-for be a macro
01:15:45FromGitter<alehander42> which just rewrites
01:15:48FromGitter<alehander42> form_for(paste, action="/pastes/") do (f):
01:16:00FromGitter<alehander42> to internal_form_for(...) do (f: FormBuilder) -> ..:
01:16:14FromGitter<yyyc514> it needs to know the type of Paste though
01:16:25FromGitter<alehander42> but that's my theory : does it
01:16:56FromGitter<alehander42> give me an example of a method
01:16:59FromGitter<yyyc514> so far all these are procs and the rewrite magic is macros
01:17:10FromGitter<alehander42> e.g. f.radio_button(paste.attr)
01:17:28FromGitter<yyyc514> you’d just have the name there not paste.attr
01:17:38FromGitter<alehander42> so f.radio_button(attr) ?
01:18:01FromGitter<yyyc514> yeah, but it’d have to be static, or else you need to compile a lookup table for runtime
01:18:08FromGitter<yyyc514> f.radio_button(“time_mode”)
01:18:19FromGitter<alehander42> and time_mode is a field of paste ?
01:18:23FromGitter<yyyc514> yes
01:18:33FromGitter<alehander42> then you just mechanicaly
01:18:39FromGitter<alehander42> generate paste.<name>
01:18:48FromGitter<alehander42> you don't need to know the fields for the rewrite
01:19:03FromGitter<alehander42> because the user already typed them
01:19:15FromGitter<yyyc514> but right now i need to know the Type
01:19:24FromGitter<alehander42> why?
01:19:57FromGitter<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:58FromGitter<yyyc514> and i want to use language features of nim when possible
01:21:25FromGitter<yyyc514> right now all the scoping and blocks and everything i get for “Free” with do
01:21:32FromGitter<yyyc514> if i have to rebuild that all with macros...
01:21:34FromGitter<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:50FromGitter<alehander42> and I get it for free with simpler logic
01:21:56FromGitter<alehander42> sometimes it's the opposite
01:22:00FromGitter<yyyc514> i guess i’d have to see a full example :)
01:22:01FromGitter<alehander42> of course
01:22:33FromGitter<yyyc514> it doesn’t have to be 100% pretty, i just need to see the whole thing conceptually
01:23:03FromGitter<yyyc514> are you talking about using macros to just inject the |f| as a var or something?
01:23:57FromGitter<alehander42> so you want custom helpers, like color_field time_field number_field etc ?
01:24:11FromGitter<alehander42> I am just not sure why do you need the macro to know the type
01:24:21FromGitter<alehander42> because I expect that the final code would be still
01:24:39FromGitter<yyyc514> IF i use the “do” syntax internaly it seems to need it
01:24:44FromGitter<alehander42> f.color_field(paste.attr)
01:24:57FromGitter<yyyc514> if you throw that out the window then you have to rebuild what do gives you
01:25:10FromGitter<alehander42> but if you use do
01:25:16FromGitter<alehander42> you can always generate
01:25:26FromGitter<alehander42> do (f: FormBuilder) -> string
01:25:48FromGitter<yyyc514> oh wait you’re sayign just lose the type of FormBuilder
01:25:52FromGitter<alehander42> or if it's very important ⏎ do (f: paste.type) -> string
01:25:55FromGitter<alehander42> (I think)
01:26:11FromGitter<alehander42> (maybe you need import typetraits for the last one)
01:26:19FromGitter<alehander42> f: FormBuilder[paste.type] *
01:26:26FromGitter<alehander42> but yeah I am not sure
01:26:30FromGitter<yyyc514> can that even work?
01:26:34*FromGitter * yyyc514 trying
01:26:39FromGitter<yyyc514> i’ already using typetraits :)
01:26:43FromGitter<alehander42> the second one not sure
01:27:15FromGitter<alehander42> but I am not sure that you need FormBuilder to know about InstanceType at all
01:27:40FromGitter<alehander42> it depends: do helpers often need other data about an instance except the field args
01:28:44FromGitter<yyyc514> not form helpers but i could imagine more complex stuff where it’d be useful
01:29:22FromGitter<yyyc514> ok paste is actually a ref
01:29:28FromGitter<yyyc514> how do i turn a ref type into a type type :)
01:31:26FromGitter<alehander42> not sure what you mean
01:31:35FromGitter<alehander42> the type of it should be available as paste.type
01:31:46FromGitter<yyyc514> ye but that is “ref Paste"
01:31:46FromGitter<alehander42> but not sure if it's directly usable in proc
01:31:48FromGitter<yyyc514> when we want Paste
01:31:51FromGitter<alehander42> aaaaah
01:32:07FromGitter<alehander42> well, you want the type of paste
01:32:16FromGitter<alehander42> if it's ref Paste indeed
01:32:21FromGitter<alehander42> let it be?
01:32:50FromGitter<alehander42> I am not sure how did it end up like that, is Paste = ref object ..
01:33:32FromGitter<alehander42> (otherwise I guess something like (paste[]).type)
01:33:40FromGitter<yyyc514> var paste = Paste()
01:33:48FromGitter<yyyc514> oh duh :) []
01:34:36FromGitter<yyyc514> whoa :)
01:34:53FromGitter<yyyc514> and that just works
01:35:13FromGitter<alehander42> does it
01:35:24FromGitter<yyyc514> yes :)
01:35:34FromGitter<yyyc514> `(form_for(paste, action = "/pastes/") do (f: FormForHelper[paste[].type]) -> string:`
01:35:35FromGitter<alehander42> nice
01:35:51FromGitter<yyyc514> should it not be a ref? that’s just what Paste() is giving me
01:35:58FromGitter<yyyc514> so i just ran with it
01:36:06FromGitter<alehander42> well, I'd just use paste.type
01:36:24FromGitter<alehander42> some objects might be ref, some not (I guess)
01:36:42FromGitter<alehander42> so now one can
01:36:42FromGitter<yyyc514> my new() returns Paste type
01:37:01FromGitter<alehander42> usually you don't need new()
01:37:14FromGitter<alehander42> almost always people just do a = A()
01:37:20FromGitter<yyyc514> oh i wrote my own that just makes a new paste now the new that allocs
01:37:23FromGitter<yyyc514> might want to rename it
01:37:27FromGitter<yyyc514> yeah that’s what new does :)
01:37:45FromGitter<yyyc514> it has a DateTime which evidentaly can’t be empty
01:37:49FromGitter<alehander42> yeah please rename it, as new is usually different
01:37:49FromGitter<yyyc514> so Paste() is actually a no go
01:38:07FromGitter<yyyc514> i’d use newPaste() but i thought Paste.new() was prettier :)
01:38:25FromGitter<yyyc514> or is that why i have a ref? some wierd interaction there?
01:39:01FromGitter<yyyc514> lol
01:39:02FromGitter<yyyc514> yep
01:39:07FromGitter<yyyc514> cause i never exported my new ROFL
01:39:40FromGitter<alehander42> haha probably
01:39:54FromGitter<yyyc514> i still need to figure out the point
01:39:56FromGitter<alehander42> but maybe use init
01:40:00FromGitter<yyyc514> aren’t objects already by reference?
01:40:05FromGitter<alehander42> it's more nim-ish
01:40:33FromGitter<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:39FromGitter<alehander42> if A is object
01:40:48FromGitter<alehander42> a = A(..) : a is object too
01:40:51FromGitter<alehander42> if A is ref object
01:40:55FromGitter<alehander42> a = A(..) is ref object too
01:41:02FromGitter<alehander42> if you do a = new A(..)
01:41:07FromGitter<alehander42> I think it will be a ref ref object
01:41:20FromGitter<alehander42> (I guess it will allocate a ref to the val)
01:41:26FromGitter<yyyc514> going to go read: https://forum.nim-lang.org/t/1207
01:42:29FromGitter<alehander42> good idea
01:42:37FromGitter<alehander42> ok, I am going to bed as it's 4 am here
01:42:43FromGitter<yyyc514> night
01:42:47FromGitter<alehander42> good luck
01:42:51FromGitter<yyyc514> afaik it seems to be largly about stack vs heap
01:42:57FromGitter<yyyc514> refs are dynamicly allocated
01:43:45FromGitter<yyyc514> "The primary between a plain object and a reference is that assignment makes a copy of the original object. "
01:43:59FromGitter<alehander42> yeah, ref is basically a gced pointer
01:46:33*darithorn joined #nim
01:51:30FromGitter<yyyc514> yeah
01:51:43FromGitter<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:56FromGitter<yyyc514> hmmm doe embedsrc literally supposed to put nim code beside the C?
02:05:58FromGitter<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:15FromGitter<mratsim> Is there a IRC/Gitter split?
06:59:34narimirani see your comment here
07:00:10FromGitter<mratsim> cool
07:00:18*stefanos82_ joined #nim
07:00:33*stefanos82 quit (Ping timeout: 252 seconds)
07:00:41FromGitter<kayabaNerve> @mratsim I see your comment
07:00:49*stefanos82_ quit (Client Quit)
07:00:55FromGitter<kayabaNerve> #Helping
07:15:22*nsf quit (Quit: WeeChat 2.2)
07:32:16*stefanos82 joined #nim
07:45:12FromGitter<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:25TheLemonMan"fixed array of runtime size" ? it's either fixed-sized or growable at runtime...
07:54:05FromGitter<tim-st> if the size is determined at runtime of course it can be fixed size
07:55:04TheLemonManoh, so a non-growable vector. There's the rtarray module for that
07:55:22FromDiscord<exelotl> like `int arr[x];` in C where x is some variable. The array will still be allocated on the stack
07:55:53FromGitter<tim-st> yes, I meant that type, I think the problem is that's not supported in c++ only in c99
07:56:08FromGitter<tim-st> https://en.wikipedia.org/wiki/Variable-length_array
07:56:14TheLemonManusing VLAs that way is a horrible practice
07:56:33FromGitter<tim-st> I read it's up to 5 times quicker than vector
07:57:51TheLemonManthat's because you just bump the SP in order to allocate them
07:58:28FromGitter<tim-st> ok, so it's not a candidate for nim?
07:59:39TheLemonManhttps://wiki.sei.cmu.edu/confluence/display/c/MEM05-C.+Avoid+large+stack+allocations
08:00:27FromGitter<tim-st> yes, that's a good point with "controlled by attacker"
08:00:39TheLemonManI guess it's not (you can still wrap alloca & use it but beware it may break in unexpected ways)
08:01:06FromGitter<tim-st> ok, thanks
08:01:28FromGitter<tim-st> isn't that type is used by java all the time^^
08:01:56TheLemonManjava runs on a VM so no ?
08:02:08FromGitter<tim-st> oh, no they dont, it's to long ago I used java :\
08:03:06AraqC99 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:33FromGitter<tim-st> ok^^
08:03:57Araqsure, let's add complex numbers to C, but still offer no sane way to detect integer overflows
08:04:20Araqcriminals at work.
08:05:26Araqand afterwards they added a threading model, incompatible with Posix's while still not offering a sane way to detect integer overflows...
08:06:31Araqoh and overloading is so bad, so we will add it, but based on some preprocessor magic, incompatible with C++'s model
08:06:47TheLemonManyou must really like integer overflows
08:07:40TheLemonManis it? I thought _Generic was handled by the compiler and not by the preprocessor
08:07:53AraqI enjoy detecting them until the hardware devs embrace my sticky saturated integer arithmetic (patent pending...)
08:09:17AraqTheLemonMan: I probably misremember
08:09:17TheLemonMan"sticky saturated" -> that's almost as bad as silent wraparounds :)
08:09:45Araqno, you can compute for a while and if it's +/-Inf you know you screwed up :-)
08:10:20Araqand alloc(Inf) fails so you don't get heap corruptions
08:11:58TheLemonManit's so crazy it may even work heh
08:13:08AraqI analyzed plenty of programs, it's the best way to do it, especially if hardware assisted exception handling is off the table
08:13:49Araqand since proving at compile-time that overflows cannot happen seems unfeasible for most programs out there
08:14:15Araqbbl
08:18:21FromGitter<mratsim> @tim-st bad idea, you might overwrite your return stack
08:18:55FromGitter<mratsim> But if you feel adventurous, here you go: https://github.com/status-im/nim-ranges/blob/master/ranges/stackarrays.nim
08:19:00TheLemonManthat's a good idea if you write your program as a huuge ROP chain :)
08:19:55FromGitter<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:18FromGitter<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:48TheLemonManiirc SmallVector behaves like RtArray does
08:23:19FromGitter<mratsim> rtarrays have no doc :P
08:25:56FromGitter<mratsim> actually there are not implemented: https://github.com/nim-lang/Nim/blob/devel/lib/pure/collections/rtarrays.nim
08:27:14TheLemonManthe api is quite...minimal? but the functionality is there
08:27:28FromGitter<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:31TheLemonManallocate with initRtArray and get a pointer with getRawData
08:28:43TheLemonManheh I was wondering what `laser` was
08:29:15FromGitter<mratsim> An experiment at creating the fastest and flashiest tensor backend ever :P
08:29:39FromGitter<mratsim> Have to compare with the stuff done by Halide-lang but I’m sure I compile much faster than it :P
08:30:22FromGitter<mratsim> For now, there is runtime cpu capabilities detection, the dynamic stack arrays, and variadic parallel strided loops
08:30:36TheLemonManthe use of TRM is also pretty nice
08:31:25FromGitter<mratsim> OpenMP templates with tuning including chunk processing.
08:31:54FromGitter<mratsim> so I can use copyMem on parallel chunks for example
08:35:13TheLemonManI just got my libclang-based bindings generator to build bindings for libclang :D
08:35:39TheLemonManbootstrap acheived!
08:35:59FromGitter<mratsim> we’re not far from the singularity :P
08:44:06FromGitter<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:19FromGitter<mratsim> only need 6D
08:44:49FromGitter<Vindaar> ah, then I misremembered
08:45:00FromGitter<mratsim> batch_size, time, color, depth, height, width
08:45:17FromGitter<mratsim> and that’s for 3D videos ;)
08:45:25FromGitter<Vindaar> hehe, makes sense, yeah
08:45:27FromGitter<mratsim> a stack of 3D videos even
08:46:13FromGitter<mratsim> limiting to 6 dimensions allows me to keep a complete tensor metadata in 2 cache lines.
08:47:08FromGitter<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:02FromGitter<mratsim> 33% improvement :P
08:48:14FromGitter<Vindaar> :P
08:48:30FromGitter<Vindaar> I guess it's not /that/ easy, is it?
08:49:13FromGitter<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:46FromGitter<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:08FromGitter<mratsim> strided meaning [0, 0, 1] isn’t just after [0, 0, 0] in memory
08:52:13FromGitter<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:42FromGitter<mratsim> if we assume the cost of loading from a cache at 100 cycles
08:53:18FromGitter<mratsim> and that cost is just for loading data. Compared to that, floating point addition takes 1 cycle
08:53:35FromGitter<mratsim> i.e. I could add 300 more numbers in the time I wait for data
08:54:26FromGitter<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:49FromGitter<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:54narimiran"mhm, yeah yeah, i know some of these words"
08:57:58*tdc quit (Ping timeout: 245 seconds)
08:58:02FromGitter<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:15FromGitter<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:28FromGitter<Vindaar> where do the additional specific latencies in ns come from? is that based on a specific clock speed?
09:05:05FromGitter<mratsim> it’s based on the number of channels in your RAM and it’s clock speed yes (like 2100Mhz, 2666Mhz …)
09:05:31FromGitter<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:16planetis[m]hey, does anyone have a hierarchical fsm example for spare? I m writing a fsm macro and could use an example
10:54:20FromGitter<tekjar> Has anyone tried using nim on nuttx rtos?
10:54:35FromGitter<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:54FromDiscord<hotdog> @planetis I would be interested in seeing what you create, please ping me if you put it online
11:54:09FromDiscord<hotdog> A nice hfsm dsl is on my to-do list
11:59:15*narimiran quit (Quit: Konversation terminated!)
12:01:16planetis[m]its more like a toy
12:01:40planetis[m]it uses the state pattern to write a procedural fsm
12:02:03planetis[m]thus doesn't support state variables
12:02:14planetis[m]sure i will upload it soon
12:14:22planetis[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:40FromGitter<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:27FromDiscord<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:19planetis[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:05planetis[m]anyway tough luck I guess, here it is https://github.com/b3liever/macromachining I hope you like it
13:39:39planetis[m]but probably doesn't do what hfsm should I havent tested it.
13:58:40planetis[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:04FromGitter<xmonader> guys how can i encode `binary data` using base64 encode ?
14:19:56FromGitter<tim-st> is it possible to add an url to a git repo as dependency of a nimble package?
14:20:11FromGitter<tim-st> (which is itself a nimble package)
14:22:31FromGitter<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:16FromGitter<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:29copygirlMhh.. two questions, guys.
14:52:04copygirlFirst of all, apologies for essentially asking you to do my work as a programmer for me.
14:52:54copygirlI 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:33copygirlSo if I create an `either("string", int)` or an `either(5, string)` it would turn out the same.. or so.
14:54:17leorizequite simple actually
14:54:27leorizemake an `Either[T, U]`
14:54:38copygirlI 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:44leorizeand a template `either` to put the stuff in the correct order
14:55:05copygirlOr a template. But.. how?
14:55:07FromGitter<alehander42> `type T` I think
14:55:42FromGitter<alehander42> e.g. eitherT, U (a: T, b: type U): Either[T, U]
14:55:46FromGitter<alehander42> `e.g. eitherT, U (a: T, b: type U): Either[T, U]`
14:57:17copygirlYeah but then `either("string", int)` is an incompatible type with `either(t, string)`.
14:57:28copygirl(`t` was meant to be `5`)
14:58:37copygirlI probably still don't know the proper powers of templates as well..
14:58:42FromGitter<alehander42> ahh
14:58:43FromGitter<alehander42> I see
14:58:57FromGitter<alehander42> basically you want Either[T, U] to be equivalent to Either[U, T]
14:59:34copygirlOr the method creating an either to always return the same type, perhaps.
14:59:55copygirlIf you give it the same types, regardless of order.
15:00:02leorizeor make a `converter`?
15:00:35FromGitter<alehander42> crafty, a converter might be the simplest solution
15:00:36copygirlI think that's just going to cause weirdnesses.
15:00:50leorizewhy?
15:02:48copygirlWell I'd have to write a bunch of converters first of all. Imagine an Either[T0, T1, T2, T3].
15:03:45leorizeare you gonna use that kind of `Either`?
15:04:27copygirlYes. I'm writing a json schema validator and converter that is supposed to allow properties of various possible types.
15:05:20copygirlAnd it can be more than just `string or int or bool`, but `string or SomeObj or SomeElement[] or ...`
15:07:26leorizehmmmm
15:07:39leorizewrite a macro that generates a bunch of converters? :P
15:08:19copygirlBut then I could also just write a macro that sorts the types.
15:08:50leorizedo you have a good idea on how to sort them?
15:11:15copygirlNot sure if default HashSet iterator would always sort them the same.
15:12:20copygirlOnly 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:34copygirla way*
15:13:01leorizeoverload the `[]` operator then?
15:13:37leorizethe only problem is that typedesc is a compile time value...
15:17:05leorizehow 'bout a `[]` macro?
15:17:38leorizeit could easily traverse the type tree to retrieve the correct variable
15:17:50leorizeor "field"
15:18:02copygirlYeah I'm doing either[string] to get the string of that either variable, for example.
15:30:36leorizecopygirl: https://ptpb.pw/z4fK
15:30:58leorizethat's my small template contraption
15:32:54copygirlMhh maybe I can work it..
15:33:58copygirlThe 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:19copygirlAnd I need to generate code that sets it depending on the incoming type.
15:34:38copygirlOr.. wait. Hm.
15:34:49copygirlMaybe it *doesn't* matter.
15:36:27copygirlThough 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:46leorizemacros all the way
15:37:50copygirlI just wonder if I can use `quote` for that.
15:38:11dom96tim-st: a little bit, yes.
15:38:41copygirlBecause 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:17leorizesure, 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:04FromDiscord<hotdog> @planetis just had a look, I like it
16:21:25FromDiscord<hotdog> I recognise the miner example, is that from game programming patterns?
16:21:49planetis[m]thank you :)
16:21:56FromGitter<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:11planetis[m]no from Programming game ai by example
16:23:12planetis[m]It pbl doesn't work correctly since I am just getting to understand fsm's
16:23:14planetis[m]and its also hard-coded
16:25:54*wildlander quit (Quit: Konversation terminated!)
16:29:16FromDiscord<hotdog> Ah yeah I knew I recognised it from somewhere
16:29:38*tdc quit (Ping timeout: 245 seconds)
16:30:52FromDiscord<hotdog> I think the best way to understand fsms would just be to use it in a real project
16:31:10FromDiscord<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:15FromDiscord<Jérôme> Hello, how are you ? :)
17:40:15FromDiscord<Jérôme>
17:40:15FromDiscord<Jérôme> I want your opinion on whether this is possible or not.
17:40:16FromDiscord<Jérôme>
17:40:16FromDiscord<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:16FromDiscord<Jérôme>
17:40:18FromDiscord<Jérôme> I want to know if I can do my project with KARAX?
17:40:20FromDiscord<Jérôme> Can I also add SQLite or PostgreSQL with KARAX?
17:40:21FromDiscord<Jérôme>
17:40:22FromDiscord<Jérôme> Thank you
17:44:41dom96You can do anything with Karax
17:44:52dom96mech422__: hard to say without seeing code
17:47:39dom96that's inheritance
17:47:51dom96you're declaring an object that inherits from RootObj
17:48:52dom96it's a keyword
17:48:57dom96it's a type of kind
17:49:35FromDiscord<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:28dom96Jérôme: The Nim forum is written in Karax and it uses SQLite
17:52:27dom96You're defining an `object`
17:52:30dom96That's why it's there
17:52:52FromDiscord<Jérôme> @gitterirc Super I go then, thank you for you is the return
17:53:19FromDiscord<Jérôme> ok i take note of you is advice
17:53:37FromDiscord<Jérôme> 🙂 😃
17:54:38dom96Here is NimForum's source code: https://github.com/nim-lang/nimforum
17:56:06dom96You should read " Foo = ref object of RootObj" as "Foo is a reference object that inherits from RootObj"
17:57:39FromDiscord<Jérôme> Good thank you very much, one last question that has nothing to do with my project.
17:57:39FromDiscord<Jérôme>
17:57:39FromDiscord<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:36FromGitter<alehander42> you still need a server lib probably, karax is a SPA
18:00:27FromDiscord<Jérôme> Sorry my english is not ready yet
18:00:34FromDiscord<Jérôme> 🙂
18:20:29*PMunch joined #nim
18:33:47FromGitter<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:53FromDiscord<Jérôme> @gitterirc Yes, HTML, CSS, JS and a can Python
18:57:55FromDiscord<Jérôme> 😃
19:02:09*PMunch quit (Remote host closed the connection)
19:13:50FromGitter<tim-st> is there a way to give two different variants in a object variant the same field name?
19:14:00FromGitter<tim-st> is it a bug or a feature?
19:20:09*tdc joined #nim
19:35:41*kapil____ joined #nim
19:39:14FromGitter<alehander42> @Jérôme ok, so nim + karax is the equivalent of typical html + JS
19:39:44FromGitter<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:45anamokhi
20:19:34anamokNim 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:17FromDiscord<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:57anamokWhat's the difference between Number and SomeNumber?
20:31:02FromGitter<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:49FromGitter<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:14anamokmy bad, there is really no Number
20:37:12anamokIf 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:32FromGitter<kayabaNerve> anamok: I have a guess
21:12:41FromGitter<kayabaNerve> It's hooking into the generic system
21:12:46FromGitter<kayabaNerve> SN1 == SN2 == SN3
21:12:54FromGitter<kayabaNerve> But your SN1 != SN2
21:12:59FromGitter<kayabaNerve> So it doesn't know what to return
21:13:43*elrood joined #nim
21:14:57anamokSo 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:38FromGitter<kayabaNerve> I'm guessing it's because you made SomeNumber the return type
21:15:39FromGitter<kayabaNerve> One sec
21:18:28FromGitter<kayabaNerve> Nope. They all have to be the same.
21:18:33FromGitter<kayabaNerve> Looks like a bug
21:19:27FromGitter<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:50FromGitter<kayabaNerve> I used Nim Playground for it.
21:22:15*Widdershins joined #nim
21:23:28anamokThanks. But I don't think it's a bug.
21:25:59FromGitter<kayabaNerve> I don't think SomeNumber is meant to work like this :P
21:26:19FromGitter<kayabaNerve> But maybe *shrugs*
21:37:19mastermwhat is the idiomatic way to pass an instance of a struct to a C function that expects a pointer to said struct?
21:37:29mastermsomething like this doesn't seem to work: https://pastebin.com/yJ0ttXGd
21:37:48mastermI feel like I'm missing something
21:52:11anamokbye
21:52:16*anamok quit (Remote host closed the connection)
21:52:32*rockcavera joined #nim
22:05:20mastermok, got it. one cannot take addr of immutable variable :)
22:25:00FromGitter<xmonader> how do i get reference to a proc in?
22:26:37FromGitter<kayabaNerve> var a: proc(a: int): int = myProc)
22:27:34FromGitter<xmonader> @kayabaNerve ⏎ it's more of this ⏎ ⏎ ```timeoutable(app.zosReachable)``` ⏎ ... [https://gitter.im/nim-lang/Nim?at=5bccfd56ae7be94016947c8a]
22:27:57FromGitter<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:58FromGitter<kayabaNerve> ... because you're passing it an argument.
22:29:04FromGitter<kayabaNerve> timeoutable(zosReachable)
22:29:21FromGitter<xmonader> @kayabaNerve it's a method on object `app`
22:29:40FromGitter<kayabaNerve> It's a method that takes in `app`.
22:29:57FromGitter<kayabaNerve> Nim doesn't have... class functions/nested functions/whatever.
22:30:06FromGitter<xmonader> i understand what you're saying due to ucfs ..
22:30:11FromGitter<kayabaNerve> app.zosReachable translates to zosReachable(app)
22:31:26FromGitter<kayabaNerve> ```proc createReachable(app: App): proc () = ⏎ proc () = ⏎ app.zosReachable()``` [https://gitter.im/nim-lang/Nim?at=5bccfe3def4afc4f28ae8dce]
22:31:36FromGitter<xmonader> yeah i changed it thanks :)
22:31:44FromGitter<kayabaNerve> Alrighty. Happy to help :P
22:44:19FromDiscord<smitop> i'm trying to use the opengl bindings
22:44:28FromDiscord<smitop> where do i put openglut.dll
22:44:58FromDiscord<smitop> putting it in the compilation directory doesn't work
22:49:01FromGitter<kayabaNerve> Then you have the wrong DLL
22:52:38FromDiscord<smitop> when i try to compile i get "could not load: (freeglut.dll|glut32.dll)"
22:52:50FromDiscord<smitop> But I have freeglut.dll in my source directoru
22:54:14*Sentreen quit (Remote host closed the connection)
22:58:48FromGitter<xmonader> can someone tell me what's wrong here? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bcd04a8ab17df2631cc5e6a]
22:59:26FromGitter<kayabaNerve> smitop: That doesn't mean it's the right DLL. It means that it has the same name.
22:59:34FromGitter<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)