Questions tagged [nim-lang]

Nim (formerly known as "Nimrod") is a statically typed, imperative programming language that tries to give the programmer ultimate power without compromises on runtime efficiency. This means it focuses on compile-time mechanisms in all their various forms.

Filter by
Sorted by
Tagged with
-2 votes
0 answers
44 views

Bypassing sql protection [duplicate]

The problem requires to login into a website so that you have the flag returned. Among the assisting files for the problem we have a control.api written in nim, and a user.api written in go. The ...
Ramon Mateas's user avatar
0 votes
1 answer
30 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" ...
Nate Ackerman's user avatar
0 votes
1 answer
40 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 ...
Nate Ackerman's user avatar
0 votes
1 answer
38 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 ...
Philipp Doerner's user avatar
0 votes
1 answer
41 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-...
Philipp Doerner's user avatar
0 votes
1 answer
34 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 ...
depperm's user avatar
  • 10.7k
2 votes
2 answers
66 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 ...
Nate Ackerman's user avatar
0 votes
1 answer
50 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 ...
Nate Ackerman's user avatar
0 votes
3 answers
75 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[...
Nino van Hooff's user avatar
0 votes
0 answers
46 views

Read headers HappyX

I was intrigued to try this new framework for building APIs, but I don't understand where to find the inHeaders. In fact I had this problem also with the cookies, but then I used inCookies (had to ...
std124_lf's user avatar
  • 134
0 votes
1 answer
131 views

Opening File in Nim

I want to open a file in nim, (not for reading it's content) but for displaying it to the user There's a file on desktop, named "Licence.pdf", so i want to open it for the user so that he ...
vijay shankar's user avatar
0 votes
1 answer
80 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 ...
gnuchanos's user avatar
0 votes
3 answers
132 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 ...
Orlando Huang's user avatar
1 vote
3 answers
110 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 ...
Orlando Huang's user avatar
2 votes
1 answer
114 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 ...
Orlando Huang's user avatar
0 votes
1 answer
69 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 =...
Philipp Doerner's user avatar
0 votes
1 answer
142 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 ...
vijay shankar's user avatar
1 vote
1 answer
85 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....
Flare's user avatar
  • 83
0 votes
1 answer
85 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 ...
me0045's user avatar
  • 21
0 votes
0 answers
46 views

Nim intellisense not working properly with nim jester

Nim intellisense not working properly with nim jester as when i am hovering over any object or variable it is not showing any details there in the routes block. I tried uninstalling and reinstalling ...
me0045's user avatar
  • 21
2 votes
1 answer
139 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 ...
Philipp Doerner's user avatar
0 votes
0 answers
64 views

nim - Windows - how to check for system wide hotkey press?

My background app needs to respond to several (3 or 4) system wide hotkeys. I'm using the nim autome package (https://github.com/miere43/autome), but it doesn't respond well to the 2nd and 3rd ...
IvanS's user avatar
  • 51
1 vote
1 answer
48 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():...
Ethosa's user avatar
  • 169
3 votes
1 answer
74 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 ...
Philipp Doerner's user avatar
1 vote
1 answer
48 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 ...
Philipp Doerner's user avatar
0 votes
1 answer
92 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://...
jwesonga's user avatar
  • 4,289
1 vote
1 answer
56 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"> ...
me0045's user avatar
  • 21
1 vote
1 answer
84 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 ...
Jim's user avatar
  • 13
1 vote
1 answer
126 views

Component Constructors In HappyX

It possible to create custom component constructor in happyx web framework? For example: component A: field: int constructor(args): ...
Emilia Qtless's user avatar
1 vote
1 answer
75 views

Send file in HappyX

Can I send file from server to client in HappyX web framework? I have this project structure: test/ -- assets/ -- someImage.png -- main.nim How I can send someImage.png to client at route /raw/...
Emilia Qtless's user avatar
0 votes
1 answer
64 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 ...
epilif3sotnas's user avatar
1 vote
1 answer
87 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 ...
epilif3sotnas's user avatar
2 votes
2 answers
81 views

Translation in Happyx

Can I translate strings in happyx web framework? For example ... get "/": if lang == "en": return "Hello, world!" else: return "Bye" Now I'm trying ...
Emilia Qtless's user avatar
2 votes
2 answers
137 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 ...
Federico's user avatar
  • 582
1 vote
1 answer
117 views

Handling JSON body in HappyX

How I can handle JSON body in HappyX web framework? I have this code import happyx serve "127.0.0.1", 5000: post "/messages.send": # here I want to handle JSON I want to ...
Emilia Qtless's user avatar
0 votes
2 answers
275 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 ...
amateur's user avatar
  • 37
0 votes
1 answer
60 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 ...
lshlsh's user avatar
  • 1
0 votes
1 answer
211 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 ...
Philipp Doerner's user avatar
1 vote
0 answers
88 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. ...
Lex's user avatar
  • 4,789
1 vote
0 answers
73 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 ...
IvanS's user avatar
  • 51
1 vote
1 answer
134 views

Nim websocket client using threads instead of async

Is there a possibility to use websockets in nim with threads instead of async - or handle input- and output streams with async instead of threads? I try to redirect the input and output streams of a ...
bugninja's user avatar
2 votes
2 answers
84 views

black_box analogue in Nim

I've been trying to benchmark a function, but the C compiler optimizes the unused variable with placeholder syntax out: let start = getTime() let _ = fn(x) let elapsed = inNanoseconds(getTime() - ...
Miiao's user avatar
  • 842
1 vote
0 answers
82 views

How to make this pipe communication non-blocking?

I've created 2 small programs to test inter-program communication. It works as expected, but I want to make it non-blocking. Like it is now if either the server (main) program or the client is ...
IvanS's user avatar
  • 51
0 votes
1 answer
180 views

How to write/read binary data (in type) in Nim?

Assume I've got this data type: type TODO* = tuple atTime: float item: string type TestData* = tuple timeAdded: float who: string todo: seq[TODO] isDone: bool var data: ...
IvanS's user avatar
  • 51
2 votes
1 answer
102 views

How to print Nim's AST at runtime?

dumpTree and similar macros print Nim's AST at compile time. I was wondering how to print the same content at runtime. The use case is to be able to capture the output to document it in a nimib ...
pietroppeter's user avatar
  • 1,443
3 votes
0 answers
128 views

Trying to create a Nim-Nim dll, to be able to work with plugins, but tests keep crashing

Creating a Nim only dll is hardly documented. I'm creating an addon for a simulator (3rd party) with plugins based on the spacecraft being flown. Every 'spacecraft' module would only have 3 ...
IvanS's user avatar
  • 51
1 vote
1 answer
97 views

How to run (not ignore) runnableExamples in nim

In nim, how do you get runnableExamples to be run instead of ignored? That documentation reveals: In normal debug and release builds code within a runnableExamples section is ignored. A normal debug ...
still_dreaming_1's user avatar
0 votes
1 answer
280 views

What c compiler does nim use to make exe file?

Should I install gcc or other c compiler after installing nim to compile my code to an executable file or it contains? If it contains, which c compiler it uses? gcc, tcc, clang etc. Don't get me wrong,...
Ovqou's user avatar
  • 3
0 votes
2 answers
106 views

Nim Lang - Finding char index

I appreciate this is a very newbie question, I just came across Nim 2 days ago and thought I'd give it some investigation. but I'm not finding the documentation to be very intuitive. I have used the ...
Bor's user avatar
  • 3
1 vote
1 answer
100 views

How can you get the sizeof an untyped type identifier, inside a macro?

More than willing to accept that this is an X:Y problem. here's the context: I'm building a helper macro that parses a DSL of the form: type FieldDescription[T; bitrange: static Slice[int]] = ...
shirleyquirk's user avatar
  • 1,558

1
2 3 4 5
14