Nim project using C++ Backend with single module using library wrapping a C library

2022-03-03 Thread Akito
Before choosing a library, I was investigating which one would fit best. I was trying to find a simple one, but the simplest I found was Hunspell. I had seen your libraries, too, well, at least I remember the suggest library, but it seemed more like a paper than anything, so I didn't get the imp

Nim project using C++ Backend with single module using library wrapping a C library

2022-03-03 Thread cblake
I don't know how much your future software vision relies upon features very specific to hunspell such as utf8/complex natural language. The top of your file says American English only. If the answer is "not much" then for more ASCII-oriented work there are a number of pure Nim spellcheck/edit di

import from url

2022-03-03 Thread awr1
This also makes it easier for Nimble to comprehend a package's dependencies. That being said, Nim already supports some interesting ways of establishing dependencies through Nim code itself (albeit from a different angle - Nimterop comes to mind). Personally, I don't see much of an advantage to

Nim project using C++ Backend with single module using library wrapping a C library

2022-03-03 Thread Akito
Thanks for the suggestion. Yes, using a dynamic library seems obvious, but I don't like adding such stuff to small Nim programs. It's too much bloat for such a slim program. After thinking about the situation, I would consider either statically linking the database module with the rest of the p

Nim project using C++ Backend with single module using library wrapping a C library

2022-03-03 Thread elcritch
One option would be to wrap and export hunspell using [Genny](https://github.com/treeform/genny) and then import it as a dynlib on the C side.

How to delete and reset runtime array ?

2022-03-03 Thread mardiyah
How to reset e.g. `var d= newSeqOfCap[ int ](70)` after so many pushes ie. d.add( ) so it'd be as if the first empty, not ever have been pushed, and then how to delete (just like `delete` on C++) it manually?

How to delete and reset runtime array ?

2022-03-03 Thread PMunch
I've already answered this in Nims live chat: And on StackExchange: Simply use `reset` or `setLen`

How to delete Nim runtime array and to delete manually?

2022-03-03 Thread mardiyah
How to reset e.g. d= newSeqOfCap[ int ](70) Run after so many pushes ie. d.add( ) so it'd be as if the first empty, not ever have been pushed, and then how to delete (just like `delete` on C++) it manually?

Performing goto in Nim

2022-03-03 Thread mratsim
Something unspeakable. "Raw" gotos that need to be structured as a case object. Note: the enum vanishes in the C backend and becomes goto Label type MyState = enum A, B, C proc stateMachine() = var state {.goto.} = A case state of A: doSomethi

Performing goto in Nim

2022-03-03 Thread coffeepot
> (undocumented) {.goto.} pragma @mratsim what does this do?

Can there be an else clause on a template (or macro)?

2022-03-03 Thread coffeepot
> We should do an "obscure feature" survey to see what we should document > better. Honestly, this would be great.

Can there be an else clause on a template (or macro)?

2022-03-03 Thread Yardanico
It is actually kind of possible even with templates with the `do`, although you can't use `else`: import std/random randomize() template customIf(body, body2: typed) = if rand(10) >= 5: body else: body2 customIf: echo "true

Nim project using C++ Backend with single module using library wrapping a C library

2022-03-03 Thread Akito
I am currently working on a project, which uses a Nim library, which is basically wrapping a `.h` file with nimterop. My project additionally wrapped a `.hxx` (C++) file the classic by the book Nim way. Now, I have the problem, that I have to compile the project with the `cpp` backend, to make

Raises tracking and no more cyclic references in `chronos`

2022-03-03 Thread arnetheduck
> sounds like a solid plan. :-) we've done this already across our entire codebase :) would start this journey for the rest of the community.

Can there be an else clause on a template (or macro)?

2022-03-03 Thread Hlaaftana
Seems to have existed since [before 0.17.0](https://github.com/nim-lang/Nim/commit/9ffaee3f8803a6fce35bf784c8870ea238747e13).

Can there be an else clause on a template (or macro)?

2022-03-03 Thread PMunch
Wait, when did this become a thing?

Can there be an else clause on a template (or macro)?

2022-03-03 Thread Hlaaftana
You can do this with a macro, yes. There have been ideas for a minor patch to implement it for templates as well. import std/[random, macros] randomize() macro customIf(body, elseBranch: untyped) = echo elseBranch.treeRepr # Else # StmtList

Can there be an else clause on a template (or macro)?

2022-03-03 Thread PMunch
Problem then is that you can't have two `customIf` after one another in the same scope because the `condition` variable would crash.

Can there be an else clause on a template (or macro)?

2022-03-03 Thread sls1005
template customIf(body: untyped): untyped = let condition {.inject.} = (rand(10) >= 5) if condition: body template otherwise(body: untyped): untyped = if not(condition): body customIf: echo "true condition" otherwise: echo "fa