asynchttpserver basic-usage with error

2020-12-26 Thread domogled
Oh, thanks

asynchttpserver basic-usage with error

2020-12-26 Thread jrfondren
Probably, the library was updated without an update to the documentation. If you look around the library code you'll find pieces of the example in there, inside the new API you're intended to use. import asynchttpserver, asyncdispatch proc main {.async.} = var server

asynchttpserver basic-usage with error

2020-12-26 Thread domogled
Hi, I copy example code from import asynchttpserver, asyncdispatch proc main {.async.} = var server = newAsyncHttpServer() proc cb(req: Request) {.async.} = let headers = {"Date": "Tue, 29 Apr

asynchttpserver basic-usage with error

2020-12-26 Thread domogled
I did change library code in nim-#devel/lib/pure/asynchttpserver.nim(68, 3) set codket to "public" AsyncHttpServer* = ref object socket*: AsyncSocket # I add * reuseAddr: bool reusePort: bool maxBody: int ## The maximum content-length that will be read

cs2nim update

2020-12-26 Thread treeform
What kind of things are you brining from C# to nim?

How to deal with Enums with same names?

2020-12-26 Thread alexeypetrushin
> That means, among other things, that you can't infer the type of a function > argument based on the signature, which is what you're trying to do here. Sad...

Closure vs object benefit?

2020-12-26 Thread snej
My intuition is that an object with methods would be more efficient, because it’s designed for exactly this, vs. closures which are much more general purpose. As for which is _better_ , there’s a Zen koan about that: > The venerable master Qc Na was walking with his student, Anton. Hoping to >

How to deal with Enums with same names?

2020-12-26 Thread xigoi
The problem is, Nim doesn't have backward type inference (because it would conflict with existing features and make the compiler much slower). That means, among other things, that you can't infer the type of a function argument based on the signature, which is what you're trying to do here.

How to deal with Enums with same names?

2020-12-26 Thread snej
I like Swift's grammar, where the enum value doesn’t have to be qualified with its typename unless it’s ambiguous. And the parser uses type analysis to narrow down the possible enum types in function arguments, so there’s very rarely ambiguity.

How to deal with Enums with same names?

2020-12-26 Thread alexeypetrushin
Yes, there are edge cases with enums when it's impossible to disginguish which one to use. And emitting an error is ok. But in most cases (maybe even in 90%) - it's possible to know what enum to use. Current way enums are used - looks ugly and inconvenient let some_re = re(".*\\s:(

cs2nim update

2020-12-26 Thread kobi
I updated the repository again, you can check out the tests/samples dir to see what currently works. sorry limited time (even to properly post new info here) right now, the code is still in flux, so no need for pull requests for now, but if you're interested you can take it for a spin, or post i

How to deal with Enums with same names?

2020-12-26 Thread ElegantBeef
Just as any case where the are multiple overlaps you need a way to distinguish both. What about if you did `let a = red`, which enum is that value? It's less like using multiple dispatch, as there is a way to discriminate the types, it's like having an int literal such as `10` being treated as a

How to deal with Enums with same names?

2020-12-26 Thread alexeypetrushin
> It's admittedly a bit C-ish, but you get used to it as it matches the way > functions are handled in Nim. I would say it's against the way functions are **used** in Nim. One of the biggest advantage of multiple dispatch is to free human memory. So you can say "shape.rotate()" and the machine

How to deal with Enums with same names?

2020-12-26 Thread disruptek
... type Yep {.purely: "foo".} = enum One Two discard fooOne Run

How to deal with Enums with same names?

2020-12-26 Thread doofenstein
what you often see in Nim code is to prefix enums so that you just don't have two enums with the same name in the same module. If you have two enums from separate modules but with the same name you can distinguish them by the module name. See the Nim style guide for official projects:

How to deal with Enums with same names?

2020-12-26 Thread Stefan_Salewski
Have you really missed pure enums? See end of this section or other tutorials. For name conflict with function name -- well never occurred to me?

How to deal with Enums with same names?

2020-12-26 Thread juancarlospaco

How to deal with Enums with same names?

2020-12-26 Thread alexeypetrushin
Thanks, yes I missed it, with pure it looks better :). Would be even better if the last line `print_color(Color3.red)` would worked too without the explicit specification as there's enough information for compiler to extend `print_color(red)` into fully qualified enum name. type Co

How to deal with Enums with same names?

2020-12-26 Thread alexeypetrushin
Code below won't compile, because it has name conflict for enum. type Color3* = enum red, green, blue type Color7* = enum red, orange, yellow, green, light_blue, blue, violet proc print_color(color: Color3): void = echo color print_color(red) Run E

let's work :-)

2020-12-26 Thread digitalcraftsman
Not long ago I discovered this small language called Nim and liked the overall language design and the small yet responsive community around it. Retrospectively, 2020 was a good year for Nim with a few highlights despite the whole Covid situation: * new and interesting libraries emerged, *

let's work :-)

2020-12-26 Thread xigoi
`let thisChristmas = Holiday(kind: hkChristmas, merry: true) ` Run

Advent of Nim 2020 megathread

2020-12-26 Thread auxym
I wrote a hand-rolled recursive parser for day 19, which I think can handle the general case (as long as the rules are not left recursive):

terminal.nim says i don't have a true color term (but it's wrong)

2020-12-26 Thread cblake
The rxvt family and maybe more use it for another purpose (they do not support true color). So, it was always "unreliable". It may as well always have been a `NIMTRUECOLOR`. I agree a way to statically override may make sense (maybe statically override the name of the var as well?). The best wa

terminal.nim says i don't have a true color term (but it's wrong)

2020-12-26 Thread jseb
I've asked to several people if `COLORTERM` was set in their env. Answers vary … For Kitty, that's ok (set to _truecolor_ ). For rxvt-xpm, it's set to _rxvt-xpm_. It seems that testing `COLORTERM` is the best way to know if a term has true colors caps ( _s-lang_ does this way and _ncurses_ … d

terminal.nim says i don't have a true color term (but it's wrong)

2020-12-26 Thread cblake
For what it's worth, `rxvt-unicode` aka `urxvt` sets `COLORTERM` to be something quite different. So, this is not the best name to have used and you could run into trouble on (at least) that terminal emulator.

terminal.nim says i don't have a true color term (but it's wrong)

2020-12-26 Thread jseb
thank you for the answers. Indeed, before testing if the true color mode can be supported, we must enable it. First point. The second is , by reading the source of `enableTrueColors` , we have this when target is not MS-Windows™ : term.trueColorIsSupported = string(getEnv("COLORTER

Is it possible to generate a list of all transient dependencies and their sources?

2020-12-26 Thread zevv
"I fail to build this due to an unsatisfied dependency error" That is pretty ironic :(

Is it possible to generate a list of all transient dependencies and their sources?

2020-12-26 Thread adnan
This is great but unfortunately I fail to build this due to an unsatisfied dependency error. I have filed an issue in the repo.

let's work :-)

2020-12-26 Thread adnan
Merry Christmas and Happy New Year to all :)

let's work :-)

2020-12-26 Thread domogled
let's work without bugs :-) while true: we_all = happy and healthy Run