Square brackets for generics

2020-11-15 Thread AmjadBHD
why not use `a[:T]` instead of `a!T`, it's closer to the current syntax.

How do you deal with dependencies in Nim ?

2020-11-15 Thread Araq
> Why do you think that? Because more often than not it's caused by semver, not by "incompatible" library versions. For example: Say you have libraries A, B, C. A seeks to depend on B and C v1.0. B depends on C v2.0 but only because when B was written C was at v2.0 and we strive to support up-

Passing iterators as arguments

2020-11-15 Thread KnorrFG
Originally I used araqs code, that produced the `Error: redefinition of 'it'; previous declaration here: ...` error, when I called it 2 times in the same function. Then I tried to fix that by making the iterator anonymous, so there would be no symbol that could collide with itself. This then pro

Possible usage of Nim & Z3 for embedded?

2020-11-15 Thread elcritch
> Ada/Spark OTH is a route that will serve us well for orientation. That makes sense. The given 'sort' example in DrNim seems to be a useful approach. I'm still only partly sure how it could be used for larger projects. If Nim's DrNim annotations could be made to have similar power/usage as Ada

How do you deal with dependencies in Nim ?

2020-11-15 Thread jackhftang
I hear about nix, but I don't have experience with it. How can it solve dependency problem in Nim?

How do you deal with dependencies in Nim ?

2020-11-15 Thread jackhftang
@Araq allowing duplicated libraries is terrible Run Why do you think that? >From experience in nodejs, even though allowing co-existence of multiple >version of a package will result in bloated node_modules for large >applications, there is no more dependency hell issue.

Creating unique ID from strings

