Thanks.
Something akin to Delphi, Lazarus or C++ Builder, where there's WYSISWG visual
application development, where code is automatically properly generated, and
where you can add code (and edit) as needed, so that you more quickly and more
intuitively develop an application.
Hi, i'm using
let m = memfiles.open("text.txt", mode = fmRead)
Run
and try to call
let f open("another.txt")
Run
results in
Error: ambiguous call; both io.open(filename: string, mode: FileMode,
bufSize: int) [declared in
walkDirRec does recursively search all files/dirs. If you dont want to enter
some directories, I guess you need to implement your own recursive "walking"
logic with walkDir, then you can have an "exclude_dirs : seq[string]" variable
Great. In fact, I already found your macros in another thread of this forum.
Very interesting work, by the way.
Because I'd simply want the user to run `nimble install` without having to
provide additional flags when installing my package. This comes from the fact
that the user can't use the custom flags that I provide in my nimble package
before cloning the repository first. So, it's not possible to do
I am using a Makefile script for compiling Nim programs. However, RSDuck
suggested the replacement of Makefile with nimscript. I confess that I didn't
know anything about the very existence of nimscript, and I want to thank RSDuck
for drawing my attention to it. However, in nimscript, I
I dont understand what you mean, but basically it is showing you what the
`const` literally is.
You can use `macro` to make a custom `nnkCommentStmt`.
import macros
macro docustom(): auto = newCommentStmtNode("This is my custom Doc")
expandMacros: docustom()
I'm finding that `nim doc` generates ugly output for tables declared as
`const`, presumably because of the compile time expansion. To see what I mean,
run `nim doc` on the following example and compare the the way the identical
tables are displayed in the let and const sections:
I've been trying to find a memory leak. The program is processing data
retrieved over the net, uploading results to another site, and runs for days at
a time with multiple copies running at once. There is no database. After a few
days, the memory usage increases to a point then the program
why? if you need to apply configuration you should use nim.cfg or config.nims,
not override default actions.
The only problem I'm finding now is that, considering that the general
`nim.cfg` gets executed before `config.nims`, if I add the `-d:danger` flag to
`config.nims`, it doesn't actually get applied to the resulting binary, as the
behaviour for `-d:danger` is defined in `nim.cfg`. Is there a way
Hello everyone,
Is there a way to add custom compiler flags (e.g. `-d:danger`) to the `nimble
install` task? I know that I can use the `--passNim` flag on the nimble call,
but I was wondering if this could be directly abstracted from the user in the
nimble file of my package. I tried creating
That makes sense. Thank you!
import macros
macro function(x) =
var params: seq[NimNode]
expectKind x, nnkCommand
expectKind x[0], nnkPar
expectKind x[0][0], nnkExprColonExpr
params.add newIdentDefs(x[0][0][0], x[0][0][1])
expectKind x[1], nnkCommand
let f = system.open("another.txt")
Thanks, I was hoping to avoid that. But it will be a good exercise. I am also
thinking of I just call the existing find and read what I need from a temp
file. Or could I get significantly faster with implementing it myself?
`const` are compile-time evaluated by definition.
[https://nim-lang.org/docs/nims.html](https://nim-lang.org/docs/nims.html)
[https://github.com/kaushalmodi/nim_config/blob/master/config.nims](https://github.com/kaushalmodi/nim_config/blob/master/config.nims)
Check the links may have useful stuff. The syntax and all is the same, so is a
little
Use a `config.nims`.
One of the overloads of walkdir takes a Posix Glob that can be recursive and
filtering at the same time, kinda `"**/*.pyc"` or similar.
I understand what `const` does in terms of compiling a nim program, but I'm
looking for a way to deal with the ugly output of nim doc itself. I guess the
problem is that nim doc actually compiles each module rather than just parsing?
this doesnt work
what is the point of customTask that is not even defined locally, if you can
just add -p:-d:danger?
Unfortunately I have been unable to do that as mentioned in the post.
$ cat hi.nim
echo 42
$ cat hi.nims
--define:danger
$ nim c hi.nim
Hint: used config file
'/home/juan/.choosenim/toolchains/nim-1.0.2/config/nim.cfg' [Conf]
Hint: used config file '/home/juan/code/temp/hi.nims' [Conf]
Hint: [Link]
Hint: operation
you can use "when defined(nimdoc)" to do specific thing on nimdoc.
In general, compile-time tables and compile-time object variants are ugly when
printing due to how it's represented in the VM memory. Unfortunately I think
this is a hard problem.
Unfortunately, your approach doesn't work because most of the flags that
`-d:danger` activates/deactivates are set in `nim.cfg`. In fact, if you look at
the binary size of your `hi.nim` file compiled with your method and with the
standard `nim c -d:danger hi.nim`, you'll see that the latter one
Same behaviour when compiled in debug mode, and with -d:release and -d:danger?
Can you try another GC, maybe boehm?
Try to extract a minimal code sample that reproduces the bug, and share it, no
way to know without code.
I prefer a nice DSL over a "RAD" any day. (Used QtDesigner, end up doing UI
manually because code kinda sux) So I think DSL are the way to go on Nim.
I've been trying to implement Pollard's Rho algorithm
([https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm](https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm))
in Nim, using the BigNum module (which in turn uses GMP).
Up to the 6th Fermat number (18446744073709551617) it works fine.
Ok thanks for response, I was thinking about distribution as well and keeping
it simplw for end user. Anyhow I will just dig in and have a go and if I get
stuck I'll come back more specific. Cheers!
The nim tutorial that the Della-Vos group is slowly writing is here:
[https://github.com/FemtoEmacs/nimacros](https://github.com/FemtoEmacs/nimacros)
The main novelties are:
1 -- Example of nimscript, suggested by RSDuck and coded by SolitudeSF 2 --
Translation of Fibonacci's Cuniculorum
Try another GC, I know that there are (were) some leaks on small memory
allocations that were not returned to the OS.
For full debugging, compile with `--debugger:native -d:useMalloc` and pass the
program through Valgrind. That will replace all the GC calls by system malloc
and Valgrind will
Is the solution of Mr Felsing still the best and only solution?
[https://stackoverflow.com/questions/48418386/tuple-to-function-arguments-in-nim](https://stackoverflow.com/questions/48418386/tuple-to-function-arguments-in-nim)
Is so, maybe we can tune it and add it to Nim std lib?
Splat is
That's what I ended up doing, thanks.
I remember that unpackVarargs covered part of the splat needs.
[https://nim-lang.org/docs/macros.html#unpackVarargs.m%2Cuntyped%2Cvarargs%5Buntyped%5D](https://nim-lang.org/docs/macros.html#unpackVarargs.m%2Cuntyped%2Cvarargs%5Buntyped%5D)
It's in great need of documentation though.
[https://github.com/nim-lang/Nim/blob/version-1-0/lib/pure/htmlgen.nim#L314](https://github.com/nim-lang/Nim/blob/version-1-0/lib/pure/htmlgen.nim#L314)
Is this on purpose? I need it for auto-hyphenation.
I don't know how you design your chips but if you are using Verilog, be sure to
checkout this repo:
[https://github.com/kaushalmodi/nim-systemverilog-dpic](https://github.com/kaushalmodi/nim-systemverilog-dpic)
And awesome news!
Not sure if it's proper to have a 'lang' attribute on body tags, but that's a
temporary fix.
I was going to put up one of my games online anyway, so I figured I'd make it
more educational: this could be an online repository of javascript nim games
with links to the corresponding source code.
Details at [https://nimgame.online](https://nimgame.online)
If nothing else, it has two of my
Could this be because Jester uses HttpBeast in Linux and builtin server on
FreeBSD?
We need a reasonably fast multiplatform http server :/
Hi all,
I am investigating the possibility of async on embedded systems running a
realtime OS.
Since the realtime OS (such as FreeRTOS) supports task/semaphore, etc, it is
possible to have async just like Windows/Linux.
But how?
1\. asyncfutures depends on os. It is (nearly) _impossible_ to
I compared the performance of Jester on FreeBSD with that on Linux, then the
result showed req/sec of Jester on FreeBSD is 1/10 of that on Linux. I changed
kernel parameters of FreeBSD; kern.ipc.somaxconn=4096,
net.inet.icmp.icmplim=4, but the result did not change much. Load
tester(wrk)
@mratsim \- it's not just you. Formatting looks pretty garbled.
@araq \- sensible to me to duplicate/alias rather than deprecate. Pretty
low-cost.
I have few NimScript tasks which you can see in my repo's README:
[https://github.com/kaushalmodi/nim_config/blob/master/README.org#list-available-tasks](https://github.com/kaushalmodi/nim_config/blob/master/README.org#list-available-tasks)
Those tasks are defined in the config.nims in that
Are you using async await in your program?
In any case, the best way I've found to diagnose memory leaks for long-running
programs is by logging the memory usage of each object to something like
prometheus. My [prometheus package](https://github.com/dom96/prometheus) can do
that automatically
As I've mentioned in a previous post, I've been working on an interpreter
written in Nim
([https://github.com/arturo-lang/arturo)](https://github.com/arturo-lang/arturo\)).
The lexer/parser part is handled by Flex/Bison, so I'm basically interfacing
with C code (the code calls back my Nim
Nim main paradigm is structured programming, just like C. Meaning everything is
a free-standing procedure.
Assuming Nim was OOP-first we could have chosen the Python/C++ approach where
"this"/"self" is completely implicit and you don't even see it declared or
typed. Or sink into the Java
The monotimes module seems to be quite new, I wasn't aware of it.
Looking into the implementation, yes it should work OK.
Otherwise you can use [criterion](https://github.com/LemonBoy/criterion.nim)
(it's archived but pretty much finished) or [roll your own with cpuTime /
monotimes in a couple
I've sure read the documentation but I'm still unsure when these two commands
are to be used.|
I'm interfacing with flex/bison, meaning bison calls Nim routines (with the
tokens,ids,etc found), I create the appropriate AST objects and then control
goes back to Bison.
For example, Bison calls:
The issue is probably not in you algorithm but in memory management.
You are using out-of-place routines like `x = (x*x + 1) mod n`, that means an
extra allocation at each loop. F(7) is 2^128 + 1 so it does take some space and
for F(7) it seems like the GC cannot reclaim that memory. And you
You need to do 2 passes.
The first pass will lex the files and store either in memory or on disk an
array of the starting bytes of each line.
Then you divide those lines by the number of cores and process them.
Hi all,
We are a startup in China, making Bluetooth Low Energy chips. We are happy to
adopt Nim in parallel with C/C++ in our SDK([1]).
There are many benefits to use Nim instead of C.
* _Meta-programming_
> With metaprogramming, we can create advertising and GATT profile at compile
>
You're a star! So simple, but I was missing it. I did it with the in-place
routines and it worked beautifully!
No memory issues, and SUPER fast (relatively).
Here's my updated code in case somebody needs it:
proc pollardG*(n: var Int, m: Int) {.inline.} =
discard
It's very exciting to hear this anncouncement. We are Chinese Nim community
aims to promote Nim practice globally.As PMunch mentioned, these kind of
platforms using Nim are really rare by far, your production would be a great
encourage for Nim. I have send you our QQ group number of community
Very cool to see that you are supporting Nim! There aren't a whole lot of users
on these kind of platforms using Nim yet, but as you mentioned there are some
really good reasons to do it
And... without the one million ugly comments:
proc pollardG*(n: var Int, m: Int) {.inline.} =
discard mul(n,n,n)
discard add(n,n,1)
discard `mod`(n,n,m)
proc pollardRho*(n: Int): Int {.noSideEffect.} =
var x = newInt(2)
var y =
GC_ref and GC_unref are required when your Nim code needs to be responsible for
keeping track of memory, but you might end up passing things in and out of Nim
code. In general they aren't used a whole lot for regular C interop. The
important thing to keep in mind here is who is
Thank you!
I'm the maintainer of the awesome-nim and I'm so tired to maintain this repo.
Awesome-nim is now deprecated in favor of Curated Packages.
Yes, I use multiple operating systems, I am fed up with the free-standing
procedure of the c language, but I have to do this (although I can also write
oop-like code, but it is a chicken rib in c). but in nim can reflect oop-like,
such as the existence of inheritance.
But for a lot of reasons,
Hm, so you mean something along this?
var linePtr: seq[pointer]
var input = memfiles.open("file.txt", mode = fmRead)
for line in memSlices(input):
linePtr.add(line.data)
Run
and then i divide the length of linePtr by my core count. This gives me the
Good point,
Once it's indexed, you can use Nim streams and setPosition:
[https://nim-lang.org/docs/streams.html#setPosition%2CStream%2Cint](https://nim-lang.org/docs/streams.html#setPosition%2CStream%2Cint).
So you would:
1. Single threaded index the file
2. Single threaded openFile to get
64 matches
Mail list logo