Documentation comments before the item being commented?

2021-04-18 Thread Stefan_Salewski
I asked the same some years ago for procs. Indeed I like to have the whole proc code as short as possible, fitting on the screen as a whole, so comments between proc header and proc body is not that nice. Araq told me that proc comment is a part of the proc, so place should be after proc heade

Recommended method to build nim for M1 Macs?

2021-04-18 Thread Araq
Try these steps please: git clone https://github.com/nim-lang/nim.git nim git clone -q --depth 1 https://github.com/nim-lang/csources_v1.git csources cd csources sh build.sh cp bin/nim ../nim/bin/nim cd ../nim bin/nim c --skipUserCfg --skipParentCfg koch ./

How to use macros for an intermediate compiler step?

2021-04-18 Thread Araq
The `seq` is still a tree but also allows for linear traversals as well as for recursive traversals. That's the beauty of it. > Would that affect macros too? In a future that is a far away, yes. But in the meantime the macro system is not affected, even if the compiler were to use packed ASTs e

Documentation comments before the item being commented?

2021-04-18 Thread Araq
There is no way to do that.

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread shirleyquirk
Nim isn't doing anything other than moving bytes around, it's all about what displays the unicode, and the zero-width joiner is very variously implemented, it varies with os/browser/terminal/font and the newer ones like "πŸ‘¨πŸ»β€β€οΈβ€πŸ’‹β€πŸ‘¨πŸΌ" will be one glyph or four depending on what you're seeing it on

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread juancarlospaco
Usually its the fonts that do not have the glyph.

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread treeform
I think its a terminal issue here is how it looks in the terminals I tried: None of them can display it and all of them display it differently.

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread treeform
If you write to a file instead of echo: var s = "Hello πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦" writeFile("foo.txt", s) Run And open the file it looks correct. I think Nim supports the family emoji but the terminals don't.

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread treeform
I can think of several reasons: * The fonts are different and the terminal font does not have the proper unicode to display that. * The terminal does not do the unicode composition thingy needed to display the family emoji. * The editor saves the unicode in an odd way so that it does not p

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread masiarek2
var s = "Hello πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦" echo s Run See the screenshot at:

Recommended method to build nim for M1 Macs?

2021-04-18 Thread stu002
That build is with `choosenim`. It looks like the Homebrew `--HEAD` build fails: 15 lines from /Users/stu/Library/Logs/Homebrew/nim/01.sh: 2021-04-19 09:28:37 +1000 /bin/sh build.sh # OS: macosx # CPU: arm clang -o bin/nim -ldl -lm Undefined symb

Recommended method to build nim for M1 Macs?

2021-04-18 Thread stu002
Is there a recommended method to install nim built for aarch64 to M1 Macs? Both `brew install him --HEAD` and `choosenim update devel --latest` build the amd64 version: $ nim --version Nim Compiler Version 1.5.1 [MacOSX: amd64] Compiled at 2021-04-18 Copyright (c) 2006-2

Documentation comments before the item being commented?

2021-04-18 Thread stu002
Is there an option or a method to allow documentation comments (starting with `##`) to precede the thing being commented, rather than inside it? Something like: ## This type contains a description of a person type Person* = object name: string age: int

ArrayBuffer

2021-04-18 Thread juancarlospaco
`JsObject` ?, but in the future there should be proper support for ArrayBuffer because is part of the standard.

ArrayBuffer

2021-04-18 Thread shirleyquirk
treeform/jsutils defines the type as `type ArrayBuffer* {.importc.} = ref object`

ArrayBuffer

2021-04-18 Thread dullbananas
How do I import a JavaScript function that returns ArrayBuffer?

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread alexeypetrushin
Thanks, it works! :)

When to use nim.cfg vs config.nims?

2021-04-18 Thread juancarlospaco
You kinda responded to yourself.

When to use nim.cfg vs config.nims?

2021-04-18 Thread jrenner
Is there any general information on when nim.cfg should be used vs config.nims? maybe some sort of style consesus? If I had to guess, I would say that config.nims is the newer, better way to go but both are supported.

Post process string formatted with `fmt`

