2 questions on json mudule

2022-01-03 Thread PMunch
The answer to this question is the same as the answer to the first question. Use the `kind` attribute of your `JsonNode` to see what kind of `JSON` node it is.

Anyone written an Android app using Nim-generated Native code lately?

2022-01-03 Thread GordonBGood
Almost two years ago I had the process of writing Android apps using native C code generated by the Nim compiler pretty much worked out as per [this thread](https://forum.nim-lang.org/t/6045#37387) and [a simple GitHub repo using those techniques](https://github.com/GordonBGood/NimHelloJNI) plus

nbindgen - calling rust code from nim

2022-01-03 Thread arnetheduck
If you're looking for an example, we are using it in Waku - we build a library with the rust code, then import it to nim. * the rust code is built from our `Makefile` using `cargo` \- the makefile also builds the Nim code so as to get the dependency management right (we don't use nimble):

2 questions on json mudule

2022-01-03 Thread oyster
1st question for the code, I expected the latter output is 21 HELLO Run however, the real one is 21 20 HELLO 20 Run why `20` appears? the code import strUtils import json var a = %*[1, "he

2 questions on json mudule

2022-01-03 Thread Hlaaftana
`i.getInt() is int` checks the type of the expression `i.getInt()` and checks if it matches `int`, so this condition is always true. You want `i.kind == JInt` and `i.kind == JString`. [json docs](https://nim-lang.org/docs/json.html)

2 questions on json mudule

2022-01-03 Thread oyster
the 2nd question is, can we get the underground value of JsonNode? so that I can do for i in a.getUnderGround(): if i is int: echo (i + 20) if i is string: echo i.toUpper Run I asked so question, because I met a C# code which I

Why does 'string' and 'len' use 'int' rather than 'uint' for length?

2022-01-03 Thread demotomohiro
With a few code change like `for (size_t i = size - 1; i < size; i--)` to `for (size_t i = size - 1; i < size; i-=2)` it become infinite loop when size == size_t.high. Because when `i` wraparound from 0 to 0xfffe, this loop still continues because `0xfffe < 0x` is true. Here is

`getTypeImpl` bug?

2022-01-03 Thread geekrelief
Ok, I think I get it. The confusing part is how `t` and `res` are both nnkSym `Vec4f`, but a `getTypeImpl` print out different things. It seems like `res`, since it comes out of a BracketExpr typedesc, carries some hidden info that it's actually a type.

A rant about Nim bugs

2022-01-03 Thread deech
"One language to rule them all" is pretty unrealistic. I did a talk on where I think Nim specifically would shine (. I echo OP's experience with bugs or at least surprising behavior and unfortunate limitations in type inference that make, eg. `Option` difficult to

`Result` update

2022-01-03 Thread chancyk
@moigagoo `Result` (sometimes also called `Maybe`) is a type system convention that behaves a bit like exceptions in that there's a correct path and an error path, except you're usually forced to handle it at compile time at the call site instead of the exception bubbling up if it's unhandled.

nbindgen - calling rust code from nim

2022-01-03 Thread marcomq
Great project didn't had time to look for this yet. Is there some recommended way to use rust in a nim library, maybe in some nimble package? I was thinking about wrapping a rust library (wry) to nim. I guess you would need to install rust first, maybe add it as package dependency in the .nimbl

`getTypeImpl` bug?

2022-01-03 Thread planetis
I don't think it's a bug. `t` is a `typedesc[Vec4f]` and that's what you see. Note the difference in with the macros entry. You are using a type but the [docs](https://nim-lang.github.io/Nim/macros.html#getTypeImpl%2CNimNode) use a variable.

`getTypeImpl` bug?

2022-01-03 Thread geekrelief
import macros type Vec[N: static[int], T] = object arr: array[N, T] Vec4[T] = Vec[4, T] Vec4f = Vec4[float32] var a: Vec4f macro test(t: typed) = echo t.treeRepr var res = t.getTypeIm

`Result` update

2022-01-03 Thread arnetheduck
> IMHO the way Nim does it does work reasonably well what works reasonably well really depends more on the problem than the language and the team - ie across the board for the data we've looked at, Nim code that uses exceptions has more issues with resource leaks and unhandled edge conditions t

`Result` update

2022-01-03 Thread arnetheduck
> The application does "panic" though panic = crash? I mean... > not if you manage to wrap your requests/whatever in a try..except block. over/underflow = Defect = doesn't work with try/except

good real life apps

2022-01-03 Thread planetis
Nitter comes to mind

good real life apps

2022-01-03 Thread cmc
Sure, try pakku, a user-repository package manager for Arch Linux, for a command line app.

`Result` update

2022-01-03 Thread Araq
1. The application does not "crash", not if you manage to wrap your requests/whatever in a try..except block. The application does "panic" though and there are no widely used newer programming languages that got rid of panics. 2. IMHO the way Nim does it does work reasonably well for "every

nimsuggest Issue processing ``runnableExamples``

2022-01-03 Thread Clavismax
Exactly! Like here:

`Result` update

2022-01-03 Thread arnetheduck
> I'm guessing this Indeed, that's the one ;) > but the general idea is that one should follow the error pattern used the > library/language `Result` has excellent exception support allowing you to switch freely between the two paradigms or write libraries that pass this choice convenient for

A rant about Nim bugs

2022-01-03 Thread cmc
I basically agree with the sentiment- my impression is, as well, that there is a bit of cavalier attitude in the Nim community with regards to getting the little things right. Now no one is saying this directly but it appears to me that there seems to be the assumption that because Nim is doing

Why does 'string' and 'len' use 'int' rather than 'uint' for length?

2022-01-03 Thread Araq
No, it wouldn't "work just fine", `rev` is already an indicator that it doesn't work but here is maybe a stronger argument: You program with `int`, you get overflows, you change to `BigInt` in the appropriate places, things work. You program with `uint`, you don't get overflows, it's hard to deb

nimsuggest Issue processing ``runnableExamples``

2022-01-03 Thread Araq
It is quite likely that it is a nimsuggest issue but just to ensure that I understand you correctly: When you put your mouse over a symbol you would like to see the complete documentation, including the runnable examples?

Why does 'string' and 'len' use 'int' rather than 'uint' for length?

2022-01-03 Thread Zoom
> for (size_t i = size - 1; i < size; i--) typing i < size instead of i >= 0 > and casting the wrap-around behavior into stone doesn't seem like a good > idea... The article is not very convincing, "just learn these N subtle > patterns and apply them consistently everywhere" has been proven agai

nimsuggest Issue processing ``runnableExamples``

2022-01-03 Thread Clavismax
Recently I noticed that in Visual Studio Code, in cooperation with the nim-lang extension of "Saem", the display of `runnableExamples` does not work. The code-block statement, on the other hand, is processed and displayed correctly. Since it is, as I read on several pages, a better way to work w

Some week-of-year procs for use with the times library

2022-01-03 Thread cmc
... nd we got merged, it's in times! Thanks to all who gave feedback in the review process! The API actually got a lot better.

Help with metaprogramming

2022-01-03 Thread keks84
A big THANK YOU to all of you guys! Your replies give a lot of things to consider: quote and procedural version, even a dsl package. Well worth to have a closer look at Nim.

Help with metaprogramming

2022-01-03 Thread planetis
with fusion astdsl, it becomes a little simpler to write (not by much, for this example though): import fusion/astdsl macro transposeImpl(M, N: static[int]; x, res: typed): untyped = result = buildAst(stmtList): #let typeSym = getTypeInst(res) #let type

Help with metaprogramming

2022-01-03 Thread planetis
This is a very nice use case, I made an example for you import std/macros type Matrix[M, N: static[int]] = array[M * N, float32] macro transposeImpl(M, N: static[int]; x, res: typed): untyped = result = newNimNode(nnkStmtList) for n in 0 ..< N * M:

Status - how would I program a GUI-based Nim-application on Windows?

2022-01-03 Thread axben
@Clonk Thx for the answer (the content of which I was afraid of...).

Status - how would I program a GUI-based Nim-application on Windows?

2022-01-03 Thread enthus1ast
wnim is the most advanced for windows only:

Comments and criticism,please: Nimplementation of Church Numerals

2022-01-03 Thread shirleyquirk
I did make sure that division worked so I'm not surprised it was easy to add, but I'm surprised by the elegance of your predicate function. I've only seen them based upon church pairs before, what was your inspiration? Purely cosmetically speaking, I think all the -chuch suffixes are distracting

Status - how would I program a GUI-based Nim-application on Windows?

2022-01-03 Thread Clonk
More here

Status - how would I program a GUI-based Nim-application on Windows?

2022-01-03 Thread axben
What is - as of now - the "recommended"/supported way to program a GUI-based application on Windows (nothing sophisticated)?

good real life apps

2022-01-03 Thread severak
Hello all. With new year I started learning new language called Nim. :-) I needed some language which has usable stdlib and can produce small binaries both of which Nim can. However I wonder if there are any good real life apps written in Nim which I can learn from?

Help with metaprogramming

2022-01-03 Thread Hlaaftana
>From what I understand you are asking for the same thing as the code given >does. This might be wrong though. The point of the given code is that in Nim, >`a[b, c]` is a valid expression that parses to a call to a routine named `[]` >with the arguments `a, b, c`. Here is how the given code is u

enum in macro

2022-01-03 Thread ynfle
In general, a macro is used for code generation. In nim there are a bunch of constructs for compile time evaluation/execution (`const`, `static`, `.compileTime.`, etc) outside of macros

enum in macro

2022-01-03 Thread domogled
thanks, very mutch