Iterators dont inline

2024-06-23 Thread 4n0n4me
{ { NI i; NI res; i = (NI)0; res = ((NI)1); { while (1) {

get object field by variable

2024-05-05 Thread 4n0n4me
it's possible like this (not tested) proc `[]`(obj: JsObject, key: string): ??? {.importjs: "#[#]".} Run but you don't know the return type

Can’t wrap my head around this TypeError

2024-04-25 Thread 4n0n4me
I think maybe `ref` types can't be evaluated at compile time, so they can't be `const` s.

Nim's equivalent of kwargs

2024-04-10 Thread 4n0n4me
I am so sad that I forgot std/json

Nim's equivalent of kwargs

2024-04-09 Thread 4n0n4me
I don't think there is kwargs in Nim. It may be possible to implement similar things with macros. You can also just do import std/tables proc foo(a: int, b: string, kwds: seq[(string, string)] = @[]) = let kwdTable = kwds.toTable echo kwds, kwdTable foo(

How to use dynamic dispatch with inheritance without converting to the appropriate subtype by hand?

2024-04-01 Thread 4n0n4me
error message says: (line numbers are not the same as in your code) /usercode/in.nim(21, 8) Warning: use {.base.} for base methods; baseless methods are deprecated [UseBase] /usercode/in.nim(24, 8) Warning: use {.base.} for base methods; baseless methods are deprecated [UseBase]

How do you handle incomplete nimble packages?

2024-03-25 Thread 4n0n4me
I think this is simply the problem of a ecosystem which is not big enough. If with Nim you can't do this thing, you need to implement it, or use another language. When Rust was 0.2.0(some random early version number), people in Rust also didn't have enough _good_ libraries to use. (Sorry as a ho

List of GC'ed types

2024-03-25 Thread 4n0n4me
I am not familiar with these things, but I think when you pass a closure to a function as a callback, you pass the "environment" together with the function pointer which points to some code in code segment. I guess that's why closures are GC'ed.

JS bindings question - Quill

2024-03-25 Thread 4n0n4me
I think this happens because getLine returns a js array and a js array is not the same as a Nim tuple, the latter is like `{Field0: ..., Field1: ...}` in js as I tested. maybe you need to change the structure of the return value to fit a Nim tuple with js inside the importcpp.

HTTP/2 Support?

2024-01-29 Thread 4n0n4me
Any libraries for HTTP/2 client or server? For now I know [curly](https://github.com/guzba/curly)

Why is "end" a reserved keyword?

2023-12-04 Thread 4n0n4me
I have heard that [code filters](https://nim-lang.org/docs/filters.html) also uses `end`.

Is Nim Dead?

2023-11-25 Thread 4n0n4me
Why! Will you say V is dead?

proc/func/method: syntax

2023-11-16 Thread 4n0n4me
Nim is now 2.0.0. And communities have been loving 'opinionated' softwares for a long time: for example, Black the python formatter, and Rails. I think most people won't accept the possibility of this change, for it not only breaks the Nim way, but also breaks all written code.

Array of type "proc" except I don't know what I'm doing

2023-11-04 Thread 4n0n4me
`proc `$`(x: proc): string = $typeof(x) & " = ..." ` Run

Alternative to powmod in Nim

2023-10-21 Thread 4n0n4me
Amazing! As a normal Nim learner, I am grateful to you for your responsibly making highly completed libraries for Nim. (not those which provide naive solutions without covering edge cases or seeking high performance.)

Using Result library

2023-09-21 Thread 4n0n4me
I think it is unlikely to find other solutions (there are indeed other means to do it, but I think all of them work in similar ways as the Results lib), since Nim is a very strong typed language. You can also use `throw newException(...)` to throw exceptions, but I guess it is not what you want.

Need help writing a helper function?

2023-09-21 Thread 4n0n4me
Actually I think there are not really such solutions. However, if you use Editor support, for example the VSCode extension by nimseam, you can type `"string".` and see all methods available in the Editor completement. As far as I know, this is powered by the tool nimsuggest under the hook.

Improving Examples and Documentation

2023-09-14 Thread 4n0n4me
I think the websites of projects like Vue, Flask, FastAPI, or httpx shows the ideal document amount of libraries like karax, jester, etc. When a Nim library is fairly popular, it should be slowly promoted to get as well-documented as those projects.

Nimble newbie issue

2023-09-09 Thread 4n0n4me
The document seems to imply that you need to import one of db_mysql, db_odbc, db_sqlite, db_postgres:

Can I use Nim with GPU Computing?

2023-08-05 Thread 4n0n4me
I am not familiar with CUDA or OpenCL. I don't use them by programming in C, instead, with Python packages, only what I need to do is to install CUDA. I am trying to brute SHA-512 with Nim. At first, official package `checksums`, but I find it very slow. is mu

How can I know whether an untyped argument of a template can be stringified?

2023-04-14 Thread 4n0n4me
Well, I find something in . I make mine like this: proc isStringifyableImpl[T](body: T): bool = type Helper = concept proc `$`(x: T): string result = body is Helper template isStringifyable(body: untyped): boo

How can I know whether an untyped argument of a template can be stringified?

2023-04-14 Thread 4n0n4me
I try to do this: template eval(body: untyped) = let res = body if isStringifyable(res): echo res else: discard Run I have known `typeinfo` in stdlib or `concept` may be helpful, but failed to use them successfully. I find no documenta