std/asynchttpserver or httpbeast

2020-11-25 Thread bung
if you need a python asyncio like framework , try , well , it's under development, I'll remove some debug log info if you can wait.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread xigoi
Obviously you'd have to remove the `static`, but it doesn't give you any benefit here anyway since you need to select the branch at runtime.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread xigoi
What monstrosity is that? Why not just do drawUberStatic(a, b, c, start, stepX, stepY, lines, blendMode, true, false) Run

std/asynchttpserver or httpbeast

2020-11-25 Thread domogled
I'm considering what to build my http server on. Jester is a good choice. Prologue, perhaps, too. We think, thank, We don't need a sinatra|express|flask -like framework. So I choose between stdl/asyncHttpServer and httpBeast. Btw: Jester uses both of these libraries. What's the difference betw

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread treeform
It would use if/case statements. See here: My huge if-case tree that calls 92 static versions of my single function. This quest for speed let me down the path of shaving a few branches here and there.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread adokitkat
Well `v` will be `static[bool]` and available at compile time if you declare it as `const v`.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread treeform
Hmm after working with it a bit. Yes I can use static yes, but it really does what template does already. I wish nim would dispatch dynamic variables into static procs. proc run(on: static[bool]) = discard var v = true run(v) Run I get error: `v is

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread treeform
Yes! The `static[bool]` and `static[enum]` is exactly what I want. Great feature! Thank you for answering!

Unhandled exception in httpbeast

2020-11-25 Thread domogled
I'm trying individual http APIs now. Jester has better routing, is built on httpbeans and or alternatively on stdlib/asynchttpserver. I studied the Prologues. Suffers a mysterious error, more my post here "Prologue has strange behavior. When running examples,

imgui

2020-11-25 Thread sekao
There must be something wrong with your linux environment...i don't know why you're getting that linker error when running my project. If you have any other computer or vm, try running it there. Don't bother trying to build imgui as a dynamic library; that won't fix the `-lXxf86vm` linker error,

Set base address of sequence

2020-11-25 Thread doofenstein
seqs are exclusively managed by the Nim runtime, so even if you managed to create a seq with the base pointer to your external memory the runtime could try to free it etc. UncheckedArrays are probably what you're looking for. proc doSomethingWithPtr(x: pointer) = let x = cast

How to properly deserialize variant (case) objects

2020-11-25 Thread cumulonimbus
I'm not looking for a way around it, I was actually happy with this constraint and am surprised that it is gone (or reduced, or whatever). I think it was Araq's who said that "If it can be changed without having to change/reset the rest of the fields, it should be a regular field and not an obj

How to properly deserialize variant (case) objects

2020-11-25 Thread cumulonimbus
> I'm not a fan of setting the discriminator after object creation; it just > feels lazy to me. > > Note that Nim has no requirements for discriminator ordering, either. Has this changed? In this thread: it says that you must set the discriminator first befor

How to properly deserialize variant (case) objects

2020-11-25 Thread disruptek
The requirement is a little looser than it was, in limited circumstances. Unless you really know what you're doing, I don't think it's worth the potential grief to try to work around it.

How mature is async/threading in Nim?

2020-11-25 Thread slonik_az
Bumping the thread to see what changed in the intervening 6 months. Specifically, is there a multithreaded executor for CPU bound async operations like rust's `tokio` ?

How to properly deserialize variant (case) objects

2020-11-25 Thread b3liever
Anyway, here's the second version of [eminim](https://github.com/planetis-m/eminim) For now it works like the others. Can use some suggestions on how to improve it. Testing and bug reports, all appreciated.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread juancarlospaco
`static[bool]` static arguments can give good performance improvements easily on some cases, too bad they are not allowed on stdlib sadly.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread euant
`static` parameters with `static` blocks are great for doing this kind of work at compile time in my experience. I actually [wrote a blog post related to this](https://www.euantorano.co.uk/posts/compile-time-string-validation/#approaching-the-problem-in-nim) a while back.

Unhandled exception in httpbeast

2020-11-25 Thread zetashift
D-d-do you mean jester and httpbeast instead of jockers and httpbeans? Jester has some niceties build in but I don't see why asynchttp wouldn't work. You can also take a look at:

Set base address of sequence

2020-11-25 Thread aid
Hi, a Nim newbie here, is there a way to set the data pointer of a Nim sequence? So that I could use the sequence to access memory that has been allocated by some library like PortAudio or OpenGL. In Golang e.g. I would create a Golang slice and get access to its header, and set the "data" and

recursive iterators - is there a recommend workaround?

2020-11-25 Thread cblake
Here is a link to some [recent discussion](https://forum.nim-lang.org/t/7020#44144) and links to for loop macros that may simplify your life. The manual has actually already been updated to include this, but I don't know if the "devel" HTML is online anywhere.

recursive iterators - is there a recommend workaround?

2020-11-25 Thread HJarausch
I am trying to "translate" a Python code, the heart of which is a 300 lines generator which calls itself (yield from) at several places. Is there a _readable_ workaround in Nim. Is there a summary of appropriate techniques somewhere. Thanks for some pointers.

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread leorize
I'm pretty sure `static[T]` is what you want, quoting the [manual](https://nim-lang.org/docs/manual.html#special-types-static-t): > For the purposes of code generation, all static params are treated as generic > params - the proc will be compiled separately for each unique supplied value > (or

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread Araq
`static[bool]` seems to do exactly what you're after.

How to properly deserialize variant (case) objects

2020-11-25 Thread b3liever
I forgot to mention that I am working on deserializing JSON from a Stream (directly) so it's a bit more different than having `JsonNodes`

How to differentiate different IOErrors?

2020-11-25 Thread yglukhov
@cblake, thanks for the correction, I actually meant `IOError`. I suggest saving a copy is `impossible` because (a) that's usually not your code that doesn't do that and (b) you can't make everyone to always account for a possibility of IOError going through their catch blocks. If that makes sen

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread treeform
Some thing like this: proc fn(foo: baked[bool]) = ... when foo: ... proc fn(true) Run Maybe using the type system? * * * I am trying to gain maximum performance and my code is kind of complex. But lets simplify it to a loop like this:

imgui

2020-11-25 Thread kb2ma
Thanks for the correction. Ironically I also just pulled in 1.4.0 to test that the Nim version was not an issue with running ImGui. Looks like I need to check the release page too. ;-)

imgui

2020-11-25 Thread Stefan_Salewski
> The command line nim r i.nim in your example It is fine for recent Nim compiler. But it is not very smart to use it in case of problems. If there is only a minimal chance for trouble, I use a plain nim c --gc:arc myfile.nim first to see all the compiler output including warnings. (nim r is co

imgui

2020-11-25 Thread slonik_az
Since version 1.4.0 `nim r i.nim` will > compile to $nimcache/projname, run with [arguments] using backend specified > by `--backend` (default: c)

Strange error message from collections/sets.nim

2020-11-25 Thread slonik_az
> @Araq: You have to use gofmt to get it or you need to be conciously aware of > tabs vs spaces all the time. Excuse me, but I prefer to spend more time on > the algorithmic aspects of my code. Modern editors are surprisingly good at keeping this complexity away from you. VS-code with Golang ex

imgui

2020-11-25 Thread kb2ma
The command line `nim r i.nim` in your example above should not compile/run. I assume you mean `nim c -r i.nim`. Can you share a snippet of `i.nim` so we can understand what's happening on line 3? Also, you should be able to compile and run the ImGui [test app](https://github.com/nimgl/imgui/b

How to properly deserialize variant (case) objects

2020-11-25 Thread timothee
see how i did it here:

How to properly deserialize variant (case) objects

2020-11-25 Thread disruptek
I'm not a fan of setting the discriminator after object creation; it just feels lazy to me. 1. Create the object with the discriminator and then populate the remaining fields as you wish. 2. Create the object with the discriminator and all other fields in a single constructor. Note that

Strange error message from collections/sets.nim

2020-11-25 Thread Araq
> Of course a good editor could fix that... Well I'm not gonna change the language for people who prefer to use broken tools, sorry. But there is a good alternative: Let's focus our efforts on a standard tree format for programming languages. We can then store code as trees on the disk and eve

Strange error message from collections/sets.nim

2020-11-25 Thread Araq
> Nim's hard choice of "two spaces per indent" is not helping its adoption. It > might seem as a pet peeve but for new Nim users with experience in other > languages it can be a serious irritation. There is no such "hard choice" and there is no evidence whatsoever that it hinders its adoption.

How to differentiate different IOErrors?

2020-11-25 Thread cblake
@yglukhov \- `OSError` already has `errorCode`. I think you maybe meant literally any other exception type in your last `except` and maybe by "error class" you mean `Exception` or `CatchableError`? Anyway, you do have the option of saving a copy of `osLastError()` in a variable (declared before

Strange error message from collections/sets.nim

2020-11-25 Thread cblake
I tried using proportional fonts for programming once. Very awkward. You are more adventurous than most. [Barely relevant, but funny.](https://forum.nim-lang.org/t/6891#43159).

Strange error message from collections/sets.nim

2020-11-25 Thread Stefan_Salewski
It's the other way round: Space key refers to the space, the empty room between two things, like two words. Tabs may be not the ideal solution for indentation, as tabs have not been really invented for it. But indentation by those tiny spaces will ever feel wrong. For people like me using a prop

Unhandled exception in httpbeast

2020-11-25 Thread domogled
Can I use the asynchttp server to build a web portal, instead of jockers and httpbeans?

Strange error message from collections/sets.nim

2020-11-25 Thread lqdev
I feel like one very important point people miss when saying tabs should be used for indentation is the fact that tabs actually have a different purpose. It's in the name: _Tabulator_. Not indentator.

How to properly deserialize variant (case) objects

2020-11-25 Thread b3liever
So I'm having trouble adding support for case objects in my deserialization library. I'm sorry for the long post but the question is really simple. Let's consider this example: type Fruit = enum Apple Banana Foo = object name: string

Unhandled exception in httpbeast

2020-11-25 Thread Peter
It seems that there is a workaround. If I put Jester behind http proxy (nginx) with a `localhost:5000` connection and do not use direct connections - everything works as expected, there is no exception. So, it seems to be a problem somewhere at Nim side working with 'real' network interfaces.

How to differentiate different IOErrors?

2020-11-25 Thread yglukhov
`osLastError` doesn't necessarily correspond to the `OSError` exception in question. try: try: foo() except: myLogFunction("error happened") raise except OSError: echo osLoastError() Run Now was `osLastError` triggered by

wonderfully prologue

2020-11-25 Thread Araq
Maybe report issues to prologue's issue tracker.

wonderfully prologue

2020-11-25 Thread domogled
prologue, example blog logue run ./app.nim DEBUG Prologue is serving at 0.0.0.0:8080 DEBUG Starting 8 threads DEBUG Listening on port 8080 Run Server is runnig. OK. Now more times send req

How to differentiate different IOErrors?

2020-11-25 Thread Araq
So yeah write this one line of code that "feels as low level as C". Pure hyperbole. > This might be another thing that fell through the cracks when @Araq did his > pre-1.0 stdlib quality control scan. Hardly, you can do IO without an OS.

Strange error message from collections/sets.nim

2020-11-25 Thread ElegantBeef
Well I never said it was useless, I just don't get the point. Indentation's purpose is to show scope, I'm uncertain if alignment even makes more readable code. Do want to say though that you can omit the `()` and just write as follows not that I suggest this. if 10 == 10 or

Compile Error for Nim-Generated C-code for android with ndk-build (through wiish)

2020-11-25 Thread cmc
Hi! I've been playing with the amazingly cool desktop/mobile toolchains and ended up looking at wiish but couldn't compile on android. I `filed an issue with wiish `, but am writing here excluding the wiish-specific parts- this looks to me like some kind

imgui

2020-11-25 Thread pihentagy
Ok, tried that: /tmp ⌚ 10:17:35 $ git clone --recursive https://github.com/cimgui/cimgui.git $ cd cimgui $ make $ cp cimgui.so ~ $ rm -rf ~/.cache/nim Run and then when I try to run my program again: $ nim r i.nim Hint: used config

imgui

2020-11-25 Thread pihentagy
That package is already intalled for me.

Strange error message from collections/sets.nim

2020-11-25 Thread lscrd
We want alignment for instance in this case: if some_long_expression and another_long_expression and another_one: Run Of course, we could use parentheses and write, using only indentation: if ( some_long_expression and another_lon