Re: New Fixed-Point Number Library

2020-06-22 Thread b3liever
I think you could possibly make `fracbits` part of the type (that would mean you will have to use generics, everywhere). Like so: `type FixedPoint[fracBits: static[int]] = objectBut`. But `static` has many bugs yet so maybe it wouldn't work, just yet.

"subsequence" type (like Go's "slice")

2020-06-22 Thread snej
As I get more fluent in Nim, the main tool I find myself missing is a lightweight reference to a range of bytes in memory — something that points to a portion of a `seq` without copying it. The closest equivalent I know of is Go's `slice[T]`, which is pretty ubiquitous — it's actually rare in

Re: Fuzz testing nim

2020-06-22 Thread neo
Thanks saves me the report!

Nim Days Chapter 21: Parser combinators and Nim

2020-06-22 Thread aredirect
Here's a new chapter for one of my earliest code in nim nim-parsec [https://xmonader.github.io/nimdays/day21_parsec.html](https://xmonader.github.io/nimdays/day21_parsec.html)

Re: Dual number type

2020-06-22 Thread whiterock
Thank you, this solves the first problem I had. I don't understand though, why it can infer N from Dual[N, T] but not T. Anyways, the problem remains that scalar multiplication should work for arbitrarily nested duals, i.e. let a = dual[2, Dual[2, float]]( dual[2,

Re: "subsequence" type (like Go's "slice")

2020-06-22 Thread snej
I'm writing code that manipulates portions of `seq``s, and I keep creating proc parameter lists that include ``input: openarray[byte]; inRange: var Slice[int]`, and then inside the proc I keep writing stuff like `input[inRange.a + i]`  I have a large C++ codebase that uses a custom `slice`

Re: Norm 2.0.0

2020-06-22 Thread Araq
Interesting. Can you outline the learned lessons?

Re: More fuzz testing

2020-06-22 Thread SolitudeSF
what's the bug?

Re: "subsequence" type (like Go's "slice")

2020-06-22 Thread bpr
> There is also openArray. It's currently restricted to parameters due to > memory safety reasons, there is an RFC to extend it. I assume you mean [this](https://github.com/nim-lang/RFCs/issues/178)? What's the status of that and the other

Re: More fuzz testing

2020-06-22 Thread neo
I would expect print first 1 3 5 7 printSeq(seq1 ,2) 1 3 Run

Re: New Fixed-Point Number Library

2020-06-22 Thread b3liever
Really nice fixed point lib, with docs, tests and a way to generate different representation, operators... It is very complete, well done!

Re: More fuzz testing

2020-06-22 Thread quetzalb
printSeq is writing to stdout itself before returning a default value empty string.

More fuzz testing

2020-06-22 Thread neo
Follows an edge case, an unexpected behaviour or a programmer's bug? let sp = ' ' let seq1 = @[1, 3, 5, 7] proc printSeq(s: seq, nprinted: int = -1) :string = var nprinted = if nprinted == -1: s.len else: min(nprinted, s.len) for i in 0 ..< nprinted:

Norm 2.0.0

2020-06-22 Thread moigagoo
Hi all! It is my great pleasure to announce Norm version 2.0.0  I've rewritten in from scratch, because the previous architecture turned out to have unsolvable issues. There's zero backward compatibility, so if you've never used Norm before, just start using the new version and don't bother

Re: Can't install the bin tarball of nim 1.2.2.

2020-06-22 Thread halloleo
Ups, sorry @araq! Totally forgot! You did mentioned this in your first reply. I'll try it.

Re: New Fixed-Point Number Library

2020-06-22 Thread lbart
Thank you for your comments! Nice idea, I'll take a look at in.

Newbie question: why do I get a "No handles or timers registered in dispatcher" error?

2020-06-22 Thread alastair
I've simplified my issues down to a simple test case where I use spawn() to run a proc that completes a future. It feels like it ought to be straightforward: import asyncdispatch import threadpool let future = newFuture[string]() let complete_future = proc

Re: Use getenv with js

2020-06-22 Thread Araq
The error message could be better, of course, but JS has no `getEnv` and Nim's JS target is **not** NodeJS.

Use getenv with js

2020-06-22 Thread vsantana
Hi everyone! when I try to compile this code into js (e.g. nim js main.nim) import os echo getEnv("USER") Run I'm getting the follow error: .choosenim/toolchains/nim-1.2.2/lib/pure/includes/osenv.nim(97, 16) Error: internal error: expr(nkBracketExpr,

New Fixed-Point Number Library

2020-06-22 Thread lbart
Hi, After having had a lot of fun learning and testing Nim, I have started working on several libraries, including one on FPN (and another on CAD/GIS geometry). [https://gitlab.com/lbartoletti/fpn](https://gitlab.com/lbartoletti/fpn) A lot of the code comes from old notes that I had

Re: Fuzz testing nim

2020-06-22 Thread SolitudeSF
compiler crashes are not expected behavior. you should report it on github.

Re: Fuzz testing nim

2020-06-22 Thread Yardanico
Duplicate of [https://github.com/nim-lang/Nim/issues/13992](https://github.com/nim-lang/Nim/issues/13992) :)

Re: Idea: Nim Online Conference

2020-06-22 Thread Araq
Once again a big "Thanks you" to every speaker, the quality of the talks were high throughout and the fact that every speaker was online during the stream and replied to questions made it even more enjoyable. Coming soon: A hackathon? How to organize one?

Re: Idea: Nim Online Conference

2020-06-22 Thread dom96
We shouldn't forget about @miran's awesome work here. Big thanks to him for all his work on scheduling, planning and organising this conference. It went incredibly smoothly, the bar has been set very high for the next conf :D

Custom HTML elements

2020-06-22 Thread LancerRevX
Is it possible to create custom html elements with Nim?

Sending emails from Nim using SMTP

2020-06-22 Thread alfrednewman
Hallo, I would like to send emails from Nim using module smtp. However, I need to include an attachment with the message. Is it possible? If so, can you pls provide a code snippet to help me out?

detectOs template in for loop

2020-06-22 Thread neo
What's the best solution for the following: import distros for distro in Distribution: if detectOs(distro): echo distro Run Error: undeclared field: 'distro' found 'distro' of kind 'forVar' Module distros source shows a Distribution.d enum is expected:

Re: Can't install the bin tarball of nim 1.2.2.

2020-06-22 Thread Araq
You can use `-d:nimEmulateOverflowChecks` for 1.2.0

Re: Can't install the bin tarball of nim 1.2.2.

2020-06-22 Thread halloleo
Thanks @shashlick. Yep. The GH issue looks like the same problem. So, this means I cannot install 1.2.2 from the normal tar ball, right? Therefore I'm back to square one: tar ball 1.2.0. installs, but gives me a compile error in the subsequent C compiler chain.

Re: Passing a sequence by reference to a data type

2020-06-22 Thread ameerwasi
Thanks, guys, I really appreciate your help, this community, and the welcoming nature of this forum.

Dual number type

2020-06-22 Thread whiterock
I am trying to implement a dual number type in NIM, but struggling with with, for me, obscure error messages. Most likely I am missing something trivial, but after having poured in more than 2 hours in trying stuff and researching I still could not figure it out. Here's the minimum not working

Re: First take: parameters

2020-06-22 Thread neo
Thanks, also another solution from the tutorial [advanced-types-varargs](https://nim-lang.org/docs/tut1.html#advanced-types-varargs) proc lfecho(data: varargs[string ,`$`]) = write(stdout, "\L") for s in items(data): write(stdout, s) Run

Re: How to get & set text in clipboard ?

2020-06-22 Thread Trustable
You could have a look at the WinAPI clipboard implementation of NiGui: [https://github.com/trustable-code/NiGui/blob/master/src/nigui/private/windows/platform_impl.nim#L421](https://github.com/trustable-code/NiGui/blob/master/src/nigui/private/windows/platform_impl.nim#L421)

Re: detectOs template in for loop

2020-06-22 Thread neo
Thanks for the workaround. As an aside, it turns out for distro in Distribution: if detectOsImpl(distro): echo distro Run outputs two strings: Posix Linux Run The macro ouputs the first. What is the benefit of only accessing

Re: Dual number type

2020-06-22 Thread jyapayne
If you want just scalar, you can change the definition of `T` in this case to: # scalar multiplication proc `*`*[N: static[int]; T: SomeFloat](x: T; y: Dual[N, T]): Dual[N, T] = result.real = x * y.real for i in 0..N-1: result.dual[i] = x * y.dual[i] #

Re: Dual number type

2020-06-22 Thread jyapayne
Replace `x: SomeFloat;` with `x: T;` in your multiplication proc definition. The nim compiler can't determine which `T` you are wanting when there are no parameters with `T` as the type, so it's telling you that with `Maybe generic arguments are missing?`.

How to debug a library with gdb on windows?

2020-06-22 Thread Shucks
So nim-gdb is working fine for me now with binaries. I can use it on VSCode aswell and it works great. finish.exe should set the NIM_GDB environment in the nim-gdb.bat if you let it setup mingw btw. I had to fix that manually. However, I've coded a simple library with nim which gets load some

Re: detectOs template in for loop

2020-06-22 Thread jyapayne
This is, unfortunately, not possible at the moment with the way the template is written. You can work around this, however, with the following macro: import macros import distros macro findOS*(): Distribution = var body = newNimNode(nnkStmtList) # Mac

Re: detectOs template in for loop

2020-06-22 Thread jyapayne
Actually, the above won't work due to the general nature of Posix and Linux. This may be better: import macros import distros macro findOS*(): Distribution = var body = newNimNode(nnkStmtList) for distro in Distribution: if distro in

Re: Termcurs

2020-06-22 Thread JPLRouge
Update and harmonization for termkey.nim, for standard use of the source generator. designer progression big update for termcurs.nim

Re: Sending emails from Nim using SMTP

2020-06-22 Thread enthus1ast
You can try to use my library: [https://github.com/enthus1ast/nimMime](https://github.com/enthus1ast/nimMime) it could be that you need to patch one or two things (pr welcome ;))

Fuzz testing nim

2020-06-22 Thread neo
var seq1: seq = @[1, 3, 5, 7] Run Error: internal error: genTypeInfo(tyNone) No stack traceback available To create a stacktrace, rerun compilation with ./koch temp c Run Is this an expected compiler behaviour?

Re: detectOs template in for loop

2020-06-22 Thread Araq
> But it's actually a tricky problem that might not be able to be solved with > an iteration of Distribution, which is probably why it's not in the stdlib. distros is for Nimble support, for nothing else. Detecting the distro is fundamentally flawed anyway, test for features, not for distros or

Re: detectOs template in for loop

2020-06-22 Thread neo
Second macro version outputs Ubuntu Run which is the correct answer!

Re: Custom HTML elements

2020-06-22 Thread geotre
Do you mean like web components? For SPAs have a look at Karax