are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread Araq
Great update! However, I still don't like to see `defer` in the Nim compiler code and I dislike it so much that I thought of adding a switch `--araqstyle` (which forbids `defer` and `continue`) that is enabled for the compiler's code. But great update, thanks for writing it.

amysql - Async MySQL Connector write in pure Nim.

2020-11-16 Thread bung
Thanks!

Open-ended slices

2020-11-16 Thread pietroppeter
Well it appears that you can define a `[.. ]`: Unfortunately, it seems you are not allowed to define at the same time a `[ ..]`.

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread timothee
> That's the reason why I never used defer: as I thought that the try: ... > finally: scope rules were more clear. > With that semantic, defer: is really > different from try: ... finally: and the manual paragraph should be changed. fixed, see

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread spip
when true: block: template main1 = echo "ok1" defer: echo "ok3" echo "ok2" main1() main1() Run > [ok1 ok2 ok1 ok2 ok3 ok3](https://play.nim-lang.org/#ix=2Eqq) But that's not what states the [Nim Manual](https://nim-la

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread timothee
> Does defer still have the utterly counterintuitive behavior that it gets > called if a statement before it raises an exception? no, this was debunked, see , as you can also see here: when true: # prints a1 then raises foo bloc

Open-ended slices

2020-11-16 Thread snej
Hm, no postfix operators... I'm leaning toward using `nil` for the "alpha/omega" sentinels. (That's more or less how they're already represented internally.) So, `for (key, value) in collection[nil .. "x"]:` or `for (key, value) in collection["a" .. nil]:` (I realize `nil` isn't a valid string

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread snej
Does `defer` still have the utterly counterintuitive behavior that it gets called if a statement _before_ it raises an exception? I was actually unaware of that ... if it's still the case, I need to go through my code and fix any problems it's causing.

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread timothee
> Last time I bench'd was quirky > goto > setjmp @juancarlospaco any links? quirky isn't a fair comparison though (it has its uses but comes with large caveats), so we should restrict comparison to: * P1 manually doing what defer would do on exit * P2 defer with C++ * P3 defer with C+goto

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread juancarlospaco
Last time I bench'd was quirky > goto > setjmp

How do you deal with dependencies in Nim ?

2020-11-16 Thread federico3
This is not a very Nim-specific problem, but about software lifecycle in general. Various software distributions take a "snapshot" of the ecosystem at a given point in time and provide one given version of each library. This ensures that specific set of libraries and tools are well tested toget

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread treeform
So defer is here to stay, and many of its issues have been fixed. Thats great.

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-16 Thread timothee
now that defer is here to stay (refs which was rejected), it's time to revisit all the arguments presented above against `defer` in light of recent progress: > For the C target (which is the default) exceptions are mapped to setjmp, > pretty expens

Getting random non-equal int pairs, comparison of routines.

2020-11-16 Thread Vindaar
I saw this earlier today and decided to replace the gnuplot plotting by ggplotnim. Had to fix a small issue with reversal of discrete axes, but with this done, here's a solution that directly creates the grid of the plots shown in the OP in one ggplot call:

a DSL to construct Nim AST based on karax

2020-11-16 Thread geotre
Very nice! I haven't used it before but [this package](https://github.com/alehander42/breeze) seems to have similar goals

Open-ended slices

2020-11-16 Thread doofenstein
how about `..>=x` for an open range closed to the left?

out of memory

2020-11-16 Thread tmsa04
I've used Valgrind on C programs, which worked well on those. I think you just ran the app like valgrind --some-args appname after compiling it with debugging symbols, and it tells you if there are any memory leaks and what functions they originate in, so it's pretty simple to use. Never tried i

Gedit syntax highlighting.

2020-11-16 Thread spip
@Stefan_Salewski, your [nim.lang](https://raw.githubusercontent.com/StefanSalewski/NEd/master/nim.lang) and [nimdark1.xml](https://raw.githubusercontent.com/StefanSalewski/NEd/master/nimdark1.xml) are well supported in recent Ubuntu. # as root cp nimdark1.xml /usr/share/gtksou

Open-ended slices

2020-11-16 Thread spip
Like in from alpha to omega? `alpha .. X` is bottom-opened range while `Y .. omega` is top-opened range!;-)

Open-ended slices

2020-11-16 Thread b3liever
There are no postfix operators in Nim, with the export marker `*` being a special case. `..X` is defined in system. But for the other case you will need to maybe define a sentinel value that represents the upper limit and use the binary `..` op.

Blog post about strict funcs

2020-11-16 Thread AmjadBHD
> This can be important for evolving code bases so that you don't > accidentically break the func-ness guarantees. So shouldn't the usage of func be encouraged over proc (use func by default and only if you need a proc use it), like in code snippets in the docs and the manual and gradually repl

Blog post about strict funcs

2020-11-16 Thread AmjadBHD
> does it help the compiler to make optimizations in a way it can't without > `{.noSideEffects.}` ?

Open-ended slices

2020-11-16 Thread snej
I'm implementing a database cursor class. The keys are basically strings. A cursor can be restricted to a sub-range of the keys, like you might want to iterate only from "X" to "Y". I thought of using subscripts with ".." for this, so `curs["X".."Y"]` would return a copy of `curs` that's restri

Cross compile on WIndows 64bits for Windows 32 bits

2020-11-16 Thread Recruit_main707
i had the same issue, the ideal solution is to do what rockavera suggests

Cross compile on WIndows 64bits for Windows 32 bits

2020-11-16 Thread rockcavera
I do so here on my Windows 10 64 bit to get 64 and 32 bit executables: 1. I have 64-bit Nim; 2. I installed Mingw32 and Mingw64 (C:mingw32 and C:mingw64); 3. I configured C:Nimconfignim.cfg like this (I placed it at the end of the file): @if windows: @if i386:

out of memory

2020-11-16 Thread snej
There are likely some Linux tools you can use to inspect a process's heap. I don't develop on Linux, but for example, on macOS I would turn to tools like `heap` and `MallocStackLogging`.

Is there a torrent library for Nim?

2020-11-16 Thread zulu
Or is there a suitable candidate for wrapping?

Getting random non-equal int pairs, comparison of routines.

2020-11-16 Thread treeform
Wow Nikki's max substitution is pretty clever. You generate first number normally but generate second number with 1 less range. When you get a-b=0 on the send number you go for the highest value. Effectively making second be a number of full range but without 0s.

Cross compile on WIndows 64bits for Windows 32 bits

2020-11-16 Thread treeform
I think you will need a 32 bit version of GCC (or the C compiler you use). Then you will need to pass flags to nim to use that compiler. It might be easier to get a windows 32 vm and install nim there and compile there.

Blog post about strict funcs

2020-11-16 Thread Araq
It is inferred yes, but `func` (or an explicit `.noSideEffect`) guarantees it. This can be important for evolving code bases so that you don't accidentically break the func-ness guarantees.

How do you deal with dependencies in Nim ?

2020-11-16 Thread treeform
If you get to the "Cannot satisfy the dependency" state, you got to fix up the dependencies. Its same thing if your dependence relies on nim 1.0 feature thats been deprecated in 1.4. You just got to fix the code. Might be also nice if you submit the PR for your fixed dependency up to the author.

amysql - Async MySQL Connector write in pure Nim.

2020-11-16 Thread treeform
This is pretty cool!

Blog post about strict funcs

2020-11-16 Thread AmjadBHD
I apologize for my "noobiness" and for bumping this thread, why does one need to explicitly declare a routine with `func`, doesn't the compiler perform side effects analysis regardless ? does it help the compiler to make optimizations in a way it can't without `{.noSideEffects.}` ?

Passing iterators as arguments

2020-11-16 Thread Sixte
Well, I copy/pasted your example, made some minor changes - it wörks :) import tables type Iterable[T] = iterator: T proc iterSomething(xs: Iterable[int])= for x in xs(): echo x template toSecondClassIter(x) : Iterable = let myit = iter

