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.
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
Thanks saves me the report!
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)
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,
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`
Interesting. Can you outline the learned lessons?
what's the bug?
> 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
I would expect
print first 1 3 5 7
printSeq(seq1 ,2) 1 3
Run
Really nice fixed point lib, with docs, tests and a way to generate different
representation, operators... It is very complete, well done!
printSeq is writing to stdout itself before returning a default value empty
string.
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:
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
Ups, sorry @araq! Totally forgot! You did mentioned this in your first reply.
I'll try it.
Thank you for your comments!
Nice idea, I'll take a look at in.
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
The error message could be better, of course, but JS has no `getEnv` and Nim's
JS target is **not** NodeJS.
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,
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
compiler crashes are not expected behavior. you should report it on github.
Duplicate of
[https://github.com/nim-lang/Nim/issues/13992](https://github.com/nim-lang/Nim/issues/13992)
:)
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?
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
Is it possible to create custom html elements with Nim?
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?
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:
You can use `-d:nimEmulateOverflowChecks` for 1.2.0
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.
Thanks, guys, I really appreciate your help, this community, and the welcoming
nature of this forum.
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
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
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)
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
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]
#
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?`.
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
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
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
Update and harmonization for termkey.nim, for standard use of the source
generator.
designer progression big update for termcurs.nim
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 ;))
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?
> 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
Second macro version outputs
Ubuntu
Run
which is the correct answer!
Do you mean like web components? For SPAs have a look at Karax
45 matches
Mail list logo