681
questions
0
votes
1
answer
31
views
File exists exception message
I've only recently gotten into Nim and wanted to write a small script that would recursively walk through a directory, copy the files to a different location and then rename them (the files are ...
0
votes
0
answers
46
views
Nim lang LSP Extension for VSCode Broken?
I haven't touched Nim for 2 years now and I wanted to get back into it, but while setting up the LSP server for Nim, I ran into a problem. It seems like Nimsuggest crashes without a reason. I tried ...
1
vote
1
answer
76
views
How do I read all keys pressed in nim since the last call to a function, without needing to press enter
I need to read keys from stdin without blocking, and without only recieving them when a newline is pressed. The way i would like it be formatted is a sequence, where each item is a keypress or ascii ...
1
vote
1
answer
80
views
strings as functions during parsing
TL;DR
Given: sequence of Token and Grammar
Where:
Token := tuple[name:string, value:string, parent:Token]
Grammar := Table[system.string, proc(x:Token):string]
Return: string of token values ...
0
votes
0
answers
125
views
Use openssl and RSA encryption in nim
I want to use openssl for RSA encryption in nim however pointer types in nim are causing me problems. Currently I have this code:
import openssl
var publicRsa: PRSA
var privateRsa: PRSA
let ...
0
votes
0
answers
31
views
How to serve acme-challenge file dynamically with Jester REST API?
Is it possible to dynamically serve the acme challenge file generated and required by certbot with rest api by jester with nim lang?
I have this code
get "/.well-known/acme-challenge/@challenge&...
0
votes
1
answer
216
views
Flake fails on update, nimPackages is missing, where has it gone?
A while back, I had a flake.nix which worked:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
...
0
votes
2
answers
177
views
What are the types of arrays with variable size and accommodating different types in Nim?
Nim is my second language after Python. Python has a universal array type, the "list" type. It has a changeable size and can accommodate any type. I am currently sorting out and studying Nim ...
1
vote
1
answer
257
views
What are the main ways to do a reverse iteration in Nim?
I'm learning Python. I recently learned about Nim and began to study it too. I liked the python+pascal syntax and the speed of C. Unfortunately, there is much less educational information and ...
1
vote
1
answer
207
views
How to fix this error : simple run error with the library faster_than_requests
here is my simple code with the faster_than_requests library :
import faster_than_requests as requests
t = requests.get("http://httpbin.org/get")
print(t)
As you can see the code is not ...
3
votes
1
answer
141
views
Why isn't the order of a sequence kept in nim when deleting an element?
I am trying out nim and struggling with a strange behaviour while working with sequences.
If i run this code:
var
hobbies = @["Coding", "Creating", "Sports"]
echo ...
1
vote
2
answers
344
views
lldb in vscode: how to show string values on hover?
I'm debugging a C app in VS Code on Mac OS (arm64).
I can set breakpoints and see stacktraces. However, for variables, memory addresses are shown instead of values. The variable I want to inspect is ...
0
votes
1
answer
113
views
Is it possible to globally modify the AST in Nim?
In Haxe, it's possible to iterate through and modify a project's entire AST prior to typing using @:build macros. I was wondering if it was possible to do something similar with Nim?
Nim has a rich ...
0
votes
1
answer
76
views
Nim: Analog of .dirty. pragma for macros
I am trying to write a macro which, among other things, gives a forward definition to a procedure which will be defined outside of the macro. However, I am getting a error. (This is similar to the ...
1
vote
1
answer
59
views
How to call iterator for Chipmunk 7 bindings (Nim)
I'm using the chipmunk7 library bindings, and trying to call the iterator eachShape. The bindings source is here
SpaceShapeIteratorFunc* = proc (shape: Shape; data: pointer) {.cdecl.}
## Space/body ...
0
votes
1
answer
161
views
Declare procedures prototypes in nim
I am trying understand how I can declare, in a nim source, different procedures that call each other, as it sounds like the compiler expects all calls to come after the declaration, but the procedures ...
1
vote
1
answer
58
views
Using nnkDotExpr to create an ident in Nim
I am trying to use nnkDotExpr in a macro and am getting an error. Specifically I am trying to write a macro which will write a procedure that returns a specific field. I have tried three approaches ...
1
vote
1
answer
123
views
How do I define a setter in a macro in Nim
I am trying to write a macro which will define a getter and setter for a field. The getter/setter should be called Name. However, when I define the setter the procedure name is 'Name=' and the macro ...
2
votes
1
answer
83
views
Nim program crashes when using recursivity and openarray
The following Nim program crashes and I don't understand why:
proc recursiveExplorer(s: openarray[char]) =
if s.len == 0: return
# processing(s[^1])
recursiveExplorer(s[ 0 ..< (s.len-1)...
1
vote
1
answer
96
views
Identifier construction in nim macros (instead of templates)
In nim, if I am writing a macro, how do I explicitly construct a name from an argument. Specifically in the nim manual (see here) we have the following example of "identifier construction"
...
1
vote
2
answers
104
views
In Nim, how can I define a procedure with an unspecified collection of generic parameters
I am trying to write a template to define a three procedures which are identical except in the number of generic arguments they take and the number of generic arguments of the types. Is there a way to ...
0
votes
1
answer
83
views
How to have a message from a thread-channel trigger an update in owlkettle?
After doing some research in general in owlkettle (https://github.com/can-lehmann/owlkettle) for a "client-server" architecture (see here ) I tried to figure out how to specifically write ...
0
votes
1
answer
162
views
How to set up a small client-server example between threads in nim?
For the owlkettle package (a declarative gtk wrapper) in nim I am researching how one could implement multi-threading "properly".
For that I am looking into how one would setup a client-...
0
votes
1
answer
72
views
Why is nim expecting type Ordinal instead of Board
nim 1.6.8
To compile: nim c ./myfile.nim
I've tried adding var in front of Board in parameters(but I don't need to modify Board). I've tried adding [Board] after proc name to indicate proc is for ...
2
votes
2
answers
129
views
In nim is there a way to get a list of all procedures with a given name?
In Nim is there a way to get a list of the declarations of all procedures with a given name which are defined at a given point in the code? For example I am looking for a function TYPE where following ...
0
votes
1
answer
156
views
Why is my call of a nim template not simply expanding the template code?
Working in Nim, my intuition for templates is that, at compile time, they are simply expanded into their code (with the appropriate substitutions). But the following code:
type
New_Type = ref ...
0
votes
3
answers
101
views
Nim: lambdas with void return type cause compiler crash
See this minimal example:
import sugar
type TestLambda = () -> void
type NamedTestLambda = tuple[name: string, lambda: TestLambda]
var testNil: TestLambda = () => void
var funcs: seq[...
-1
votes
1
answer
161
views
raylib nim i learn this language today i have to much problem
code
https://pastebin.pl/view/a021251b
question
I need to explain this errors while trying to fix it but I can't and I'm so tired I've been trying to fix this for 7 hours.
1 - expression '' has no ...
0
votes
3
answers
188
views
How many build options are there in Nim
When you build an app in Nim, to compile in default mode (debug), you do nim c <file>. For release mode: nim c -d:release <file>. I heard on the internet that nim c -d:danger increases ...
0
votes
3
answers
264
views
If name main check in Nim
So, If you know Python, you should be familiar with this:
def main():
<your code>
if __name__ == '__main__':
main()
That creates a main function and checks if current files is being ...
1
vote
1
answer
309
views
Is there any way to use echo and not print a new line in Nim
My code:
echo "Name: "
var input = readLine(stdin)
echo "Your name is: " + input
What I get:
Name:
<your name>
Your name is: <your name>
What I want to get (notice ...
0
votes
1
answer
115
views
How do you define a =copy hook for a distinct-cstring-type in nim?
For interacting with the GTK library I call some functions that hand me a c-string (char*) that my code owns going forward.
I want to have those strings in a custom distinct cstring type and define a =...
0
votes
1
answer
226
views
Removing Console window in Nim
I have written a program in Nim, which on execution opens a blank cmd
I found that using switches during compilation this can be removed, But I don't want to use any contemplation flags.
Means as in C ...
1
vote
1
answer
202
views
Type mismatch when setting table value
Hi im trying to do a basic example with tables:
import std/tables
let tableTest = initTable[int, string]()
tableTest[2] = "hello world"
Here is the playground link:
https://play.nim-lang....
0
votes
1
answer
137
views
How to serve a static directory with nim httpbeast?
How to serve a static directory with nim httpbeast? I am working on a project and needs to be light weight so I am using httpbeast but am unable to serve the static directory. I am able to serve ...
2
votes
1
answer
365
views
How do I execute a proc with a delay in nim?
I was looking to get a bit more into async in nim with the C-backend and have a fair bit of experience with Javascript. There functionality such as setTimeout is available to execute a function at a ...
1
vote
1
answer
65
views
Open file at compile-time [JS backend]
I'm trying open file in macro, but I got exception:
template/generic instantiation of `some` from here
Error: cannot 'importc' variable at compile time; fopen
My Nim code:
import macros
macro some():...
3
votes
1
answer
115
views
How to get all fields of an object type `MyType` in a macro from a NimNode ident("MyType")
In nim I have a macro that takes in a proc definition and generates a proc based on that and some statements.
The syntax looks like this:
type A = object
name: string
type B = object
name: string
...
1
vote
1
answer
104
views
How can I see the contents of a NimNode?
I'm using the nim programming language and am doing some metaprogramming.
I want to write a DSL of some sorts that enables generating procs. For that I want to pass some nim-code into a macro (e.g. a ...
0
votes
1
answer
197
views
Async HTTP call and json using Nim
My code:
import std/[asyncdispatch, httpclient, json]
proc asyncProc(): Future[string] {.async.} =
var client = newAsyncHttpClient()
try:
let response = await client.getContent("https://...
1
vote
1
answer
64
views
Nim - Data not being able to transfer between functions using nim prologue
I have a HTML and JS code written and is fetching data from the link '/availability-json'
<div class="col-lg-4">
<div class="room-booking">
...
1
vote
1
answer
253
views
Nim cannot install a package
Error: cannot open file: nimcuda
knowing that I already used the command
nimble install nimcuda
and installed it.
Windows
I use the command "nim c -d:release x.nim" to compile
I have tried ...
0
votes
1
answer
104
views
Problem inherit procs from another Type in Nim
I was playing around with OOP in Nim and when I tried to implement inheritance between two Nim types in different files, I encounter the following problem, when inherit a type from a different file I ...
1
vote
1
answer
112
views
What is the equivalent of Java's protected attributes in Nim?
I was playing around with OOP in Nim and when I tried to implement inheritance between two Nim types in different files, I encounter the following problem, when importing a type from other file could ...
2
votes
2
answers
166
views
Semantics of `let` assignment in Nim
Semantics of let assignment in Nim
I was recommended the Nim programming language and started reading through the Tutorial 1, the Manual and even the memory model (in particular the section about ...
0
votes
2
answers
380
views
Execution time of recursive Fibonacci function is slower in C than equivalent Nim and Pascal code
At this link there is a benchmark about a recursive Fibonacci function written in various languages. I tried some examples(specifically Nim and Pascal) and verified that the execution time was about ...
0
votes
1
answer
79
views
Can I create a thread from gc-UNsafe procedure? (Nim)
At some point in my console application I want to output an image.
While displaying the image(in a separate window) my console program should not stop,
so I would create a thread for gui and invoke ...
0
votes
1
answer
379
views
How to set up a small websocket client-server example with nim/prologue?
I am using the prologue framework of the nim programming language for my webserver and want to play around with websockets.
There is a section about websockets in the prologue docs but that mostly ...
1
vote
0
answers
107
views
Nim SDL2 no window appears
I'm trying to follow this blog post about using SDL2 with Nim.
I've set up a project with SDL2. Using nimble build or nimble run throws no errors. When the program is running no window appears.
...
1
vote
0
answers
100
views
Nim osproc.startProcess input/output out of sync
I'm using startProcess to communicate with a standalone module, but the input to and output from the module is out of sync with the calling program that catches the output.
I expect this:
Process ...