2021-04-18 Thread alexeypetrushin
> can use any SQL and paste the results into the DSL I didn't realised it's so close, from the examples it wasn't obvious. And type-safe SQL is definitely a cool feature. Nice to know Nim macros is so advanced that it's possible to write macros to validate SQL types and columns.

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread shirleyquirk
your `rtype` is a `Sym`, when you want it to be an `Ident` `rcall_impl` should be `proc rcall_impl[A,B](fn:string,a:A,b:B,R:typedesc):R` you can use `newCall(fname, argSeq)` instead of the if statements and `quote do` but that's all style stuff. the real fix is: don't have rtype be a sym in the

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread ElegantBeef
Replacing line 17 with `(impl[0].symbol.`$`, fsignature[0..^2], ident($fsignature[^1]))` resolves the issue as it seems it being a symbol causes it not to be accepted as a `type int`.

python: print(x, end=" ")

2021-04-18 Thread masiarek2
wow - both answers are great. THANK YOU!

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread alexeypetrushin
Yes, it builds the correct expression `return rcall_impl("multiply", a, b, int)` but still refuses to compile, please see updated post, I simplified the code a little bit and added more detailed error description. > Considering that is a third question thread you posted Thanks for taking time a

python: print(x, end=" ")

2021-04-18 Thread BLeAmz
By something like this: import strutils var x = "aa" y = "bb" z = "cc" stdout.write [x,y,z].join " " Run

python: print(x, end=" ")

2021-04-18 Thread PMunch
`import strutils stdout.write [x, y, z].join(" ") ` Run

python: print(x, end=" ")

2021-04-18 Thread SolitudeSF
> How to achieve sth similar? by writing your own function.

python: print(x, end=" ")

2021-04-18 Thread juancarlospaco

python: print(x, end=" ")