2020-11-15 Thread cblake
I agree that [Blake3](https://www.infoq.com/news/2020/01/blake3-fast-crypto-hash/) is a choice that balances @stbalbach's needs well. It may not be even 2x slower than murmur or xxhash (for large inputs) and drastically more collision resistant both with a 256-bit output and because it is tryin

Creating unique ID from strings

2020-11-15 Thread slonik_az
There is already `BLAKE3` which is several times faster than `BLAKE2`

Deprecated operators for DateTime private members

2020-11-15 Thread sekao
> In fact, most bugfixes are a potential breaking change, when people start > relying on the bug. I'm ok with breaking changes to fix bugs -- especially security / correctness related bugs -- but this is not an example of that. Removing a footgun is admirable, but can be done without breaking e

Which HTTP server library?

2020-11-15 Thread spip
You could start looking [there](https://github.com/nim-lang/Nim/wiki/Curated-Packages#web) and then extend your search to Nimble packages...

Possible usage of Nim & Z3 for embedded?

2020-11-15 Thread moerm
Frama-C is a PITA both in terms of building/installing and usage (beyond ridiculously minimal usage). ZZ is hardly alpha and largely written in Rust and C++ (a big minus) and seems to be (yet?) undecided which formal route to go (e.g. symb. exec. vs solver). About the only property I like is tha

How do you deal with dependencies in Nim ?

2020-11-15 Thread timothee
> But I also think Rust/Cargo's solution of allowing duplicated libraries is > terrible, so I'm not looking forward to the day where Nimble supports this > scenario relevant discussion where I advise against copying fusion sources into nim, causing duplicate packages:

Deprecated operators for DateTime private members

2020-11-15 Thread timothee
Not all breaking changes are equally hurting and I disagree that you should strive for 0 breaking changes. In fact, most bugfixes are a potential breaking change, when people start relying on the bug. Breaking changes suck and should be avoided whenever reasonable but shooting for 0 or near 0 b

Passing iterators as arguments

2020-11-15 Thread slonik_az
@Araq's code has an extra `it` as a return of template. Your code above is missing it. template toFirstClassIter(x): untyped = iterator it(): auto {.closure.} = for y in x: yield y it Run

How do you deal with dependencies in Nim ?

2020-11-15 Thread slonik_az
Nix package manager / is trying to offer a general and universal solution for dependency hell and reproducible builds.

Creating unique ID from strings

2020-11-15 Thread snej
A cryptographic hash would be safer, because in those it’s a requirement that it’s effectively impossible to find two strings with the same hash. In other hashes that’s _[desirable](https://forum.nim-lang.org/postActivity.xml#desirable) but not required, because hash tables can handle duplicate

Kill thread?

2020-11-15 Thread snej
In general, killing threads is considered a bad idea. The problem is that the thread stops at some arbitrary point and can’t clean up things like locks or file descriptors or whatever. If you work around this by making the thread raise an uncatchable exception, so that stack unwinding can clean

out of memory

2020-11-15 Thread kobi
Another question: My program exits with an "out of memory" failure. I'm on linux, and I have ~ 8gb of ram on this computer. The program is parsing files in a directory, collecting all this info in a tree, and then generating from this tree. Now, the current folder is pretty big, almost 36,000 fi

ANN: NimDBX, a super-fast persistent key-value store

2020-11-15 Thread snej
I’ve got some C++ code that extends libmdbx further, adding value properties (JSON-like), indexes and querying. But I’m trying to wean myself off C++, and NimDBX is a first step.

ANN: NimDBX, a super-fast persistent key-value store

2020-11-15 Thread snej
Yeah, the cursor and put modes in all those dbm-derived APIs are very confusing! I plan to add more idiomatic sugar to the Cursor class to make it easier to use.

is there a way to combine types?

2020-11-15 Thread exelotl
Note: a problem with solutions that copy the fields into the type, is that they don't let you use type `ABCombined` in a place where `A` or `B` is expected. This means you lose one of the main advantages of composition / inheritance. This is why I opted for a solution that keeps the sub types as

muk - a crossplattform terminal music and video player.

2020-11-15 Thread kobi
so cool

is there a way to combine types?

2020-11-15 Thread PMunch
Made a slightly prettier version that is pretty much exactly what you wanted: nim import macros macro `+`(x, y: typedesc): untyped = result = nnkStmtListType.newTree(getImpl(x)[2]) for def in getImpl(y)[2][2]: result[0][2].add def type

is there a way to combine types?

2020-11-15 Thread PMunch
Something like this works, not the prettiest in the world though: import macros type A = object a: int B = object b: int macro combine(name: untyped, x, y: typed): untyped = result = nnkTypeSection.newTree(nnkTypeDef.newTree(name, ne

is there a way to combine types?

2020-11-15 Thread kobi
You guys are amazing! :-)

is there a way to combine types?

2020-11-15 Thread Vindaar
Well, already plenty of answers around haha. Here's mine that is pretty close to @PMunch's, but tries to make it look a bit more like something in a type section: import macros macro unionType(types: varargs[typed], sec: untyped): untyped = var typ = nnkRecList.newTre

Which HTTP server library?

2020-11-15 Thread mildred
Hello, For my nimnews package, I wanted to know what were the best HTTP server library options I had. For the moment, I'm using Jester but I'm not making use of the framework part at all as I prefer to split my code in procedure and not having to write all by handlers in the same place. For th

is there a way to combine types?

2020-11-15 Thread exelotl
Indeed, here's a macro I made to do this! Example: type Vec2 = object x, y: float Player = object position: Vec2 compose Player, position var p: Player p.y += 20

is there a way to combine types?

2020-11-15 Thread kobi
Is there a way to structurally get all the fields from several types into a new type? something like a shallow inheritance? type A = object a:int type B = object b:int type ABCombined = A + B # imagined syntax let abc

is there a way to combine types?

2020-11-15 Thread Recruit_main707
I am pretty sure there isnt (99%)

Passing iterators as arguments

2020-11-15 Thread KnorrFG
It might be strange to ask this now, after the thread derailed a little, BUT: Araqs solution to my question worked until now. I tried to call that template a 2nd time2 lines later, which yields to the error: ` Error: redefinition of 'iter'; previous declaration here: ...`

How do you deal with dependencies in Nim ?

2020-11-15 Thread Araq
> It seems it is impossible to co-exist multiple version of packages so far, > but I could be wrong. I know of no good solution either. But I also think Rust/Cargo's solution of allowing duplicated libraries is terrible, so I'm not looking forward to the day where Nimble supports this scenario.

Passing iterators as arguments

2020-11-15 Thread KnorrFG
It might be strange to ask this now, after the thread derailed a little, BUT: Araqs solution to my question worked until now. I tried to call that template a 2nd time2 lines later, which yields to the error: ` Error: redefinition of 'iter'; previous declaration here: ...` I tried to return it as

ANN: NimDBX, a super-fast persistent key-value store

2020-11-15 Thread ITwrx
This is great. I was trying to use nim-lmdb, but couldn't figure out how to use the cursor. I'm looking forward to using this to remove the db query caching code and db server dependency required with my current web stack, as well as having the performance improvement. These types of "building b

How do you deal with dependencies in Nim ?

2020-11-15 Thread jackhftang
A short description of the problem: 1. package A requires package B == 0.2.0 and package C == 0.2.0 2. package B requires package C == 0.1.0 And then when compiling package A, an error occurs saying that `Error: Cannot satisfy the dependency on C 0.1.0 and C 0.2.0` This is problematic if

ANN: NimDBX, a super-fast persistent key-value store

2020-11-15 Thread jasonfi
Good idea. I was writing a key-value DB in C++ before I knew about Nim. I was also gradually adding features to add a relational model. I spent a lot of time tracking down memory bugs, so Nim is the perfect replacement.

Life is nice...

2020-11-15 Thread cblake
Recent discussion here:

Life is nice...

2020-11-15 Thread xigoi
Interestingly, Rustaceans and others like to use this “ambiguity” as an argument against using `[]` for generics.