Real sets and tables anywhere?

2020-11-16 Thread HJarausch
Many thanks for all these really helpful hints, Helmut

Cross compile on WIndows 64bits for Windows 32 bits

2020-11-16 Thread jslarochelle
I have the standard Nim installation and I can compile (defaults) my little script to run on my 64 bits Windows system. No problem there. But I am not sure about the parameters to use to compile on my 64bits windows system for a 32bits windows system I have read the manual and did not find the p

Real sets and tables anywhere?

2020-11-16 Thread spip
Well, there is [Nim for Python programmers](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers) and reading at least the [Tutorial](https://nim-lang.org/learn.html) will answer your questions...

out of memory

2020-11-16 Thread Araq
Inject `echo getOccupiedMem()` into strategic places in your program. Or maybe collect the information in a database. Or maybe by not collecting everything into a single tree. Usually there is a correlation between what you do and the amount of memory it requires, the more memory it takes, the

GC Safe Problem

2020-11-16 Thread Lucas_Ullon
hi i'm working with threads and ran into problem implementing the {.gcsafe.}. I'm using parsesql module in my code, any ideas how to fix it? this is the output in console: /nim-1.4.0/lib/pure/parsesql.nim(1238, 6) Warning: 'ra' is not GC-safe as it calls 'rs' [GcUnsafe2]| ---|--- /nim-1

Getting random non-equal int pairs, comparison of routines.

2020-11-16 Thread Zoom
Documenting a small discussion we had in Nim's IRC channel. I asked what would be the correct way of getting a pair of random and non-equal integers, besides a `rand` and another one in a `while a==b` loop, and got a few answers. In the spirit of non-apologetic bikeshedding I wrote a simple scaf

Which one to choose, Asyncdispatch in Nim vs Chronos?

2020-11-16 Thread gcao
I'm trying implement async support in my hobby language () and wonder whether I should use asyncdispatch or Chronos(. I've read a bit about both but couldn't tell which is better from technology perspective. It seems b

amysql - Async MySQL Connector write in pure Nim.

2020-11-16 Thread bung
amysql implements both the text protocol and the binary protocol amysql implements async connection pool(amysql/async_pool) and a threaded pool(amysql/db_pool). Test passed: platform: Linux and OSX mysql: 5.7 8.0 mariadb: 10 Todo: Finish caching_sha2_password_auth. Testing ssl mode ,unix soc

amysql - Async MySQL Connector write in pure Nim.

2020-11-16 Thread bung
hmm, forget provide the link

Real sets and tables anywhere?

2020-11-16 Thread miran
`import tables`: `import sets`:

Real sets and tables anywhere?

2020-11-16 Thread PMunch
You have bit-sets built into system, and there are hash sets in the [sets](https://nim-lang.org/docs/sets.html) module and hash tables in the [tables](https://nim-lang.org/docs/tables.html) module.

Real sets and tables anywhere?

2020-11-16 Thread HJarausch
Does Nim have a 'set' type or at least a 'table' type which can hold (be indexed by) any hashable type. E.g. how can I get a set of tuple[int, int] or table(tuple[int, int], bool) Perhaps it's not a good idea to come to Nim having a strong background in Python and C++. Thanks for a hint, Helmut

How do you deal with dependencies in Nim ?

2020-11-16 Thread Araq
> It could also be different semantics (for example different order in which > code paths are tried, or different thread safety semantics). True, but not really relevant, for quality assurance I would rely on compiler error messages and tests (!). In practice it means that bugfix updates are ri

Nim based Firmware -- it's tiny!

2020-11-16 Thread wilypomegranate
> Good question, the ESP32's use FreeRTOS which is a real time operating system > (RTOS). Nim's standard library has a freertos option now, so you can do > --os:freertos. It also configures the stdlib's network code to use LwIP which > is an embedded TCP/IP stack. What this means is that you can

How do you deal with dependencies in Nim ?

2020-11-16 Thread sschwarzer
> Now what happens when you don't use a PM? The thing compiles and works. > > And if it doesn't compile, you get a meaningful error message [...] On the other hand, it's not only about whether the code compiles. A backward-incompatible change might not lead to compile-time problems. It could al

a DSL to construct Nim AST based on karax

2020-11-16 Thread b3liever
Hi just wanted to share what I worked on the past two days. From the docs: > `buildMacro` is a DSL for convenient construction of Nim ASTs. It composes > with all of Nim's control flow constructs. Code originated from the karaxdsl and adapted to work on NimNodes. I'm very happy with the resulti

Passing iterators as arguments

2020-11-16 Thread KnorrFG
I should've posted a minimal example. So in the following example I hope everything becomes clear. Auto not working would be no problem, I could use generics, but I cant get it to work either way, so here is the code: import tables, sugar type Iterable[T] = iterator: T

Which HTTP server library?

2020-11-16 Thread enthus1ast
And here is an example of a complete app that uses prologue:

Which HTTP server library?

2020-11-16 Thread GULPF
I've been moving a small project from Jester to Prologue due to the missing middleware support in Jester and I really like it so far. The documentation is excellent and unlike Jester it doesn't rely heavily on macros.

Which HTTP server library?

2020-11-16 Thread jackhftang
wanted to know what HTTP server there was out there with a rather complete implementation Run [Prologue](https://github.com/planety/Prologue) should be a rather complete implementation of a HTTP server and the most [featureful](https://planety.github.io/prologue/) one written in

Which HTTP server library?

2020-11-16 Thread mildred
Looking at there are plenty of packages, but it seems only a limited number are web server libraries: * httpkit: does not even manages the transport layer * microasynchttpserver: does not seems featureful enough (cookies, form-data, ...) * httpb

Passing iterators as arguments

2020-11-16 Thread Sixte
> which yields the error: Error: redefinition of 'iter'; previous declaration > here: ... where did the name 'iter' come from ? The other solution: if a template gives back an 'it' , the 'it' is in scope then as a value (it's a closure) and indeed, a redefinition is not possible.