<< 24-02-2017 >>

00:03:01cheatfatejabb, var bar = addr(foo)
00:03:13jabbthat creates something i have to dereference
00:03:14*ftsf joined #nim
00:04:11cheatfatejabb, https://nim-lang.org/docs/manual.html#overloading-resolution-automatic-dereferencing
00:04:55jabbyes, but for a basic type i just want the value of
00:05:01jabbor change
00:05:13jabbi'd have to do bar[] = new_value
00:05:22jabbusing addr
00:06:37cheatfateyou don't need to dereference it
00:07:06cheatfatejust make bar = new_value
00:07:33jabbhttp://ideone.com/2ONGKZ (prog.nim(7, 7) Error: type mismatch: got (int literal(10)) but expected 'ptr int')
00:08:10cheatfatehmm
00:09:23jabb:P
00:11:57cheatfatethen maybe you need to dereference it by yourself
00:12:15jabb:/
00:12:36jabbthe feature exists in procs, seems like an inconsistency to me
00:13:14jabbproc baz(x: var int) = ... behaves as expected, basically a "int &", instead of an "int *"
00:13:28jabbbut outside procs, no "int &"s?
00:13:59*handlex joined #nim
00:15:12Araqyes, that's exactly right
00:15:26jabb?
00:15:43Araqand the inconsistency exists for memory safety reasons, look at C# if you don't believe me
00:16:16Araq"but outside of procs, no int &s"? yes, that's exactly right
00:17:37zachcartersorry Varriount - had to run for a bit - it does handle it but for some reason my bgfx backend isn’t binding the right texture for the right draw call
00:26:14*PMunch quit (Quit: leaving)
00:29:01*Matthias247 quit (Read error: Connection reset by peer)
00:40:03*handlex quit (Quit: handlex)
00:41:24*yglukhov joined #nim
00:45:45*yglukhov quit (Ping timeout: 240 seconds)
01:10:56*Jesin joined #nim
01:14:39*surge-protect quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
01:18:35*surge-protect joined #nim
01:35:02*zachcarter quit (Ping timeout: 240 seconds)
01:38:40jabbhmm
01:38:50jabbp: pointer, is like a void pointer?
01:38:58jabbbut p: ptr int is an int pointer?
01:43:31*yglukhov joined #nim
01:45:15cheatfatejabb, yep
01:46:34*handlex joined #nim
01:48:00jabbcheatfate: there are quite a few ways to make a pointer lol
01:48:08jabbwhy so many keywords?
01:48:09*yglukhov quit (Ping timeout: 260 seconds)
01:48:57jabbptr, addr(), ref, pointer, var (as parameter)
01:49:25jabbx.addr
01:49:37cheatfatex.addr = addr(x) = addr x
01:49:51jabbwhy so many ways to do the same thing? lol
01:49:56jabbohhh
01:50:00jabbbecause it's a function
01:50:25cheatfatei'm not a creator of language... i don't know reasons
01:50:26jabbokay, still: ptr, addr, ref, pointer, var can all create reference/pointer
01:50:49cheatfateptr is for non GC memory
01:50:52cheatfateref for GC memory
01:51:06cheatfatepointer don't care about GC/nonGC
01:51:29cheatfatevar notation for procedures arguments return values only
01:51:42jabbcan also use var in return
01:52:01cheatfate^^^ arguments & return values only
02:00:28jabbnim's philosophy regarding unsigned is no. what about network or low level bit streams?
02:08:10cheatfatenim has unsigned, its not so restrictive as java
02:10:20FromGitter<Varriount> Nim's take on unsigned (or rather, Araq's) is "unsigned should only be used when strictly necessary"
02:11:28*shashlick quit (Ping timeout: 240 seconds)
02:13:17*shashlick joined #nim
02:30:54*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
02:50:02*chemist69 quit (Ping timeout: 240 seconds)
03:04:21*chemist69 joined #nim
03:30:38*handlex quit (Quit: handlex)
03:33:06*zachcarter joined #nim
03:35:32*zachcarter quit (Read error: Connection reset by peer)
03:35:52*zachcarter joined #nim
03:45:25*yglukhov joined #nim
03:49:44*yglukhov quit (Ping timeout: 240 seconds)
03:50:19zachcarterI could use some help. I have a type defined as :
03:50:29zachcarter nk_handle* = object {.union.}
03:50:29zachcarter `ptr`*: pointer
03:50:30zachcarter id*: cint
03:51:06zachcarterI’m trying to check when the object pointed to by `ptr` is not initialized
03:51:19zachcarterI can do a check like :
03:51:44zachcarterif not handle.`ptr`.isNil:
03:52:26zachcarterbut if I try to derference `ptr` and then repr the object or do any sort of comparison on it or anything, I get a segfault
03:59:27*Nobabs27 quit (Quit: Leaving)
04:06:30*rauss joined #nim
04:27:00FromGitter<Varriount> zachcarter: Could you rename the member? 'ptr' is already a builtin typeclass, which might cause some problems.
05:10:05*zachcarter quit (Quit: zachcarter)
05:18:30*yglukhov joined #nim
05:22:44*yglukhov quit (Ping timeout: 240 seconds)
05:41:01jabbwhat are threading options and shared state among threads?
05:41:11jabbis it just mutexes?
05:42:08jabbwait, data can't be shared across threads?
06:05:24*zachcarter joined #nim
06:07:15FromGitter<Varriount> Jabb: The default garbage collector uses a per-thread heap
06:09:23FromGitter<Varriount> You can use channels, the parallel and spawn mechanisms, or unsafe pointer passing.
06:20:51jabbapparently its slow?
06:27:14FromGitter<Varriount> Slow is relative.
06:28:23FromGitter<Varriount> Jabb: What's your use case?
06:40:33jabbhigh performant database
06:46:22*gokr joined #nim
06:52:02*nsf joined #nim
06:54:07*gokr left #nim (#nim)
06:59:39*libman joined #nim
07:05:40*zachcarter quit (Quit: zachcarter)
07:07:19*yglukhov joined #nim
07:10:00*yglukhov quit (Read error: Connection reset by peer)
07:10:30*yglukhov joined #nim
07:23:04jabbVarriount, too slow for that?
07:27:16*bjz joined #nim
07:48:48*filcuc joined #nim
07:51:39*rokups joined #nim
07:53:53*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
07:57:30*sdw joined #nim
07:58:20*bjz joined #nim
07:58:58*rauss quit (Quit: WeeChat 1.7)
08:01:44*chemist69 quit (Ping timeout: 255 seconds)
08:05:55*Arrrr joined #nim
08:05:55*Arrrr quit (Changing host)
08:05:55*Arrrr joined #nim
08:06:19*chemist69 joined #nim
08:15:40*Vladar joined #nim
08:17:40*Andris_zbx joined #nim
08:18:03FromGitter<Varriount> Jabb: Are you connecting to a database, or building one?
08:25:09rokupsAraq: is there any good reason why variables in generated c code do not contain original names? for instance "NimStringDesc* T1_; T1_ = (NimStringDesc*)0; T1_ = foo_RdSvqy2gdVZp9a5p9cZtZqDg(((NimStringDesc*) &TM_V45tF8B8NBcxFcjfe7lhBw_2), ((NimStringDesc*) &TM_V45tF8B8NBcxFcjfe7lhBw_3)); printf("%s\012", T1_? (T1_)->data:"nil");" has weird "T1_" and "TM_*"
08:25:10rokupsvariable names. having original variable name as prefix for mangled one would be really helpful for debugger support.
08:25:54Araqthese are compiler generated temps
08:26:20Araqthere is no Nim name we could use for them, real Nim vars have their original name as a prefix
08:26:31Araqand locals are often not mangled at all
08:27:10Araqbesides, with --debuggger:native in nimcache there are .ndi files which have the mapping from Nim to C names
08:28:15rokupshmm okay, but then it seems that -d:debug is doing some kind of optimizations and what not since its not 1:1 mapping to written code
08:28:43*bjz_ joined #nim
08:29:51Araqsure and GCC's debug code also uses stack slots that are not in my C code ...
08:30:10*bjz quit (Ping timeout: 268 seconds)
08:30:51rokupsalso this: https://i.imgur.com/lxCvYfj
08:31:33rokupsnot really sure whats going on here, seems some kind of variable mapping is going on but.. maybe debugger support needs to do some nim-specific sutff?
08:31:58AraqNim's #line generation is a bit weird at times
08:32:02Araqfor instance
08:32:11Araqvar x = "foo"
08:32:21Araqtranslates to
08:32:28Araqtmp = "foo"
08:32:32Araqx = tmp
08:32:47Araq(well more complex than that but you get the idea)
08:33:17Araqso only the last step corresponds to a Nim source line but we emit the #line before the tmp assignment
08:34:01Araqbut then that's what GCC does too, a C statement can produce more than 1 asm instruction...
08:34:27FromGitter<Varriount> If your connecting to a database, you're likely using a worker model, where each worker grabs
08:35:19rokupsheh well im not even sure what could be done to improve this, but it definitely needs some love
08:35:57rokupsvs code nim/debugging support is pretty good already. was surprised to find that out yesterday. and i was one of those vs code naysayers
08:36:45jabbVarriount, building
08:37:32*surge-protect quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
08:38:03jabbimplementing
08:38:21rokupsAraq: if you got time you could introduce me about to required codegen changes to allow overriding cpp virtual methods. now that coroutines are done (for now) i think maybe i could try tackle this one.
08:38:36libmanI was ***SO*** close to making an intelligent and useful Nim forum post for once...
08:39:29Araqrokups: what about the memory usages? you said -d:nimCoroutines increases booting mem usage by a whole lot?
08:39:36libmanI typed up http://pastebin.com/raw/nTyKq9K4 ... I was ready to post. I hit preview, and I saw that... Araq came and beat me to it by a few minutes...
08:40:16rokupsAraq: i was telling you about how booting got fixed, that bug was middle step :p its fixed ofc, it boots nicely with usual 300-ish mem usage :p
08:40:31rokupsgc tests passing as well
08:40:52Araqlibman: yeah but you used a profiler and/or timing tools.
08:41:01AraqI only skimmed the code :P
08:41:18Araqyour post adds some new information, please submit it
08:43:16chemist69rokups: how do you setup nim debugging in VS code?
08:43:58rokupschemist69: i installed microsoft cpp tools and native debug extension. native debug extension allows setting breakpoints in nim code, then can use either of them to debug nim
08:44:13rokupsit seems that microsoft's cpp debugger is better
08:44:41chemist69ok, thanks.
08:46:16rokupsend result with microsoft's debugger https://i.imgur.com/2d7o1S5
08:46:39rokupsthat other screenshot was from native debug extension.
08:47:26chemist69nice.
08:51:28libmanAny verdict on the suggestion of adding OS package manager info to the download page? https://forum.nim-lang.org/t/2813
08:54:44euantorPSA in case anybody has missed it: https://blog.cloudflare.com/incident-report-on-memory-leak-caused-by-cloudflare-parser-bug/
08:54:46*evacchi joined #nim
08:55:08euantorChange your passwords on any site using CloudFlare (including DigitalOcean, which I know @dom96 uses to host Nim sites)
08:55:59evacchihi all. I was wondering how hard would it be to make coroutines in coro work on a pool of threads
08:56:28evacchias far as I understand, it looks like using shared data structures for temp storage might be enough
08:56:37euantorAnd here's a (incomplete) list of sites using CloudFlare: https://github.com/pirate/sites-using-cloudflare
08:57:02evacchi(I was thinking fibers, actors, etc.)
08:59:14*butchster quit (Ping timeout: 240 seconds)
09:09:45*ftsf quit (Quit: :q!)
09:12:02ArrrrI don't think i have an account in any single one of those webpages
09:12:55Araqlibman: if you promise to maintain it, I'm willing to add it
09:13:35libmanOK, I'll whip up some HTML tomorrow.
09:13:39Araqthough in general I am not a fan of telling people "use this modified outdated Nim version *tied* to your OS"
09:14:50Araqand I think Linux package management is stupid and a hack on top of a file hierarchy that is a hillarious fundamentally broken design
09:15:17libmanDo distros really make bad modifications?
09:15:30*Vladar quit (Remote host closed the connection)
09:16:06rokupsthey probably do not in this case. but as language is still not 1.0 i would prefer seeing simple shellscript that provides latest compiler instead.
09:16:24rokupsbecause honestly - if person is looking for compiler he sure as hell can compile it
09:16:42rokupsits more troublesome on windows though, but its different story
09:17:56libmanI'm neutral on whether the download page encourages building from source instead of pkgs, I just thought it would be useful info to have on the download page.
09:18:16*evacchi quit (Ping timeout: 268 seconds)
09:18:39euantorI really like Rust's approach - point everybody to a single shell/batch script that can maintain versions and do automatic updates (in their case, rustup)
09:21:45*evacchi joined #nim
09:21:59evacchiso, I'm pretty new to Nim, and I wanted to try and write a minimal actor library as an exercise. So I played around with "shared" data structures (as you called them) such as the "sharedtable" module. I was able to make work a simple proof of concept which (at the end of the day) does the same as the "tasking" example with iterators
09:22:07evacchithen I stumbled upon the coro module, which I assume is still expected to schedule coroutines on a single thread (is that right?)
09:22:12evacchiso I was wondering how much work would it be to resume coroutines on a different thread
09:23:04rokupsevacchi: i do not think that is doable at all due thread-local heaps nim uses. resuming coroutine on another thread would wreck havoc in gc
09:23:28evacchihuh, that's what I feared
09:24:11rokupswith some work you could whip up support to do this for gcsafe coroutines, but that does not sound too useful in general..
09:24:25rokupsbut is there really a need for this?
09:24:25*krux02 joined #nim
09:24:55AraqErlang uses task local heaps and it works out quite well
09:24:57rokupsyou can have multiple threads running multiple coroutine loops and schedule your coroutines on whichever thread runs least amount of coroutines or something
09:24:58*couven92 joined #nim
09:25:15Araqwe use thread local heaps though, but maybe we can make them task local
09:25:40Araqrokups showed us how to transform thread local vars to task local vars :-)
09:25:41krux02what's the difference between thread and task?
09:25:50krux02I know thread and process
09:25:57rokupshmm i am not so sure its a good idea
09:26:04Araqthere task == coroutine
09:26:47krux02so that thing that is called goroutine in go
09:27:07krux02ok I got it
09:27:24krux02is there a performance advantage in thread local heap?
09:27:37rokupsthere is safety advantage
09:28:28krux02I heared that one of the performance problems of malloc is, that it needs to be synchronized between threads
09:28:33Araqperformance advantage: no contention possible, write barriers do not have to be threadsafe...
09:29:01FromGitter<andreaferretti> I think the advantage, for an actor library, would be that one could migrate actors between threads without losing state stored on the heap
09:29:29FromGitter<andreaferretti> so an actor that does work does not block all other actors that happened to live on the same thread
09:30:00krux02andreaferetti: as far as I know, an actor is not bound to a thread
09:30:01rokupssome actors live on one thread, some on another. one thread can execute one actor at a time. i do not see a problem
09:30:13krux02an actor is on that thread that just has time at that moment
09:30:50rokupsif you manage state object yourself you can share it among threads, but if you shoot yourself in the foot thats on you
09:31:24rokupsbut if you start coroutine on a thread and start using gc-managed objects then that coroutine is bound to a thread
09:31:42rokupsbut coroutines most of the time are short-lived
09:32:30krux02that is by the way also a problem in go. The thread that executes a goroutine/coroutine/actor/task from time to time just changes. An OpenGL context is bound to the thread. As soon as go changes the thread: boom!
09:32:59krux02it can be prevented by locking the thread, but it needs to be done in that language
09:33:39evacchiwe use thread local heaps though, but maybe we can make them task local <--- that would be pretty cool
09:34:05FromGitter<andreaferretti> what I was trying to say is that - while actor actions are short lived - actors could accumulate state
09:34:09rokupsthat would take away easy concurency though. suddenly coroutine is same as thread
09:34:16FromGitter<andreaferretti> if this state lives in the heap, this prevents actor migration
09:34:59FromGitter<andreaferretti> if heaps were task-local, one could migrate actors between threads without losing the state
09:35:29rokupsat the cost of coroutines running on same thread not being able to interact with objects owned by other coroutines
09:36:33rokupsbut it is not clear if migrating running coroutine is even worth all the trouble
09:37:32rokupsgo probably migrates them around to balance out tasks among worker threads. i would just have programmer define which coroutine is potentially long running so long running ones would be spread evenly across the threads while short-running ones would go to thread that executes least amount of coroutines
09:38:53krux02well instead of thousands of coroutines, one could also just create all jobs on a big list of jobs with an update proc that truely return, then everybody can handle scheduling according to their needs, or simplest case just have a sinle loop
09:39:58FromGitter<andreaferretti> @krux02 I am not sure I understand your suggestion, can you elaborate?
09:40:31*sz0 joined #nim
09:41:04Araqrokups: ok, back to your question
09:41:04krux02I just wanted to mention, there is always more than one solution to a problem, and I personally do not use coroutines at all.
09:41:21krux02and I don't necessarily need them
09:41:41krux02but coroutines are AFAIK nothing more than resumable functions
09:42:02Araqcoroutines do have the problem that they are not serializable, so if you base your game on them, "save game state" can become very problematic
09:42:48Araqsince the state is in what you cannot control from the language directly, the hardware stacks that are full of pointers
09:42:51krux02I didn't even think about that, but yes
09:43:25rokupsi dont even know what executing code has to do with state saving \o/
09:44:09krux02so instead of a coroutine that gives the control back in intervals, there would be an object with update, and update stores the state in the object and when update is called again it knows from the object state where to continue
09:44:33krux02then all you need for serialization is to serialize the objects
09:44:37FromGitter<andreaferretti> the problem is - where does this object live?
09:44:44FromGitter<andreaferretti> if it is bound to a thread
09:45:03krux02it's in the control of the programmer
09:45:06FromGitter<andreaferretti> you are suddenly in a position where this object running for too long can stall other objects
09:45:11FromGitter<andreaferretti> if it is not
09:45:23FromGitter<andreaferretti> you need to migrate its state everytime you move it between threads
09:45:42Araqrokups: methods are not attached to a type only generic methods are
09:45:45krux02well for games, the update of a thread does not allocate
09:45:54Araqthat needs to be changed for the C++ interop to work
09:45:56FromGitter<andreaferretti> the context is - how to design an actor library
09:45:56krux02of an object I mean
09:46:05FromGitter<andreaferretti> like Akka for Scala
09:47:15krux02Well I would ask how Akka solves it
09:47:52FromGitter<andreaferretti> the JVM has a shared heap :-)
09:49:22rokupsAraq: the way i imagine it is `method foo(this: var Bar) {.virtual.}`
09:49:44krux02I don't know how far you can get when you say you also make task local heaps
09:50:00krux02isn't that a lot of individual heaps?
09:50:50Araqrokups: yeah but for a start we'll use method foo(this: var Bar) {.exportc.} = ...
09:51:14krux02At the moment I don't know how the thread local heaps work, but I imagine they simply work by calling the C malloc ahead of time, and the locally manage those chunks for single threads, so that malloc as called less often
09:51:18Araqexportc'ed methods need to be attached to the type just like it's done for generic methods already
09:51:46Araqand then you need to patch ccgtypes.nim so that the method is generated in the struct {} declaration
09:52:14Araqkrux02: we don't use malloc, we use the OS's memory management directly
09:52:38rokupsAraq: there probably should be additional checks as well? for instance that Bar's parent is importc'ed?
09:52:46krux02does the OS haves something more smart that malloc?
09:53:14Araqrokups: yeah but that can wait
09:53:29Araqhardest part is to convince the codegen that structs can have routines in them
09:53:56FromGitter<andreaferretti> well, erlang uses one heap per actor and works fine
09:53:59Araqkrux02: malloc uses the OS under the hood, we skip the man in the middle
09:55:27krux02since I did not yet work with threads, I only need to use allocate shared, when I expect another thread frees the memory I just allocated, when other threads are only reading that memory I am fine?
09:56:31rokupsAraq: could you point me to source files that i will be modifying? will be way faster than for me to find out on myself. in general i do get the idea, will see if anything can come out of this.
09:56:48rokupsah wait you already told, ccgtypes.nim
09:58:28*evacchi quit (Ping timeout: 240 seconds)
10:02:46*evacchi joined #nim
10:05:42evacchiI'm pretty happy my question has generated this conversation :) BTW, besides try and shoving an actor model in Nim, then I'm wondering what patterns would be "idiomatic" for Nim instead of actors
10:06:39evacchiI mean, I'm currently working on a project where being able to freely spawn "tasks" regardless of where they will be executed it's pretty conveniente
10:06:44evacchi*convenient
10:07:43krux02evacchi, well you can do that when you have your own scheduler
10:08:49evacchithese tasks have state that must be maintained in some way, so they are not really short-lived in a broad sense. As Andrea Ferretti was saying, the action they perform when they are resumed are usually short; OTOH their state might be kept around for quite a while (possibly the whole application lifetime)
10:09:26evacchi@krux02 yes, that is basically what you need; that and being able to migrate state across running "tasks"
10:09:40evacchibut if you cross thread boundaries, again, you are in trouble
10:10:03*chemist69 quit (Ping timeout: 240 seconds)
10:10:24krux02well you could make all tasks single threaded :P
10:10:34*Vladar joined #nim
10:10:44evacchi:P
10:11:15evacchiin some sense you are right; you can "pin" group of actors to one thread, and never migrate them, but that's a bit limiting
10:11:59krux02but honestly, I programmed a while now, and almost all situations I encountered where people wanted to spread the work across threads, there was much more potential for optimizing single threaded
10:13:18FromGitter<andreaferretti> @krux02 it is not about doing things fast
10:13:20evacchiheh. that's assuming you have control on that. the point of an actor framework is (also) to abstract that kind of detail away
10:13:29FromGitter<andreaferretti> it is about not blocking work from other actors
10:13:56krux02they just needed to do a few easy step: Don't use interpreted scripting languages, don't use pointer heavy data structures with a lot of overhead, organize your data so that you can process it in a linear scan and make sure that there is only data in the scan that is actually used
10:14:43krux02those simple steps often give a performance boost in a factor that "spreading out to multiple threads" can only dream of
10:14:53*chemist69 joined #nim
10:16:14FromGitter<andreaferretti> @krux02 if you don't have anything to contribute to the question in case - which is about being able to move coroutines between threads - please do not derail the discussion
10:16:23krux02maybe working with actors is great, I programmed in scala and I like the idea of no shared state, just messages.
10:17:24krux02but on the other side, I did not really use actors for anything
10:26:08krux02maybe it is just because I am not a web developer
10:27:17krux02sorry, for my unproductive contributions
10:27:46Araqevacchi: .async await runs "tasks" in a scheduler
10:28:32evacchiAraq: yes, but you can't migrate tasks across thread boundaries
10:31:22Araq*shrug*, once I have this problem I'll make the scheduler use multiple threads
10:31:48evacchiheh :P
10:32:23FromGitter<andreaferretti> it is not a minor problem though :-)
10:32:40FromGitter<andreaferretti> one long running async task can block any other async thing
10:32:51FromGitter<andreaferretti> it is workable the way it is right now
10:33:09FromGitter<andreaferretti> but for some models of computation (actors in particular) works really badly
10:33:46cheatfateandreaferretti: is not a problem, just spawn more schedulers using threads/processes
10:34:32FromGitter<andreaferretti> ok, so here we are to the starting point :-)
10:34:42evacchicheatfate: then how do you know when a scheduler is "too busy" ? can you migrate a task scheduled there to one that it is "less busy" ?
10:34:54FromGitter<andreaferretti> so, the question is
10:34:54FromGitter<andreaferretti> how to move a task between these threads?
10:35:36cheatfateevacchi, i dont need to know when scheduler is "too busy"
10:36:30FromGitter<andreaferretti> you do, if you don't want to starve tasks living in the same scheduler
10:36:48*arnetheduck joined #nim
10:37:11cheatfateandreaferretti: but whole program still can work, because other schedulers can work on their clients, while one scheduler will process long-running task
10:37:13krux02andreaferetti: do you have example code, where the current Nim solution just doesn't work very well?
10:37:38FromGitter<andreaferretti> no
10:38:01FromGitter<andreaferretti> but I think I did not make a very good job in explaining the issue
10:38:10FromGitter<andreaferretti> let me start from Akka (or any similar framework)
10:38:32cheatfatewhat is Akka?
10:38:52FromGitter<andreaferretti> an actor framework for the JVM
10:38:56FromGitter<andreaferretti> it allows me to start any number of actors that will be summoned by messages and do a short computation
10:39:10FromGitter<andreaferretti> actors are scheduled on a thread pool and they can keep state
10:39:26FromGitter<andreaferretti> because everything that happens inside an actor is single threaded
10:39:47FromGitter<andreaferretti> the only point of contention is a queue where messages directed to an actor are scheduled
10:39:50*allan0 left #nim ("WeeChat 1.7")
10:39:54FromGitter<andreaferretti> this has to be threadsafe
10:40:07FromGitter<andreaferretti> it is a very simple and convenient mutlithreading model
10:40:12krux02andreaferretti: I am not sure if starting from Akka is a good idea, even though I know Akka, I am not very familiar with using it. So I don't know how woll the concepts of akka actually work out
10:40:29FromGitter<andreaferretti> I have been trying to explain the basics above
10:40:46evacchikrux02: they've been doing that in Erlang for ages
10:40:57FromGitter<andreaferretti> now, crucially, the scheduling of actors upon threads is dynamic
10:41:01evacchiit worked out pretty well for them
10:41:05krux02I remember I watched a 1 hour video about Akka explaining all the concepts
10:41:16FromGitter<andreaferretti> if an actor takes too long for whatever reasons
10:41:32FromGitter<andreaferretti> the other ones are not blocked, because of the thread pool
10:41:56FromGitter<andreaferretti> this requires to be able to move the actor state between threads
10:41:57krux02it's long aga, but I think one of the most important ones is, that all actors know their parents they spawed from. And whon one actor dies, it will never be unnoticed unlike threads
10:42:05evacchithe scheduling has to be dynamic *also* because actors may spawn new actors
10:42:13FromGitter<andreaferretti> just let me finish :-D
10:42:28FromGitter<andreaferretti> in akka, this is trivial, because the heap is shared
10:42:48FromGitter<andreaferretti> in erlang, this is trivial again, because each actor has its own heap
10:43:15FromGitter<andreaferretti> the problem is: how to write a library that allows this model of computation on top of per thread nim heaps?
10:43:39krux02the question is, do you need to write it on top of per thread nim heaps?
10:43:45krux02Nim also has shared allocation
10:44:07krux02and you could implement the erlang model in a nim-actors library
10:44:15FromGitter<andreaferretti> yes, but this would require that actors never use the stdlib
10:44:29FromGitter<andreaferretti> I mean, one can do their own things using allocShared
10:44:38evacchiit would rule-out any kind of garbage collection
10:44:47FromGitter<andreaferretti> but just have a string in your state and it does not work anymore
10:44:57cheatfatewithout real use-case this looks like something too abstract...
10:45:11krux02I get the problem
10:46:02FromGitter<andreaferretti> there are plenty of use cases - from telecom switches to http servers to game servers - most things you can think of have been implemented in the actor model
10:46:11krux02I know that c++ has custom allocators for the entire STL
10:47:00FromGitter<andreaferretti> http://doc.akka.io/docs/akka/current/intro/use-cases.html
10:47:07FromGitter<andreaferretti> http://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why
10:47:16cheatfateandreaferretti: i dont think actors model is good enough for networking servers... because you have bottle-neck on receiving connection/message
10:47:24krux02If I remember correctly they are pretty useless, because there were not designed with these intentions, but to handle other weird things like far and near pointers, but the idea is that the solution could be that the nim library allows changing the allocator
10:47:32FromGitter<andreaferretti> whatsapp runs on erlang, spark is written on top of akka and so on
10:47:55krux02twitter uses scala (afaik)
10:49:44krux02cheatfate: actually it works pretty nice with networking. All you need is an actor on the receiving site that works passes incoming messages to the individual handlers
10:50:14cheatfateandreaferretti: its very easy to run something in 1000 servers, even if it slow by design... if you know akka so good, is it possible to ask you run benchmark for simple "Hello World" output via network?
10:50:39cheatfateand then run same benchmark for simple single-threaded asynchttpserver
10:50:48cheatfateso we can compare design, not approach
10:50:56krux02cheatfate: that is not really a good benchmark at all
10:51:02cheatfatekrux02, why?
10:51:30*zachcarter joined #nim
10:51:44krux02well, because akka is designed to work for server clouds
10:52:17krux02you can't just send a single "Hello World" from one computer to another, and say hey it's slow/fast
10:53:07evacchicheatfate: now you are moving target to remote actor systems which is a completely different thing
10:53:21cheatfatekrux02, but andreaferretti said it can be used for http/game servers
10:53:39evacchipony is an "actor language" from the ground up, and it does not implement remoting AFAIK
10:53:53*PMunch joined #nim
10:54:06evacchicheatfate: well at some point, yes; the discussion started with application-local actors
10:54:07FromGitter<andreaferretti> well, you asked for real case uses
10:54:22FromGitter<andreaferretti> the point, anyway, is not raw performance
10:54:27FromGitter<andreaferretti> is not stalling actors
10:54:27krux02yes it can be used for game servers, and it can be used in a way that autalmatically when too many requests come it, it triggers to start up another computer in the network that then starts handling requests
10:54:28evacchiapplication can still communicate using scokets at network boundaries
10:54:39cheatfateas for me every cloud based http/game servers can be shrinked to one server
10:54:39evacchiyet, using actors as the async computation model
10:55:23cheatfateand also this is one of Akka lights : "50 million msg/sec on a single machine. Small memory footprint; ~2.5 million actors per GB of heap."
10:55:49krux02I think Akka is just too big to be part of and standard library. The question is just, what needs to change in the standard library, so that something like Akka is implementable as a third library construct without any conflicts
10:56:27evacchiwe are not talking about writing akka on nim
10:56:42krux02I thought so
10:56:44Araqandreaferretti: not stalling is a hard problem with thread pools
10:56:52evacchian actor library is actually a very thin abstraction over threads/coroutines and it can be written in a very few lines of code
10:58:02evacchi*provided* you have a scheduler impl (to schedule the actor's message handling routine) and concurrent data structures (to hold mailboxes)
10:58:09Araqyou can move the offending task around but without extensive runtime injections it will stay offending aka uncooperative
10:58:36Araqevery 'while' loop has the potential to block a CPU core for good
10:58:43FromGitter<andreaferretti> yes
10:59:13FromGitter<andreaferretti> the point is that other actors can run on the other CPUs!
10:59:26Araqso then it blocks one CPU out of e.g. 16
10:59:44Araqbut here is the thing: you have lots of tasks
10:59:54Araqand many tasks share the same code/logic
11:00:26Araqso eventually you have lots of offensive tasks and every thread in your thread pool is affected
11:00:49FromGitter<andreaferretti> yeah, it is a problem of course
11:00:56FromGitter<andreaferretti> but moving tasks between threads mitigates it
11:01:49Araqthat can be good or bad. "mitigating" problems can also mean "you won't find the problem until after 30 days in production"
11:01:53evacchiwell, there's no fix for badly written code
11:03:02krux02are you talking about that coroutines that don't schedule, because they are stuck in a while loop?
11:03:23Araqkrux02: yes
11:04:19krux02well, I would fix it by documenting it. I mean isn't that the price for coroutines? They are more lightweight, but they can only schedule on certain predefined points?
11:05:03evacchi(BTW Erlang's actor can be preempted IIRC; OTOH Akka's can't)
11:05:16Araqyes, but the point is we start with this design and then hack around the design to protect against it :P
11:06:50krux02well my solution is to write a timing library that uses the high performance counter of the system to measure the time each actor did not have the chance to schedule. Run it and evaluate your highlights
11:07:06*evacchi quit (Remote host closed the connection)
11:07:27FromGitter<andreaferretti> @krux02 really, we are talking about two different things
11:07:46krux02ok?
11:08:17FromGitter<andreaferretti> the question is whether one could be able to move coroutines between threads
11:08:40*evacchi joined #nim
11:08:45FromGitter<andreaferretti> no amount of trying to speed up the work they do will completely eradicate the use case
11:09:18Araqwell you can move a task to different thread
11:09:25Araqyou just need to deepcopy its state
11:09:26krux02I am sorry when I apper to be stupid today
11:10:24krux02I just thought it is not possible to move coroutines between threads, because they use thread local allocations/state
11:10:35FromGitter<andreaferretti> I think there is just some misunderstanding - talking directly usually clears things up much better than a chat window :-)
11:10:43AraqI think it's fair to request an explicit 'yieldMoveToDifferentCpu'
11:11:02FromGitter<andreaferretti> that would definitely be useful!
11:11:22FromGitter<andreaferretti> even if some deep copy needs to be performed from time to time
11:11:24krux02yes I agree
11:11:50Araqthe copy should still be more efficient than a heap per task model
11:11:54krux02I think a yieldMoveToDifferentCpu should not happen secrently in the background
11:12:06krux02it might be something you want to be aware of, or to avoid entirely
11:12:26Araqyeah
11:13:05evacchiAraq: would it ? I mean what if state is relatively large ? (genuinely curious)
11:13:37krux02evacchi: that is why it is explicit
11:13:51krux02then the programmer can evaluate if it is worth doing it
11:13:58krux02or to solve it in a different way
11:14:38Araqevacchi: heaps per task are not cheap, you can memory fragmentation problems and Erlang under the hood does share iirc to mitigate the problem
11:14:47Araq*can get
11:15:03evacchiI see
11:15:28Araqor at least Nim's current heap implementation is not a good fit for this design
11:16:07krux02Araq: where do I find the alloc implementation of nim?
11:16:19Araqlib/system/alloc.nim
11:18:11evacchibtw thanks for all the feedback, that was useful
11:21:48Araqevacchi: you might want to try an thread==actor model for testing purposes
11:22:19Araqeverybody claims threads have too much overhead, but a modern Linux can handle 100_000s of threads
11:22:36Araqand it uses an O(1) scheduler
11:23:43Araqand you don't have to deal with this "omg, this IO operation can block" nonsense :-)
11:24:12Araq(yes, it can block, the OS knows it can then run a different thread on the CPU core)
11:25:04Araq(the OS also knows how to preempt while true loops running wild)
11:25:18PMunchHmm, quick question. When writing a macro, is it possible to get the names of the attributes a function expects?
11:26:37evacchiyes, although on different kernels threads are less lightweight. e.g. threads on MacOS (which I use for development) have a much lower numeric limit
11:27:04Araqand Linux uses memory overcommitment for the thread stacks (finally something where overcommit is useful, even for all the wrong reasons)
11:28:00evacchihttp://www.jstorimer.com/blogs/workingwithcode/7970125-how-many-threads-is-too-many
11:28:17*chemist69 quit (Ping timeout: 255 seconds)
11:28:36Calinouwhat about Windows?
11:30:50evacchiI'm not sure about windows but I think the kernel it's optmized for threads; moreover by peeking at rokups PR I just discovered they have native fibers
11:30:55evacchiwhich is pretty cool
11:37:38*evacchi quit (Remote host closed the connection)
11:43:32cheatfatewindows kernel is not optimized on threads, threads are part of windows kernel every execution in windows is thread specific
11:44:18*sz0 quit (Quit: Connection closed for inactivity)
11:46:36*chemist69 joined #nim
12:00:54*libman quit (Quit: Connection closed for inactivity)
12:02:08*yglukhov_ joined #nim
12:02:09*yglukhov quit (Read error: Connection reset by peer)
12:02:31*Snircle joined #nim
12:07:51*yay joined #nim
12:20:37*zachcarter quit (Quit: zachcarter)
12:29:28PMunchNo-one?
12:29:29*yglukhov_ quit (Read error: Connection reset by peer)
12:29:44*yglukhov joined #nim
12:32:45*yglukhov quit (Remote host closed the connection)
12:33:21*yglukhov joined #nim
12:36:05rokupsPMunch: likely noone understood the question
12:37:55PMunchOh sorry, I'm writing a macro that turns a DSL into calls to an existing library. While doing this I've found that it might be useful to check if a certain function call (it's name generated on compile-time based on information from the DSL) has a specific argument.
12:38:10rokupsalso moving coroutine to another thread would require deepCopying all the objects whose reference is on coroutine stack for example. its not just coroutine state.
12:40:00rokupsPMunch: its a long time since i wrote macros, but maybe you can pass that func to a macro and dump ast or something?
12:40:44*yglukhov quit (Ping timeout: 255 seconds)
12:40:50PMunchHmm, I don't think so. Since the AST doesn't immediately identify the parameter names..
12:41:05AraqPMunch: you can use getType in the macro and the type has parameter info
12:41:19PMunchAh, okay. Thanks :)
12:41:20Araqbut for this the AST has to be 'typed'
12:41:25PMunchHmm
12:41:31krux02PMunch: you can also get the ast of proc implementations
12:42:04krux02there you might get the names of proc parameters
12:46:31PMunchHmm, another question. This macro takes things on the form "Element(parameter = true): <children>" where <children> is a list of similar elements. Is there some form of list comprehension that can give me the parts separately or would I have to parse it manually? I.e. can I somehow get "Element", ["parameter": "true"], [<children>]
12:47:50Araqmanually here seems to mean x[0], x[1], x[2]
12:48:24PMunchWell x[0], x[1..<x.high], x[x.high]
12:48:56PMunchYou could have Element(parameter = true, something = "else"): <children>
12:49:18PMunchWhich would come out as a Call with an Ident, two ExprEqExpr, and a StmtList
12:50:58*Arrrr quit (Ping timeout: 240 seconds)
12:51:30*yglukhov joined #nim
13:00:06stisaNot sure what you mean, maybe loop over element and use copychildrento to copy childrens to a nnkstmt or something?
13:01:19krux02I have a lot of error messages in my code from my editor, but it just compiles fine
13:01:26krux02how can that happen?
13:03:00stisaproblems with nimsuggest maybe?
13:04:41krux02stisa: yes that is basically what I said
13:04:53krux02I just updated nimsuggest to the latest version
13:11:37cheatfatekrux02, what is level of verbosity?
13:13:29cheatfateand what editor you use?
13:13:51nivcan someone explain to my why some stdlib calls use BiggestInt, and some use int? particularily, getFileSize(): BiggestInt; but all the io seek/set procs just use the system int
13:16:56krux02I use emacs
13:17:06krux02and it is something that worked in the past
13:17:31krux02cheatfate: it is not horrible, but it is wrong
13:17:50krux02I have around 10 wrong error reports
13:18:03krux02in 400 lines of code
13:18:03cheatfatekrux02, then maybe you should report it
13:19:43krux02last time I reported something for emacs, was in december, I didn't even get a reply: https://github.com/nim-lang/nim-mode/issues/147
13:20:22*xet7 quit (Quit: Leaving)
13:28:33PMunchIs there a way to get a slice out of an object with a [] procedure? Stuff you can normally call with something[5] to get it's 5th element, is there a way to do something[1..5] to get only elements 1 through 5?
13:30:26FromGitter<andreaferretti> https://nim-lang.org/docs/system.html#[],seq[T],Slice[int]
13:31:49PMunchWell it's not really a sequence, it just has a [] procedure
13:32:21FromGitter<andreaferretti> ah, I don't think so
13:32:31FromGitter<andreaferretti> you can write your own
13:32:41FromGitter<andreaferretti> system has it for seqs, strings and arrays
13:33:10PMunchYeah, writing my own now based on the source of the method you sent
13:33:35PMunchIt's for NimNodes so maybe it should be part of the macros module Araq?
13:43:56krux02PMunch, yes it's a loop
13:44:49krux02PMunch: do you plan to write one that returns a seq?
13:44:58*zachcarter joined #nim
13:45:20PMunchCurrently I just grabbed the one for seqs and modified it like this http://ix.io/nKs
13:46:04zachcarterSo I’ve made these Nuklear bindings, but the Nuklear header file has a lot of structs which contain members named things like ptr and pointer
13:46:51zachcarterI’m compiling the nuklear file like this - https://github.com/zacharycarter/nuklear-nim/blob/master/nuklear.nim#L3
13:47:02zachcarterhttps://github.com/zacharycarter/nuklear-nim/blob/master/src/bind.c
13:47:21PMunchAlso added the micro-proc high: http://ix.io/nKt
13:47:44zachcarteris there any way to do name mangling on the header file before compilation?
13:47:58zachcarterI don’t want to touch nuklear.h if I can avoid it...
13:48:09krux02PMunch: I also once tried to add high
13:48:13zachcarterand I’d like to keep nuklear imported as a submodule
13:48:16krux02did not work out very well
13:48:49krux02when it's defined in the same module it worked fine, but imported from somewhere else it did not work
13:49:28*nsf quit (Quit: WeeChat 1.7)
13:49:41krux02zachcarter: do you know git subtrees?
13:49:57zachcarternegative krux02
13:50:19krux02it is basically what you want to solve
13:50:25zachcarterokay let me read up on them
13:50:51krux02the important bit it, that it allows you to commit to the subtree
13:51:11krux02so you can touch nuklear.h and still get updates
13:51:50zachcarterokay sweet thank you
13:51:52krux02nice side effect is, that your repository can be cloned without being aware of submodules/subtrees, they get automatically cloned, too.
13:51:59zachcarterah sweet
13:52:08zachcarteralright I’ll ditch the submodule and go for a subtree
13:52:09rokupsyou are talking of submodules, and commit would go into submodule git repo, not to main repo
13:52:23krux02I am talking about subtrees
13:52:45rokupsuh.. this is a new thing?
13:52:47zachcarteryeah subtree sounds like a better solution that my current submodule thing
13:52:49krux02https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/
13:52:57zachcarterthat’s the article I’m reading
13:53:07krux02it's the first to find on google
13:53:12rokupslive and learn lol
13:53:12zachcarter:D
13:53:13krux02and it is good
13:53:30zachcarterI think these ptr and pointer fields are causing me a lot of issues with nuklear
13:53:47zachcarternot sure what I should be naming them
13:54:06krux02well you could keep the name and live with the backticks
13:54:13rokupszachcarter: what exactly is a problem with the fields?
13:54:38zachcarterso I’m doing this nil check here -
13:54:45zachcarterif not cmd.texture.`ptr`.isNil:
13:55:01zachcartereven if that check passes
13:55:10zachcarterand I try to do something like -
13:55:11Araqhttps://mail.python.org/pipermail/python-dev/2012-December/123028.html
13:55:18Araqwe should do the same
13:55:29Araqoptimize our tables data structure
13:55:31zachcarterlet textureHandle = cast[ptr TextureHandle](cmd.texture.`ptr`)
13:55:31zachcarter if not textureHandle.isNil:
13:55:32zachcarter if textureHandle[] == TextureHandle():
13:55:33zachcarter echo "HERE"
13:55:39rokupsah that, you can name struct field to something more appropriate, sec ill show u how
13:55:55zachcarterI’ll get a segfaul
13:55:57zachcartertt
13:56:04zachcarterlike I”m trying to dereference a null pointer
13:56:35rokupspointr {.importc: "ptr".}: pointer
13:56:59rokupsgood luck on figuring out a good name
13:57:04zachcarterthank you
13:57:35rokupsAraq: i dont really see where exactly list of procs could be attached to a type. point me to the file/proc :|
13:57:43PMunchkrux02, huh. That's weird, but I'm only using it in one module here so that's fine
13:58:04PMunchAraq, I actually saw a talk about that recently
13:58:28PMunchBasically showed all the iterations that the Python tables implementation has had
13:58:54PMunchAnd I thought about writing those kinds of tables for Nim
14:04:58zachcarterhrm - rokups what I can I do about method signatures and reserved keywords and bindings to C?
14:05:02zachcarteranything?
14:05:14zachcarteror the same thing?
14:05:40rokupszachcarter: if you are talking about names of func parameters - they are irrelevant
14:05:48zachcarterah okay
14:06:00zachcarterthanks
14:07:39krux02Araq: I like the hash memory optimization
14:08:31krux02Not sure about the performance, but my guess would be that the performance difference is neglible
14:09:54AraqI think OrderedTable should have use this optimization which is also used heavily for json
14:09:56PMunchkrux02, you might be surprised
14:10:07Araqand we had reports json is eating too much RAM
14:15:03zachcarterhrm rokups - I’m getting compilation errors when trying to compile my bindings using your suggestion, not sure why but the errors are specific to the type members I changed from using backticks to the importc pragma
14:15:05zachcarterso like
14:15:18zachcarter nk_handle* = object {.union.}
14:15:18zachcarter pointr* {.importc: "ptr".}: pointer
14:15:19zachcarter id*: cint
14:15:46zachcarternuklear_nuklear.c:261:44: error: no member named 'ptr' in 'nkhandle_lOpzfyOGEOkCq7IVFDfLiA'
14:15:47zachcarterT_TA49blRGL9cD0tQs9aEM0rD3w_0[38].offset = offsetof(nkhandle_lOpzfyOGEOkCq7IVFDfLiA, ptr);
14:16:29zachcarterI’m guessing maybe because other C code tries to refer to that ptr field?
14:16:42rokupszachcarter: you should importc structs as well
14:17:01rokupsotherwise you are redefining compatible struct, but i do not think it is a safe approach
14:17:08rokupsand in this case its not even compatible
14:17:11zachcarterah okay
14:17:28*bjz_ quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
14:17:35rokupshttps://gist.github.com/8b32a4035a25a983439978283399d4b7
14:17:53rokupsfull example
14:17:55zachcarterthank you
14:18:06zachcarterdidn’t know I could do this
14:19:43Araqrokups: grep for x.methods.safeAdd((col,s))
14:19:54rokupsty
14:21:45rokupsbut you should really stop using one/two letter abbreviated variables. its easy to loose one's head in there due to this :p
14:25:35AraqI never use more than 14 of them at the same time
14:26:24Learath2libsodium wrapper returns publickeys in strings, i want to put them in array[32, uint8], currently i just loop and assign char by char, is there a better way?
14:26:44Araqlearath2: no
14:27:03*couven92 quit (Read error: Connection reset by peer)
14:27:30Learath2is it even correct to return strings which might contain null bytes
14:28:03Araqyeah
14:28:53Learath2hmm always thought null bytes were somehow important in nim strings :P guess i was wrong
14:32:57PMunchHuh, why can't you have a tuple type with a list of it's own type inside of it?
14:33:38PMunchOh wait, yeah that makes sense
14:34:30zachcarterhrm rokups: this is turning into a disaster for me :P
14:34:50PMunchHmm, I now declared it to have a ptr to a seq[<type>]. That means I have to instantiate the seq explicitly right?
14:35:13zachcarterhttps://gist.github.com/zacharycarter/ebf9740c13e065e026f8b1ca3563afd9
14:35:44rokupszachcarter: you are overreacting :p show me nim code instead
14:36:27zachcarterokay so let me show you what I’ve done, give you a little context here
14:36:42zachcarterhere’s my original bindings - https://github.com/zacharycarter/nuklear-nim/blob/master/nuklear.nim
14:36:55zachcarterhere’s the header file I’m binding to ( it’s a bear ) -
14:37:13zachcarterhttps://github.com/vurtun/nuklear/blob/5f78107fc5fa50345e31190bf6d4b2224080a646/nuklear.h
14:37:57zachcarternow these bindings for the most part work - but I’m noticing in certain structures in nuklear.h where he’s using reserved Nim keywords as struct member names, I’m getting some weird results in Nim
14:38:19zachcarterfor instance here - https://github.com/vurtun/nuklear/blob/5f78107fc5fa50345e31190bf6d4b2224080a646/nuklear.h#L456
14:39:57zachcarterall I did to account for these reserved names, was add backticks to the corresponding member properties in the nim objects
14:40:15Araqthis is not a header file, this has full function bodies
14:40:25zachcarterit’s a single header library
14:40:39zachcartersorry I should have specified
14:40:43Araqyou can't #include it more than once
14:40:50Araqso how is it a header file?
14:41:09zachcarterI guess it’s not
14:41:11rokupscode builds only when some preprocessor variable is defined
14:41:21zachcartercode’s only included yeah
14:41:25zachcarterthat’s what this file is for -
14:41:39zachcarterhttps://github.com/zacharycarter/nuklear-nim/blob/master/src/bind.c
14:41:42zachcarterand in my bindings -
14:41:53zachcarterhttps://github.com/zacharycarter/nuklear-nim/blob/master/nuklear.nim#L3
14:43:01zachcarterif I do as you suggested rokups and try to define any of the types like - https://gist.github.com/rokups/8b32a4035a25a983439978283399d4b7
14:43:16zachcarter(I didn’t include the header pragma as I wasn’t sure how to resolve that)
14:43:28Araqyou're doing it wrong
14:43:29FromGitter<Varriount> Jabb: What kind of state would need to be shared among workers?
14:43:35zachcarterokay
14:43:39Araq{.compile: "foo.c".}
14:43:51Araqtype WeAreFree = object
14:44:05Araq x, y: cint # only layouts have to match
14:44:24zachcarterahhh okay
14:44:33Araqproc foo(x: WeAreFree) {.importc: "foO", cdecl.}
14:45:18*rauss joined #nim
14:46:11zachcarterso I have my pragmas mixed up and only layouts have to match is what you’re pointing out correct Araq?
14:46:19*yglukhov quit (Remote host closed the connection)
14:46:27rokupsand what if struct has custom alignment or something? matching layout will blow up in your face
14:46:54*yglukhov joined #nim
14:47:02Araqand what if you want it to work on the LLVM backend?
14:47:05rokupsits ok most of the time though. zachcarter you were handed a shotgun, now its your turn to be responsible ^_^
14:47:21zachcarter:)
14:47:55Araqfucking around in C land is worse than the occasional alignment problems which usually indicate stupid C code you don't want to use
14:48:18zachcarterso does importc need to come before cdecl?
14:48:24Araqno.
14:48:38zachcarterokay, I wasn’t sure if that was a mistake I was making too or not, thank you
14:49:51rokupsif only we could avoid using all the stupid c code is out there ;)
14:49:58Learath2uhm what does the syntax prox x*[y] mean?
14:50:34rokupsAraq: overriding virtual methods - should they be nim methods or procs?
14:50:45Araqmethods
14:50:58*yglukhov quit (Ping timeout: 240 seconds)
14:51:41Araqyummy, nimsuggest's memory leaks are gone :-)
14:51:57zachcarterI’d like to avoid using the stupid c code out there but there’s too much not written in pure nim yet
14:52:10zachcarterand no one is signing up to port 17k lines of C code to nim atm
14:52:13zachcarter:/
14:52:17zachcartermyself included
14:52:33rokupslangserver protocol support wanted for nimsuggest
14:52:58rokupsability to configure suggestion format (camelCase/snake_case) for nimsuggest wanted
14:54:36Araqc2nim can translate C function bodies too :P
14:54:52Araqrokups: link?
14:55:29rokupsAraq: http://langserver.org/
14:55:52rokupsthat thing is getting popular, clang recently got it's langserver. opens up potentially easy IDE support
14:56:40zachcarterAraq: this is true, I did start working on a port at one point but certain C constructs stumped me
14:56:43zachcarterI’m not the best C programmer
14:56:57zachcarterI have 4 days off next week, maybe I’ll give it another go
14:57:00FromGitter<evacchi> isn't vscode nim support already langserver-based ?
14:58:55FromGitter<evacchi> (huh; i could have sworn it)
14:59:44Araqno that uses the EPC protocol that is compatible with emacs
15:01:36rokupsemacs has langserver support as well by the way. do any other editors support EPC?
15:01:58rokupserr sorry, emacs lsp support is work in progress
15:03:09*yglukhov joined #nim
15:04:50*Arrrr joined #nim
15:04:51*Arrrr quit (Changing host)
15:04:51*Arrrr joined #nim
15:12:32*vlad1777d joined #nim
15:26:25Araq * The kind of a completion entry.
15:26:25Araq */
15:26:25Araqnamespace CompletionItemKind {
15:26:25Araq export const Text = 1;
15:26:26Araq export const Method = 2;
15:26:27Araq export const Function = 3;
15:26:29Araq export const Constructor = 4;
15:26:30Araq export const Field = 5;
15:26:31Araq export const Variable = 6;
15:26:32Araq export const Class = 7;
15:26:33Araq export const Interface = 8;
15:26:34Araq export const Module = 9;
15:26:35Araq export const Property = 10;
15:26:36Araq export const Unit = 11;
15:26:37Araq export const Value = 12;
15:26:38Araq export const Enum = 13;
15:26:39Araq export const Keyword = 14;
15:26:40Araq export const Snippet = 15;
15:26:41Araq export const Color = 16;
15:26:42Araq export const File = 17;
15:26:43Araq export const Reference = 18;
15:26:44Araq}
15:26:45Araqmeh, that doesn't look well thought-out
15:26:58AraqNim has concepts that do not map to these easily
15:28:09rokupsi do not think this stuff i set in stone. concepts are bound to be added anyway because they are coming in c++
15:28:35rokupsso its just PR-away i guess ;)
15:29:02Araqno I mean concepts like "macro"
15:29:14Araqor "type" (that's not a class...)
15:35:37*Vladar quit (Quit: Leaving)
15:42:02PMunchGiven a tuple(name:string, arguments:seq[NimNode]) where arguments are ExprEqExpr. What's the best way to create a let somesym = name(arguments)"
15:42:30PMunchCurrently I'm creating the NimNodes and putting them together
15:43:43krux02Araq: I see color is a very important completion item kind
15:45:12krux02PMunch: let sym = genSym(nskLet, name)
15:45:56krux02no
15:46:13PMunchWell, I'd want the result of a let statement be visible after the macro. So that would be a regular let
15:46:16PMunchNot a gensymlet
15:47:32krux02well you can use quote do and there is a pragma that lets you make an identifier visible outside of the macro
15:48:05krux02but it's best when the identifier comes from user code in some why, then you also don't need to hack it visible
15:48:19PMunchHmm
15:48:23krux02macrocall(myIdent)
15:48:32PMunchThe thing is I'm creating a macro to generate UIs
15:49:00PMunchAnd sometimes it's necessary to have a reference to certain elements
15:49:19krux02well it's best when you create a full example of pastebin
15:49:30krux02otherwise I don't understan what you are talking about
15:49:31PMunchSo I wanted to include a syntax in order to scope those as lets or vars
15:49:50krux02include a syntax?
15:49:53krux02what does that mean?
15:50:14PMunchhttp://ix.io/nKA
15:50:20PMunchThat's my DSL so far
15:50:56krux02ok that's looks a lot like qt :P
15:51:15PMunch() is arguments to the widget, [] is widgets for the add function (when adding as a child), <name>% is create an identifier (what I'm talking about atm).
15:51:42*yglukhov quit (Remote host closed the connection)
15:52:05krux02where do you create an identifier?
15:52:16PMunchSo in that snippet you would be able to do myButton.text = "woo" after calling the macro
15:52:18*yglukhov joined #nim
15:52:25krux02ah myButten
15:52:33*yglukhov quit (Remote host closed the connection)
15:52:44krux02I would say, take the identifier you get from the ast
15:52:48*yglukhov joined #nim
15:52:50krux02don't transform it to a string
15:52:55krux02keep it as a nimNode
15:53:10PMunchThat's what I currently have
15:53:10krux02and it will be visible automatically in user code
15:53:15PMunchOh
15:53:29PMunchSo if I just reuse the Ident it should be fine?
15:53:34krux02yes
15:53:55krux02reusing idents is also useful, because the NimNode has positional information
15:54:05PMunchAaah, that's cool
15:54:42krux02for example you can pass a NimNode to the error proc, so that the error message from the compiler emits locations in the dsl
15:58:25*rosshadden quit (Ping timeout: 260 seconds)
16:00:39*rosshadden joined #nim
16:00:58*themagician joined #nim
16:05:53*arnetheduck quit (Ping timeout: 260 seconds)
16:13:43*Trustable joined #nim
16:23:20*yglukhov quit (Remote host closed the connection)
16:23:53*yglukhov joined #nim
16:24:35krux02Araq: is it possible to pass a function symbol to a generic?
16:25:06krux02the idea is, that I do not want to pass a simple closure, but a set of function overloads
16:26:24Araqwell that's what 'mixin' is for?
16:27:00Araqa set of overloaded procs has no type though, so if you wanna pass it explicitly the generic has to be a template
16:27:58*yglukhov_ joined #nim
16:30:28*yglukhov quit (Ping timeout: 240 seconds)
16:32:29*yglukhov_ quit (Ping timeout: 260 seconds)
16:32:39krux02so I have to use a template I guess
16:33:25*gmpreussner quit (Ping timeout: 260 seconds)
16:36:09PMunchHow do I check if an ident already exists in the scope?
16:36:45PMunchI want to either do "ident = <element>" or "var ident = <element>" depending on if it exists or not
16:36:51*nsf joined #nim
16:37:46FromGitter<andreaferretti> `when defined(blah):`
16:38:06FromGitter<andreaferretti> or `when declared(blah):`
16:38:11FromGitter<andreaferretti> I always mix them
16:39:55PMunchIn a macro?
16:41:05FromGitter<andreaferretti> no, in normal context
16:41:17FromGitter<andreaferretti> but you can write a macro that produces this (I think)
16:41:22PMunchHmm
16:41:28zachcartercan someone help me understand why this is happening - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba
16:41:53zachcarterin my nim code when I echo image.handle.id I get 2
16:41:57zachcarterin my c code I get 0
16:42:50*abeaumont quit (Ping timeout: 255 seconds)
16:42:54*shodan45 quit (Ping timeout: 252 seconds)
16:43:19*rektide_ quit (Ping timeout: 245 seconds)
16:44:11*gmpreussner joined #nim
16:44:49*Andris_zbx quit (Remote host closed the connection)
16:47:21*filcuc quit (Quit: KVIrc 4.9.2 Aria http://www.kvirc.net/)
16:51:01*shodan45 joined #nim
16:52:28PMunchHmm, andreaferretti. Now I've got http://ix.io/nKB and call it by "result.add getAst(updateOrCreate(widget.identifier, asgn))" where widget.identifier is an Ident and asgn is a NimNode(nnkAsgn)
16:52:33PMunchBut I get all kinds of errors
16:52:43PMunchThat the symbols don't have a type..
16:54:00FromGitter<andreaferretti> sorry, cannot help you
16:54:07FromGitter<andreaferretti> was just some random idea
16:54:29PMunchI think it would work if I can get it running :P
16:55:54zachcarterI think maybe my problem has to do with the union?
16:56:16PMunchI mean, this works fine: http://ix.io/nKD
16:58:31zachcarterPMunch: I can try fooling around with it if you can put together a self contained example for me
16:58:41PMunchHmm
16:58:43PMunchHold on
16:58:44zachcartersince I can’t figure out my C binding code problem
17:04:43PMunchhttp://ix.io/nKF
17:04:45PMunchThere you go
17:04:48zachcarterthanks
17:05:01PMunchBoth the commented out version and the other should work in the end
17:05:05PMunchCurrently only the top one works
17:05:27zachcartergotcha
17:06:48zachcarterhrm PMunch this works for me -
17:07:07zachcarterhttps://gist.github.com/zacharycarter/5f7c49ec7ba5ed66dd931cbe6e0e3d6a
17:07:16zachcarternot sure if I’m misunderstanding what you’re trying to do
17:08:29zachcarterthat’s a pretty nifty trick though
17:08:30PMunchWait, that works for you?
17:08:32zachcarteryes it does
17:08:33demi-zachcarter: don't you have to declare the type the nim type is related to for that to work correctly?
17:08:40demi-(for your code problem)
17:08:51PMunchNim version?
17:08:57zachcarterdevel PMunch
17:09:11zachcarterdemi-: which type would that be
17:09:13PMunchYeah but which? :P
17:09:16zachcarteractually PMunch 16.1
17:09:22demi-the union declaration you have
17:09:28PMunchHmm, I'm on 0.16.1 as well
17:09:33zachcarterNim Compiler Version 0.16.1 (2017-01-31) [MacOSX: amd64]
17:09:34zachcarterCopyright (c) 2006-2017 by Andreas Rumpf
17:09:35zachcartergit hash: 8071648129909d47ff7d8d071938ba4c078fc7e4
17:09:36zachcarteractive boot switches: -d:release
17:09:40zachcarterah demi-: I do have that declared
17:09:56zachcartertype
17:09:57zachcarter nk_handle* = object {.union.}
17:09:58zachcarter pointr*: pointer
17:09:59zachcarter id*: cint
17:10:10*nsf quit (Quit: WeeChat 1.7)
17:10:25zachcarteroh I see what you mean demi
17:10:28demi-no i mean, a {.cdecl: "nk_handle", union.}
17:10:35zachcarterright right
17:10:35demi-or whatever
17:10:42zachcarterhrm I hadn’t ever tried that let me see if that works
17:10:43demi-importc, i think
17:11:21PMunchHmm, my version is younger than yours..
17:11:24PMunch55782205a4bcbe8584fbb96425ae530a302be15f
17:12:24dom96hello guys
17:12:32PMunchHi dom96
17:13:06dom96How are things?
17:13:23zachcarterdemi:- not working
17:13:24zachcarterhttps://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba
17:13:26zachcarterupdated gist
17:13:57zachcarterPMunch: interesting, wonder what changed between versions to allow it to work
17:14:03Learath2system.writeLine seems broken :/ http://paste.pr0.tips/Hq ./test genkey test.key only has 1 newlines but i call writeline 3 times on it :/
17:14:15PMunchYeah, me too
17:14:21PMunchAnd if it was intentional or not..
17:14:22Learath2disclaimer: its very possible that i messed up too :P
17:14:34PMunchAraq, would you know?
17:15:14PMunchhttps://gist.github.com/zacharycarter/5f7c49ec7ba5ed66dd931cbe6e0e3d6a That runs on git hash: 8071648129909d47ff7d8d071938ba4c078fc7e4 but not on git hash: 55782205a4bcbe8584fbb96425ae530a302be15f
17:15:35dom96Ooh, lot's of people asking questions, I like it :)
17:15:57PMunchHaha yeah it's busy here today :)
17:15:58zachcarterdom96: maybe you can help me with this binding problem I’m having - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba
17:16:06demi-PMunch: you could just git bisect it?
17:16:10zachcarterit’s making zero sense to me
17:16:49dom96Learath2: that's a lot of code, try reproducing it in a small sample, it will probably help you find the problem (if it is your fault) and if not then it will make it easier for us to test.
17:17:38PMunchdemi-, hmm time to learn bisect then?
17:17:55dom96zachcarter: the {.union.} looks suspect to me, although I guess it should work since the C type def is a union.
17:17:59demi-yeah, it is pretty easy https://git-scm.com/docs/git-bisect
17:18:06dom96zachcarter: still, give it a try without
17:18:09zachcarterokay
17:18:26zachcartereven without I print 0 from C :/
17:18:29PMunchHuh, reading the man page now. That actually seems super useful :S
17:18:58dom96zachcarter: oh, it's the C that's printing 0
17:18:59dom96hrm
17:19:01zachcarteryeah
17:19:12zachcarterNim is printing what I expect
17:19:19zachcarterwhich is 2
17:21:50PMunchHmm, when I have nim installed. Do I need to do the whole csources dance? Or is that just for bootstrapping?
17:21:58Learath2dom96: turned out to be a great idea :P figured it out
17:22:08dom96Learath2: :D
17:22:20dom96zachcarter: gonna try compiling it locally
17:23:28*Nobabs27 joined #nim
17:24:42Learath2just need to work out the algorithm to verify the certs and im done \o/
17:24:53Learath2oops w/c
17:27:36zachcarterdom96: thanks
17:30:12zachcarterdom96: going to switch from IRC to gitter
17:30:37PMunch:/
17:30:39PMunchPoor IRC
17:30:46zachcarteroh I prefer IRC
17:30:52zachcarteri’m just about to go mobile and get in the car
17:30:57PMunchAh right
17:31:09PMunchI thought you meant a permanent switch :P
17:31:13zachcarterhaha nan
17:31:15zachcarternah*
17:31:32*zachcarter quit (Quit: zachcarter)
17:37:31FromGitter<ivankoster> hmm, i want to cast a uint32 with the most significant bit set to an int32 but it throws an overflow exception. I just want to interpret the bit pattern as an int32, how do i prevent the error from throwing?
17:38:39PMunchHmm, when I pull the branch zachcarter had I still can't get the code to run..
17:39:37FromGitter<zacharycarter> Weird...
17:40:03PMunchhttp://ix.io/nKI
17:40:24PMunchThat's the code I have, the run which fails, and my Nim version
17:41:10PMunchThe treeRepr looks weird, but if it worked for zacharycarter I don't see why it shouldn't work for me..
17:41:34PMunchzacharycarter, which OS are you on?
17:41:47FromGitter<zacharycarter> Osx sierra
17:41:57FromGitter<ivankoster> ```var x = 0xFFFFFFFF'u32 ⏎ echo((int32)x) # throws overflow exception``` ⏎ ⏎ How to make this work? I'm dealing with a low level protocol. Sorry for interrupting ! [https://gitter.im/nim-lang/Nim?at=58b07064e961e53c7f61861d]
17:42:52dom96PMunch: did you rebootstrap?
17:43:13PMunchYeah
17:43:26PMunchrm csources, pull it, build.sh, the whole thing
17:43:29dom96ivankoster: try cast[int32](x)
17:43:32FromGitter<krux02> how about -1?
17:43:32FromGitter<krux02> or do a cast
17:43:41FromGitter<krux02> castint32 (x)
17:44:21FromGitter<krux02> ``castint32 (x)``
17:44:24FromGitter<Varriount> I didn't even realize Nim supported the `(type)value` casting notation
17:44:41FromGitter<zacharycarter> Same
17:44:44*Vladar joined #nim
17:44:45FromGitter<Varriount> Then again, that probably resolves to `type value`
17:45:20dom96PMunch: and koch boot as well?
17:45:27demi-ivankoster because it generates range checks: https://gist.github.com/samdmarshall/e48fc5b5598a5e173af6e84eb97229e0#file-default-txt-L4
17:45:32dom96you don't need to re-build from C sources btw
17:45:56dom96Can't wait to finish `choosenim`, it will make this stuff so much more magical and easy (hopefully) :)
17:46:39FromGitter<ivankoster> Thanks guys, `castint32 (x)` indeed works :D
17:46:42*Trustable quit (Remote host closed the connection)
17:47:26*gokr joined #nim
17:47:58FromGitter<ivankoster> then i guess `(int32)x` is not really a cast but a conversion, and `castT ()` is an actual cast?
17:48:01demi-dom96: is that going to be like `*env` for most other languages
17:48:06krux02trying to post ``cast[int32](x)`` either fails on the irc side or on the gitter side
17:48:20krux02wow that one actually worked
17:48:25krux02double backticks
17:48:30PMunchdom96, now I did "git checkout 8071648129909d47ff7d8d071938ba4c078fc7e4" "bin/nim koch c" "./koch boot -d:release"
17:48:36PMunchStill won't work
17:48:54krux02it's not different than ``int32(x)``
17:49:00krux02it's a conversion
17:49:38dom96demi-: yes, like rustup
17:49:44krux02and ``(int32)x`` is a but different in the ast, but it is at the moment equivalent of a call
17:49:45demi-cool
17:50:00FromGitter<ivankoster> AH, thanks @krux02 that explains it
17:50:18krux02I would not recommend using it at all
17:50:36dom96krux02: submit a bug report to BlaXpirit's repo :)
17:50:57FromGitter<ivankoster> Im making google protobuf for nim, i have no choice but to cast. low level protocols ..
17:51:15*handlex joined #nim
17:51:17FromGitter<ivankoster> brb dinner
17:51:37krux02dom96: a bug report for what?
17:51:51PMunchNow I even went back to 0.16.0, bug persists
17:51:59PMunchdom96, do you get the code to run?
17:52:03dom96krux02: For FromGitter
17:52:08PMunchhttps://gist.github.com/zacharycarter/5f7c49ec7ba5ed66dd931cbe6e0e3d6a
17:53:05*vlad1777d quit (Quit: Leaving)
17:55:36krux02PMunch http://ix.io/nKJ
17:55:41*jabb left #nim (#nim)
17:55:52krux02does the same, but it's "nicer", at least to me
17:55:54krux02:P
17:57:25FromGitter<zacharycarter> Dom96: did that gist compile for you?
17:57:41FromGitter<krux02> yes
17:58:17FromGitter<krux02> why? What is the problem?
17:58:27PMunchkrux02, thanks. That does indeed look nicer :)
17:58:37FromGitter<zacharycarter> With my gist?
17:59:04FromGitter<krux02> what I posted compiles nicely
17:59:09FromGitter<krux02> I am on latest Nim version
17:59:13FromGitter<krux02> devel
17:59:26krux02and the original, too
17:59:46PMunchHmm
17:59:53PMunchtest.nim(18, 7) template/generic instantiation from here
17:59:54PMunchlib/core/macros.nim(269, 22) Error: expression 'test' has no type (or is ambiguous)
18:00:01PMunchThat's what I get when I try to run it
18:00:35FromGitter<zacharycarter> Krux02 im referring to - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba
18:00:55dom96zacharycarter: afraid not
18:01:07krux02PMunch: well test.nim only has 17 lines in the gist, so I can't tell you the result
18:01:23FromGitter<zacharycarter> Dom96: hmmm
18:01:44PMunchkrux02, the one you gave me had 18 :)
18:03:33*handlex quit (Quit: handlex)
18:04:06FromGitter<zacharycarter> Guess ill wait to see what araq can offer since the union thing isnt fixing anything
18:04:40dom96PMunch: your code works for me
18:05:03PMunchWindows, latest devel?
18:05:42dom96OS X
18:05:46dom96slightly dated devel
18:05:53PMunchHmm, so it appears to work on OSX
18:05:59PMunchBut not on Linux
18:07:47FromGitter<zacharycarter> @Araq if and when you have time can you take a look at having - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba and tell me why my C code is printing 0 and not 2?
18:12:16*yglukhov joined #nim
18:12:56krux02PMunch I am on Linux
18:13:15krux02zacherycarter: I am sorry on my computer the result is also 0
18:13:25krux02I did not know that this was unexpected result
18:13:30PMunchWell, now I feel like an idiot..
18:13:34krux02did not look too clearly on the code
18:13:35PMunchFigured it out
18:13:43PMunchMy file is called test.nim
18:13:54PMunchSo test is declared, as the name of the module -_-
18:14:19FromGitter<zacharycarter> Krux02: no prob
18:15:53*brson joined #nim
18:16:33*yglukhov quit (Ping timeout: 260 seconds)
18:18:26FromGitter<zacharycarter> I should have elaborated
18:21:02*handlex joined #nim
18:21:43FromGitter<zacharycarter> @krux02 does the problem make sense?
18:22:02krux02yes, I also took a look at the generated source
18:22:05krux02but no luck
18:22:14krux02I would try to debug the generated sourcecode
18:22:22krux02and see what is wrong there
18:22:37krux02it not the best code to read, but it is possible
18:22:43krux02when you navigate with search
18:23:09krux02but at the moment I can't really take a deeper look
18:23:20FromGitter<zacharycarter> Alright i started doing that and then my eyes felt like they were being stabbed with a rusty spork
18:23:51FromGitter<zacharycarter> Ill give it another go
18:24:12krux02well first start to save the generated sorucecode somewher else, where you can edit it, and don't be afraid, that it is overwritten
18:24:38krux02compile without debug information from nim
18:24:41FromGitter<zacharycarter> Np i appreciate the confirmation of the issue
18:24:47FromGitter<zacharycarter> Okay
18:24:49krux02but then add debug information on the c compilation
18:24:53krux02and then start debugging
18:25:05FromGitter<zacharycarter> Gotcha thx
18:25:23*hjsagg joined #nim
18:25:42krux02then you will either find out what you did wrong, or what the code generator did wrong
18:25:53FromGitter<zacharycarter> Right
18:26:11krux02when it is the later one, that's a very good prototype for a bug report, because it actually can go into detail of the code generator what is generated wrongly
18:26:39FromGitter<zacharycarter> Keeping my fingers crossed its the latter and ill have my first nim bug
18:26:57krux02there are a lot
18:27:37FromGitter<zacharycarter> Ill try to fix it if it ends up being a bug
18:27:41*djellemah quit (Ping timeout: 255 seconds)
18:27:44*djellemah_ joined #nim
18:27:58FromGitter<zacharycarter> Get my nim contrib toes wet
18:28:42subsetparkCan anybody tell what's happening here? https://www.irccloud.com/pastebin/R9hi1rqq/
18:29:38dom96subsetpark: is this inside `nim secret`?
18:30:15*handlex quit (Quit: handlex)
18:31:00PMunchhttp://ix.io/nKO
18:31:02PMunchHmm
18:31:08subsetparkdom96: it is
18:31:19dom96subsetpark: I wouldn't trust it
18:31:29subsetparkHowever, I get that same error message whenever I try to compile some code that's also calling random on a typed range
18:31:33dom96PMunch: beautiful
18:32:30PMunchHaha, thanks :P
18:32:35PMunchBut it doesn't work..
18:33:07*Nobabs27 quit (Quit: Leaving)
18:36:49PMunchIt seems like Nim struggles with either the genSym, or my crazy when's..
18:36:57dom96subsetpark: probably just doesn't support cshort
18:37:01PMunchdom96, is there another way of checking if an identifier is in a scope?
18:37:05*yglukhov joined #nim
18:37:22dom96not that I know of
18:37:27dom96what's the problem with 'when'?
18:37:56PMunchI dunno, it was when I introduced the when-adding macro that thing went south
18:40:42subsetparkdom96: ah, that hadn't occured to me
18:41:32subsetparkbut i'm able to assign foo.cshort..bar.cshort to something
18:42:43krux02PMunch, why do you so much want this when not declared?
18:43:08PMunchUgh, long story
18:43:27krux02why don't you let the dsl allow let/var statements?
18:43:41PMunchBecause I don't like the way it looks
18:43:46PMunchAnd I thought this would be easier..
18:44:20krux02well, I personally hate when a programming language has no clear distinction detween declaration, and just an assignment
18:44:59krux02I can never be sure that my local assignment is not changing a global variable/global state
18:45:02subsetpark dom96: Check out that example; it fails on the call to `random`, not on assinging to CountRange https://www.irccloud.com/pastebin/7xbhVafj/
18:46:00krux02and it breaks consistency with the rest of the nim language, where assignemens also never introduce new variables
18:46:31PMunchYeah, I know
18:46:39PMunchI'm not 100% locked into the idea
18:46:42PMunchBut I want to try it
18:46:55*yglukhov quit (Remote host closed the connection)
18:47:30*yglukhov joined #nim
18:47:31krux02well as a proof of concept, and to test your skills, if you can bend Nim to do that, it's quite nice if it works, When you actually want to do it, I just discourage you to do it at all.
18:48:58subsetpark`random` takes a slice[T] so I didn't imagine it would have a problem with cshorts
18:50:20dom96subsetpark: take a look at the code in random.nim
18:50:39dom96It seems like the problem is that there is no `+`(x: int, y: int16): int
18:51:25subsetparkahh.... gross :(
18:51:27dom96or actually
18:51:31dom96`random(x.b - x.a) + x.a` returns an `int`
18:51:38*zachcarter joined #nim
18:51:40dom96But T is int16
18:52:01*yglukhov quit (Ping timeout: 260 seconds)
18:52:02dom96This error could be far clearer
18:52:47dom96Could you report it on GitHub?
18:52:55subsetparksure
18:52:56dom96I will label it as "error messages"
18:54:20dom96Although I think this is two bugs
18:55:10subsetparkhttps://github.com/nim-lang/Nim/issues/5430
18:59:59*brson quit (Quit: leaving)
19:01:02*zachcarter quit (Quit: zachcarter)
19:02:56dom96Commented
19:04:41*yglukhov joined #nim
19:04:53subsetparkthanks !
19:07:44*rektide joined #nim
19:08:28*yglukhov quit (Remote host closed the connection)
19:09:02*yglukhov joined #nim
19:12:43*rektide left #nim (#nim)
19:13:43*yglukhov quit (Ping timeout: 240 seconds)
19:14:57*Nobabs27 joined #nim
19:15:48subsetparkUm, in response Araq called me incompetent...
19:15:55subsetparkThat's a really shitty way to build a community, dudes
19:16:01Araqhey sorry
19:16:09AraqI didn't call you incompetent
19:16:41Araqbut ok, I edited my remark
19:17:49Araqand I was referring to dom's reading competence because he should know better by now.
19:18:48Araqand this "error message did personally confuse me so it's a compiler problem" is annoying me
19:20:48Nobabs27ok
19:22:04federico3should I use renderTree or astToStr to convert a chunk of code to text?
19:22:36dom96Araq: Please think about this carefully. Not everyone that writes Nim has as much experience with it as I do.
19:22:49dom96Perhaps you're right and I should "have known better"
19:23:07dom96But these messages are just as much for me as they are for others.
19:24:38*nsf joined #nim
19:24:40Araqfederico3: these are very different, astToStr doesn't work for PNode
19:24:57Araqand renderTree only works on PNodes, I think
19:25:09Araq(or does macros.nim offer that one too?)
19:26:02Araqdom96: I bet it even refers to the column of the '=' in the statement
19:26:17dom96Araq: No, in fact it refers to the `+`
19:26:20dom96Which is what confused me.
19:27:53FromGitter<Varriount> subsetpark: What are you working on?
19:28:01Araqouch, you're right
19:31:43*Matthias247 joined #nim
19:34:05Araqdom96: I'm sorry.
19:34:50dom96No worries. It's all good.
19:35:22federico3thanks Araq
19:35:28dom96Btw, if you'd like I can create a special repo for these "error messages" issues.
19:35:31*libman joined #nim
19:37:26subsetparkVarriount: Doing some tabu search optimizers
19:37:29subsetparkWhy do you ask?
19:38:03Araqkrux02: is https://github.com/nim-lang/Nim/issues/5428 a regression?
19:40:41krux02if you mean that I have code that once worked, and then doesn't, then no.
19:40:50krux02it is new code
19:40:57krux02it is also wrong code
19:41:27krux02there are multiple parts that are just wrong, but error message is a bug of it's own
19:41:52*yglukhov joined #nim
19:47:28*hjsagg quit (Ping timeout: 240 seconds)
19:49:47*hjsagg joined #nim
19:50:36FromGitter<Varriount> subsetpark: I'm curious. :D
19:51:06FromGitter<Varriount> I like to see what fascinating things other people are working on.
19:54:00subsetparkHopefully I'll be able to open source it soon... It's part of reimplementing a lot of our inner loops at my work
19:55:01*hjsagg quit (Ping timeout: 260 seconds)
19:59:12*Arrrr quit (Quit: Leaving.)
20:13:31*Jesin quit (Quit: Leaving)
20:13:52*brson joined #nim
20:15:28*Jesin joined #nim
20:19:50*Jesin quit (Client Quit)
20:21:20libmanRemember to upvote https://www.reddit.com/r/programming/comments/5vzua1/bristech_video_nim_programming_language_stands/ for much win. ;)
20:23:56*Jesin joined #nim
20:25:15*ThisAsYou left #nim (#nim)
20:38:27*vlad1777d joined #nim
20:49:54*shodan45 quit (Quit: No Ping reply in 180 seconds.)
20:54:16*shodan45 joined #nim
20:55:07*nsf quit (Quit: WeeChat 1.7)
21:01:58*gokr quit (Ping timeout: 240 seconds)
21:02:11*rokups quit (Quit: Connection closed for inactivity)
21:02:21*themagician_g joined #nim
21:04:06*themagician quit (Ping timeout: 260 seconds)
21:07:38*gokr joined #nim
21:08:30*zachcarter joined #nim
21:14:41*cjbest joined #nim
21:19:14*gokr quit (Ping timeout: 240 seconds)
21:23:13zachcarterokay so I think I found a compiler generation error
21:23:35zachcarterI’m trying to confirm but I’m C retarded - can anyone help me understand how to produce an executable with clang?
21:23:43zachcarterI understand how to produce an object file but I don’t know how to link it
21:24:23demi-`clang -x c -arch x86_64 -lbar -Isome/dir/ foo.c -o foo`
21:24:38cjbestI can't help, but I would like to propose the new term C-tarded
21:25:06zachcarterthank you
21:25:33demi-iirc also -L for specifying library search paths
21:25:37cjbestThis is coming from somebody who is also a Nimbecile
21:25:43demi-you may also want -g for debugging
21:26:00zachcartergotcha
21:29:44zachcartercjbest I like them both
21:30:52cjbestI'm trying to use the contributed kissfft binding which I've installed via nimble. Trivial "import kissfft/kissfft" fails, saying "fatal error: 'kiss_fft.h' file not found". As far as I can tell, this file is in the package, but does not get copied into the nimcache directory. Can anybody point me in a direction to help diagnose?
21:31:36cjbestzachcarter hah thanks
21:32:15demi-cjbest: you may need to install the library separately and reference the header path that it is installed to
21:32:33*brson quit (Ping timeout: 260 seconds)
21:33:39cjbestdemi- as in don't try to use the nimble-installed version, but put it somewhere in my build path?
21:34:24demi-cjbest: it depends on how that dependency is configured, a bunch of wrappers don't include the C library, as they would have to update the wrapper version with the library
21:34:49dom96it seems that the repo contains the .c and .h files
21:35:02demi-ah, i see
21:35:15subsetparkIf I call a proc with a bunch of callbacks, can that fail typechecking depending on whether the procs I pass in are defined as closures, or in local scope - assuming I haven't made any mention of call style where I've defined the original proc?
21:35:37subsetparkrather, "or in global scope"
21:35:53Araqyes, of course
21:36:04Araqthe calling conventions need to match
21:36:05dom96cjbest: might need to edit the wrapper, instead of {.header: "kiss_fft.h".} put {.header: "kissfft/kiss_fft.h".}
21:36:18cjbestdom96 thanks, will try that
21:37:11dom96or maybe you need to tell Nim to pass a flag to the C compiler to look for header files in `nimble path kissfft`/kissfft
21:37:29subsetparkAraq: right, but I mean if I didn't specify any calling conventions in the proc that accepts the callback. Like, if I have proc foo() that accepts some proc(x: int), and I call foo with something that I've defined as a closure, does that count as the calling conventions "not matching"?
21:37:34dom96(Perhaps the Nim compiler should do that automatically)
21:39:20Araqproc types default to .closure and outer procs use .nimcall
21:39:38zachcarterdom9 / Araq: could you confirm if this is a generator bug or not for me please
21:39:39Araqthere is an implicit conversion from .nimcall to .closure
21:39:45zachcarterhttps://gist.github.com/zacharycarter/5b634c8cf5ae436efaa682523a1236c1
21:39:50zachcarterI will link to line numbers in 2 seconds
21:40:20zachcartertest1.nim / test1.c and test1.generated.c are the problem files
21:40:29zachcarterthis line is problematic - https://gist.github.com/zacharycarter/5b634c8cf5ae436efaa682523a1236c1#file-test-generated-c-L120
21:40:45zachcarterif you compare it to test2.nim / test2.c / test2.generated.c
21:40:46zachcarterand this line
21:40:58zachcarterhttps://gist.github.com/zacharycarter/5b634c8cf5ae436efaa682523a1236c1#file-test2-generated-c-L104
21:41:43Araqnot a bug, annotate nuk_image with .byCopy
21:41:57zachcarterthank you Araq
21:42:07*hjsagg joined #nim
21:43:06*dom96 wasn't even aware of this
21:43:14zachcarter:D
21:43:29*Trustable joined #nim
21:43:36zachcarterI think that explains my whole zero / 2 problem dom96
21:43:49dom96zachcarter: If you have some time would you (or anyone else) be interested in writing a "Wrapping C guide"?
21:43:51subsetparkAraq: Ok, so my understanding of that is - assuming I haven't declared any calling conventions anywhere: If I define a proc that expects some proc argument, it will default that argument's CC to .closure; and since .nimcall procs are convertible to .closure procs, it effectively "shouldn't matter" under normal circumstances - since I'm not specifying any
21:43:51subsetparkcalling conventions anywhere, all of my procs will end up as either .nimcall or .closure, and procs which TAKE procs as arguments will expect/accept .closure
21:44:00zachcarterdom96 I could do that
21:44:18zachcarterI was already thinking about getting a blog going and writing some posts about my experiences wrapping soloud and nuklear
21:44:46zachcarterI have some time off next week I’ll take a stab at it
21:44:49dom96I'd love to have a tutorials section on our new website.
21:46:10Araqsubsetpark: no, it matters soon enough, because implicit conversions are not applied in array constructors for instance
21:47:12*bjz joined #nim
21:47:28zachcarterwould be very nice dom96
21:47:41Araqdom96: it only comes up in poorly written C code ;-) that said, I intend to change this after 0.16.2 because more and more people stumble upon this
21:47:57Araqespecially when they don't even use a C middle layer
21:48:02subsetparkhm. I don't *think* that's my problem but it's hard to tell, because the type error message has concrete types on the left side but generic types on the right side. Is there any compile-time ability to, for instance, type check individual arguments with their expected type?
21:48:37Araqsubsetpark: just give me a code snippet instead please
21:49:08cjbestdom96 got it compiling with --cincludes:`nimble path kissfft`
21:50:07subsetparkI imagine you'll find it a lot to take in... https://ghostbin.com/paste/gh4yo
21:50:42dom96cjbest: Good. It would be nice if Nim could automatically add that.
21:50:45subsetparkhttps://ghostbin.com/paste/zc5pa
21:50:46dom96Araq: Thoughts? ^
21:51:19subsetparkThe invocation happens on zc5pa:177, the original proc is defined on gh4yo:50
22:00:03AraqMarkTabu*[T, T2] = proc(tabus: TabuQueue[T2], scoreState: ScoreState[T], diffWith: T)
22:00:47Araq proc markTabu(tabuQueue: TabuStateQueue, stateScore: WorkerScoreState, diffWith: WorkerDataState)
22:01:08AraqWorkerDataState = seq[WorkerState]
22:02:23subsetparkyeah? That seems right
22:02:54subsetparkT = WorkerDataState, WorkerScoreState = ScoreState[WorkerDataState] = ScoreState[T]
22:03:59Araqyeah, I dunno then
22:04:51subsetparkCan you think of a way to get the typechecker to report which individual argument is failing typechecking?
22:06:19Araqyeah sure, and so can you
22:06:48Araqproc optimizeProto*[StateT, TabuElementT](
22:06:48Araq initialState: StateT,
22:06:48Araq getNeighborhood: GetNeighborhood[StateT]) = discard
22:07:00Araqadd more and more parameters and see when it fails
22:07:09subsetparksure... I guess I was wondering if there was a more verbose form of typechecking
22:07:11subsetparkbut i'll do that
22:07:28Araqthis things smells like "template" to me though
22:07:53subsetparkcan you elaborate? I'd love to streamline it
22:08:36Araqtemplate optimize(markTabu, markGoodMove, restart: untyped; ...) = ...
22:09:11subsetparkright, so basically skip the typechecking until we actually try to invoke the callbacks?
22:10:21Araqyup
22:10:41dom96cjbest: can you create an issue for this?
22:10:45Araqit's just an optimization algorithm, hardly 100 lines
22:11:21subsetparkSorry, I don't understand the implication
22:11:31Araqthe type signature reads like a programming exercise and you want to have all these callbacks inlined anyway
22:11:36cjbestdom96: sure, in nim-lang/Nim/issues?
22:11:59dom96cjbest: yeah, thanks :)
22:12:31cjbestWill do. Wasn't sure if this was a "the library should just update to fix" or a nim thing. It used to compile like a year ago
22:16:54subsetparkWell, it's definitely not an exercise...
22:18:12Araqsubsetpark: one issue that I can see is that objective is overloaded
22:18:31*dddddd joined #nim
22:18:36Araqand the compiler might have problems in determining what you meant in this context
22:18:50subsetparkyeah, I can definitely get rid of that overloading
22:19:20Araqsubsetpark: I mean the type signature is overwhelming me
22:20:48subsetparkyeah, you're not the only one. I would love to find a less hairy way to put this together. The Python code its a translation of is highly OO - tons of inheritance - and my first unsuccessful pass was using `object of` and `method`. Declaring callbacks within a closure seems better than that, but I agree that the type signature of optimize is really painful
22:21:43*FromGitter quit (Ping timeout: 240 seconds)
22:22:31*FromGitter joined #nim
22:25:23subsetparkPart of what optimize is doing is the generic side. How would I do that in a template, just pass in the types to instantiate as arguments to the template?
22:31:17AraqI don't really understand your problem enough to answer this question
22:31:52AraqI'm not sure my template idea would work out either, once one did read https://en.wikipedia.org/wiki/Tabu_search maybe your design is just right
22:32:38subsetparkOk... For now I'll just debug the types
22:33:19AraqI note though that the wiki pseudocode is 20 lines and you have 100 ;-)
22:34:07subsetparkYes, if you can imagine it, my version is more powerful than the pseudocode on wikipedia
22:35:38zachcarterfixed some issues in my bgfx nuklear backend and a major issue in nuklear-nim thanks for the help today guys
22:39:26subsetparkIt's boiled down to this : https://www.irccloud.com/pastebin/Uf746y6h/
22:40:20*Vladar quit (Quit: Leaving)
22:41:18subsetparkugh... found it
22:42:28Araqeven at the risk of sounding offensive yet again
22:43:06subsetparkuh huh...
22:43:14AraqI usually start with a concrete not generic implementation with concrete types everywhere and once that works, I generalize it
22:43:59subsetparkOh, don't get me wrong - I have done that already. This is the second module that uses this as a framework
22:44:20Araqwell I'm also lazy, so I do generalize after I actually need it to work with different types :-)
22:44:37subsetparkI'm pretty phobic of any kind of magic - as you can see, I still don't even really understand templates
22:46:12Araqdo you know C's #define? templates are very comparable except that they are safer
22:46:33subsetparkNo, the only templating I know is erlang's define()
22:47:13subsetparkI understand them in principle, it's using them for things that require, eg, generic programming or passing in code blocks where I hit the edge of my understanding
22:48:16*rauss quit (Quit: WeeChat 1.7)
22:48:24Araqalright
22:48:37Araqwell what was the issue?
22:48:38*butchster joined #nim
22:49:46subsetparkJust one type of many. objective's second argument was an Option[WorkerDataState] when it should have been an Option[WorkerScoreState]
22:49:51subsetparkNow i'm dealing with an illegal capture
22:51:36Araqyou also use [] pointer derefs where not valid, afaict
22:51:57subsetparkWhere's that?
22:53:03Araqsorry, just closed the tabs and ghost doesn't show me again
22:53:09Araqin your queue handling
22:53:26Araqyou have initQueue thats a value type, not a ref
22:56:01subsetparkoh, I define a proc `initQueue` - I probably am just reimplementing the built-in init for ref Deques
22:56:20subsetparkproc initQueue[T](): TabuQueue[T] =
22:56:20subsetpark new(result)
22:56:20subsetpark result[] = initDeque[Tabu[T]]()
22:57:18subsetparkI'll rename to initTabuQueue
23:01:23Araqthe convention says it needs to be named newDeque or newTabeQueue
23:01:39Araq'new' prefix, not 'init' prefix
23:03:16subsetparkWorks for me. Good to know
23:03:44subsetparkIs the procedure body correct according to convention?
23:07:17*yglukhov_ joined #nim
23:07:17*yglukhov quit (Read error: Connection reset by peer)
23:07:27Araqyeah I guess
23:12:07subsetparkha, that's that raving endorsement i was looking for
23:13:14*yglukhov_ quit (Ping timeout: 268 seconds)
23:18:52*Matthias247 quit (Read error: Connection reset by peer)
23:20:39*yglukhov joined #nim
23:21:09*sdw quit (Read error: Connection reset by peer)
23:21:37*Trustable quit (Remote host closed the connection)
23:21:40*sdw joined #nim
23:21:40*sdw quit (Changing host)
23:21:40*sdw joined #nim
23:21:53FromGitter<Varriount> subsetpark: :D
23:23:12*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
23:23:24*hjsagg quit (Remote host closed the connection)
23:25:08*rosshadden quit (Ping timeout: 255 seconds)
23:26:04*rosshadden joined #nim
23:56:43*Sentreen quit (Ping timeout: 240 seconds)