2021-04-18 Thread masiarek2
Python allows large number of variables to be printed on the same line (without line return) Please compare: var x = "aa" var y = "bb" stdout.write(x, " ", y, "\n") Run # stdout.write(x y z & " ") # error # stdout.write(x, y, z & " ") # error x = "aa

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread haxscramper_
Also - have you considered joining any of the real-time chats we have? Discord/gitter/IRC/matrix/telegram (? Considering that is a third question thread you posted it might be more convenient for you to ask questions there

python: print(x, end=" ")

2021-04-18 Thread Smintheus98
If I get you right you want to print something without an automatic newline at the end? You can use: `stdout.write x` to achieve that.

Nim on raspberry PI

2021-04-18 Thread boia01
And, just for what it's worth, if you didn't know where to start, you could just have used `c2nim` on `wiringPi.h` (now installed by default on Raspian) and you would have gotten this: which worked great for

python: print(x, end=" ")

2021-04-18 Thread PMunch
stdout.write(x & " ")

python: print(x, end=" ")

2021-04-18 Thread Stefan_Salewski
stdout.write(x)

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread haxscramper_
What makes you think `int` is not evaluated as `int`? printing macro result with `echo result.toStrLit()` as the last step shows generated code - `return rcall_impl("multiply", a, b, int)`

python: print(x, end=" ")

2021-04-18 Thread masiarek2
I am unable to find equivalent in Nim: * python print(x, end=" ") How to achieve sth similar?

How to use macros for an intermediate compiler step?

2021-04-18 Thread Sixte
I just keep on reading packed_ast.nim. There is no tree anymore. You converted the tree into a list (if I understand it correctly...). So the AST becomes an ASL. Sounds promising. You wrote elsewhere, that the packed_ast should replace the recent AST representation everywhere. Would this affect

Error in macro, `int` is not evaluated as `int`.

2021-04-18 Thread alexeypetrushin
I'm trying to autogenerate implementation for the procedure with macro `rcall` proc multiply(a, b: int): int proc multiply(a, b: int): int = rcall(multiply) # => rcall_impl("multiply", a, b, int) echo multiply(1, 2) Run And it almost works,

hashing stored passwords

2021-04-18 Thread federico3
uses password hashing from libsodium as well

Nim on raspberry PI

2021-04-18 Thread archnim
Thank you very much for your advices.

Post process string formatted with `fmt`

2021-04-18 Thread juancarlospaco
That is a basic default feature of the core of language, names can have spaces in Nim, therefore that is perfectly valid in Nim, example But having said that..., make it happen, I am waiting your Pull Request to make it better and more close to SQL as possib

Post process string formatted with `fmt`

2021-04-18 Thread moigagoo
Norm doesn’t offer an SQL query constructor yet, so your conditions are plain old vanilla SQL. To safely insert values, use placeholders (? for SQLite, $1 for Postgres) with a list of values.

Post process string formatted with `fmt`

2021-04-18 Thread ynfle
Whatever you prefer. The advantage is that it is syntactically checked at compile time

Post process string formatted with `fmt`

2021-04-18 Thread alexeypetrushin
> Also see Thanks, but that's exactly why I don't want to use Nim DSL for SQL, you need to remember to write `selectdistinct "somecolumn"` instead of `SELECT DISTINCT somecolumn` and lots of similar quirks. So, instead of just SQL you to learn an

Post process string formatted with `fmt`

2021-04-18 Thread alexeypetrushin
Thanks, I don't know how macros works, but somehow with try and error I [did it](https://play.nim-lang.org/#ix=2Wv9) it works! :) P.S. As for Norm, yes, saw it, nice library, but I prefer to use plain SQL, as I already know it and don't need to learn Nim SQL-like API for generating schema or q

Post process string formatted with `fmt`

2021-04-18 Thread ynfle
Also see

Post process string formatted with `fmt`

2021-04-18 Thread haxscramper_
Of course it would be possible to write formatter similar to `fmt` \- after all it is just a simple macrom that parses argument string and generates some trivial code with string concatenation. You can check out

Post process string formatted with `fmt`

2021-04-18 Thread alexeypetrushin
I wonder would it be possible to write `sql` string formatter similar to `fmt` that would properly escape SQL values? sql"select * from users where id = {1} and is_blocked = {false}" # => (query: "select * from users where id = ?", values: @["1", "false"]) Run Exam

hashing stored passwords

2021-04-18 Thread jackhftang
argon2 is available in libsodium. Look for `crypto_pwhash_argon2id`.

Nim on raspberry PI

2021-04-18 Thread jackhftang
I did something like this nim proc hardReset*(pin: int) = writeFile("/sys/class/gpio/export", $pin) writeFile(fmt"/sys/class/gpio/gpio{pin}/direction", "out") writeFile(fmt"/sys/class/gpio/gpio{pin}/value", "0") sleep 100 writeFile(fmt"/s

hashing stored passwords

2021-04-18 Thread cheatfate
nimcrypto has `pbkdf2` and `scrypt` kdfs.

How to use macros for an intermediate compiler step?

2021-04-18 Thread Araq
> Sounds interesting. Where can I find it? Nim devel, directory compiler/ic, compile you program with --ic:on ...

hashing stored passwords

2021-04-18 Thread marcomq
I haven't found argon2 for nim yet. Also, I didn't tested it yet, but you may use PBKDF2 to store passwords. Make sure to have a high number of iterations (>30) as specialized hardwar

How to use macros for an intermediate compiler step?

2021-04-18 Thread Sixte
Sounds interesting. Where can I find it? I regard modules as heterogeneous type containers and therefore, it should be possible to type them. Modules as extended type classes, including interfaces, concepts and quantified, but restricted types.

How to use macros for an intermediate compiler step?

2021-04-18 Thread Sixte
The link of @yfle describes the motivation pretty well. I want to stay as close as possible to the Nim AST and therefore, an intermediate Nim code output would do the job.

Nim on raspberry PI

2021-04-18 Thread ThomasTJdev
Hi @archnim I use my package [wiringPiNim](https://github.com/ThomasTJdev/nim_wiringPiNim). There are some small examples in the README. I know there are other RPi packages, but I can't find them on . import wiringPiNim if piSetup() >= 0: piPinMo

How to use macros for an intermediate compiler step?

2021-04-18 Thread Araq
I invite you to look at our upcoming "IC" infrastructure -- a Nim module is compiled into a .rod file amenable for all sorts of static analysis -- the code that is emitted is after macro expansions and type checking. It's in heavy development right now but might be useful already for your purpos