nim-lang Questions

2

Solved

I'm just discovering Nimrod and have a basic question (couldn't find the answer in the documentation). How do you use bitwise operations ? I have the following code, where x is defined as an int :...
Lightning asked 1/11, 2013 at 16:58

1

Solved

I keep reading that Nim's memory management is optional, but documenttion seems to be thin on this, the only resources I have found relate mostly to FFI to C, and https://nim-lang.org/docs/gc.html ...
Ambulatory asked 28/6, 2019 at 18:20

1

Solved

If I press Ctrl-C while my program is running it exits and prints SIGINT: Interrupted by Ctrl-C. How do I ignore the Ctrl-C interrupt in Nim on Linux? Thanks in advance.
Dyandyana asked 15/2, 2019 at 16:18

2

Solved

I am trying to do some very basic string formatting and I got immediately stuck. What is wrong with this code? import strutils import parseopt2 for kind, key, val in getopt(): echo "$1 $2 $3" %...
Idzik asked 27/2, 2017 at 11:7

3

Solved

I followed the docs and compiled with nim compileToC helloworld.nim but it just spit out an executable. How can I see the intermediate C representation?
Kamat asked 30/4, 2015 at 0:21

5

Solved

I'm trying to emulate in C++ a distinct type from the Nim programming language. The following example won't compile in Nim because the compiler catches the variables e and d having different types ...
Damalis asked 18/5, 2014 at 19:33

3

How would i read from the stdin via nimscript? i've tried: if readLine(stdin) == "yes": exec buildCommand i've run the script with nim c build.nims i receive build.nims(50, 13) Error: u...
Crossstaff asked 19/3, 2016 at 15:15

1

Solved

In Nim, I have a string that I need to split into characters, but each character should be converted to a string. Right now I have something like: var d = initTable[string,int]() for ch in line:...
Parous asked 2/12, 2018 at 11:56

1

Solved

Is there any constant variable or proc that allows to access the compiler version as a string or number?
Accomplishment asked 9/10, 2018 at 18:9

3

Solved

I'm in a situation where I have a seq[char], like so: import sequtils var s: seq[char] = toSeq("abc".items) What's the best way to convert s back into a string (i.e. "abc")? Stringifying with $ ...
Expensive asked 19/8, 2015 at 11:43

1

Solved

In Nim, to write code that executes as a sort of main function, you do (similar to the is main checks in Python): when isMainModule: echo ("Hello, Nim!") However, for the life of me, I can't fi...
Don asked 21/8, 2018 at 13:17

2

Solved

I am trying to write a macro for debug print in the Nim language. Currently this macro adds filename andline to the output by instantiationInfo(). import macros macro debugPrint(msg: untyped): ty...
Incoming asked 8/2, 2018 at 13:28

3

I'm currently creating a programing language written in Nim. The front-end of the compiler is done, I'm currently sitting in front of a well-built Abstract Syntax Tree (AST) and I tried implementi...
Allotropy asked 19/6, 2018 at 22:44

3

Solved

I would like to use Nim in a soft-realtime context, where both memory allocation and garbage collection exhibit too much latency. Therefore, manual memory management is desirable- or, even better, ...

2

Solved

Let's say I have a procedure getTuple(): (int, int, int). How do I iterate over the returned tuple? It doesn't look like items is defined for tuple, so I can't do for i in getTuple(). I initially ...
Ignaz asked 13/2, 2018 at 8:44

1

I want to concatenate string and int. But it doesn't work with & and add operator. echo "abc" & 2 But it doesn't work.
Skyward asked 29/1, 2018 at 10:14

1

Solved

Can I convert a tuple into a list of function arguments in Nim? In other languages this is known as "splat" or "apply". For example: proc foo(x: int, y: int) = echo("Yes you can!") type: Point ...
Ambrosio asked 24/1, 2018 at 8:57

3

Solved

The problem I want to allocate memory in one thread, and safely "lend" the pointer to another thread so it can read that memory. I'm using a high level language that translates to C. The high lev...
Deckert asked 3/11, 2017 at 7:41

1

Solved

I am a newer to Nim programing language. when I use Python, I can use the 'pass' to skip the defination detail of a function and class. def foo(): pass # skip detail class Bar(): pass Is ther...
Neace asked 16/1, 2018 at 13:22

1

Solved

Learning Nim and I like it resemblence of Python (but fast). In Python I can do this: item_index = [(idx, itm) for idx, itm in enumerate(row)] Im looking for a way to enumerate a Nim sequence so...
Helenhelena asked 5/1, 2018 at 20:20

1

Solved

From the docs, I know that Nim arrays have a fixed length determined at compile time, whereas seqs have a variable length. I notice that seqs have more builtin tools. For example, in the sequtils ...
Televisor asked 10/12, 2017 at 13:50

1

Solved

Is there a way in Nim to define constructors for an object? For example I have type Deck* = ref object cards* : array[52, Card] can I create an empty constructor that creates automatically all ...
Mutualize asked 17/10, 2017 at 21:57

3

Solved

I'm trying to make up my mind about Nim's policy behind expression has no address. In particular, I have a C function which takes a pointer (+ length etc.) of some data buffer. I know that this fun...
Merous asked 8/5, 2015 at 20:46

2

I'm new to the language. When trying to compile a new object type with a method (where the first argument is an instance of my new type), the compiler warned me like this: Warning: use {.base.} fo...
Rilke asked 13/3, 2017 at 1:12

1

Solved

The question is Nim language specific. I am looking for a standard to way to convert integer/string into enum in a type safe way. Converting from enum to integer/string is easy using ord() and $(),...
Pedal asked 23/3, 2017 at 13:30

© 2022 - 2024 — McMap. All rights reserved.