Can I do text replacements in a file via a NimScript?

2021-03-23 Thread halloleo
I need to do as part of a build step some string replacements in a text file. In full Nim I'm able to do this via stream reading, text replacements, and stream writing - can I do this in NimScript (i.e. `config.nims`) as well? The `streams` module is not listed for NimScript... Thanks for any p

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread lotib48819
interesting. running `node main.js` it works. Maybe by default it is using a wrong node version. I have nvm and I do have multiple node versions installed including v14, v12, v9 and v8.

NimScript tasks with parameters?

2021-03-23 Thread halloleo
How can I use parameters in NimScript tasks? I had a peek at the the `task` template source and it looks like the `...Task` proc does not take any parameters. So do I have to read parameters manually from the command line?

I am confused. Javascript, WASM coroutine support ?

2021-03-23 Thread dsrw
1\. Coroutines are definitely my #1 feature request for Nim, but for now they aren't well supported. The [coro module](https://nim-lang.org/docs/coro.html) is an unstable API that hasn't seen much attention recently. It works well under the arc/orc garbage collector, but has problems with the de

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread timothee
@lotib48819 I can't reproduce your issue, please provide more info: * nim -v * cat main.nim (minimize it first) * which OS, etc * does the generated code (without -d:nodejs) work in browser * node -v (you already did, but double check) * try also running `node main.js` directly with ma

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread juancarlospaco

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread lotib48819
`nim js -d:nodejs -r main.nim` I get this error message ReferenceError: globalThis is not defined Run If you experience errors saying that globalThis is not defined, be sure to run a recent version of Node.js (at least 12.0). node -v v14.4.0 Any ideas? Also, will t

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread Yardanico
The "var F" thing has nothing to do with the browser, it's the stack trace entries, they work fine in the browser as well as in Node.

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread lotib48819
noted. I also see that in Browser it opens with no error. But echo are muted probably i need to use console.log somehow. But in node js i get that error message.

I am confused. Javascript, WASM coroutine support ?

2021-03-23 Thread lotib48819
hi Brotherhood of Nod. For 2. Is this the tutorial ?

I am confused. Javascript, WASM coroutine support ?

2021-03-23 Thread lotib48819
Hi. I do like Nim. It is beautiful and easy to develop. I just discovered it yesterday and I believe it is a RUST and GO killer. But I want to see if Nim can fit in my demands right now: 1. Right now, can the coroutines work in Javascript or WASM (source compiled to C and then compiled to was

I am confused. Javascript, WASM coroutine support ?

2021-03-23 Thread Yardanico
3) when not defined(js): # code for c, cpp, objc backends else: # code for the js backend Run 4) Nim compilation times are usually quite fast unless you use a lot of concepts/converters/etc, but this will further be improved with incremental compilatio

2nd Nim online meetup

2021-03-23 Thread DavidKunz
Would be great!

Testing that a macro throws an exception

2021-03-23 Thread zidsal2
After digging through the testament code I've found an undocumented part of testament that solves this. The final output is the following discard """ errormsg: "missing `sheets` attribute" file: "castledb.nim" """ import castledb generateCastleDbModel("test.js

gtk gintro, hello world in object oriented way.

2021-03-23 Thread Stefan_Salewski
> It looks good to me but not for the compiler Looks very wrong for me. Please follow the provided examples. We generally do not use methods, we do not need the destructor with recent Nim, and you have to call "let window = newApplicationWindow(app)". Is started going to fix your example, but t

2nd Nim online meetup

2021-03-23 Thread dom96
We actually have a recording of the last one, will see about uploading it :)

nim doc generates code with invalid indentation

2021-03-23 Thread HJarausch
I have fixed a type error myself, please see and `nim doc` still get this "invalid indentation" error. nim -v Nim Compiler Version 1.4.4 [Linux: amd64] Compiled at 2021-03-20 Copyright (c) 2006-2020 by Andreas Rumpf active boot switches: -d:release

gtk gintro, hello world in object oriented way.

2021-03-23 Thread devosalain2
Hmm, indeed. What I currently try and does not work : import gintro/[gtk, gobject, gio] when defined(gcDestructors): proc `=destroy`(x: var typeof(CountButton()[])) = gtk.`=destroy`(typeof(Button()[])(x)) type CountButton = ref object of Button

runnableExamples need random - what can I do?

2021-03-23 Thread HJarausch
Thanks! Without `static:` and `block:` it works indeed.

auto declaration of function prototype

2021-03-23 Thread Araq
> I suspect it's on the list of things to be revisited and formalised after > incremental compilation lands? Exactly.

2nd Nim online meetup

2021-03-23 Thread Niminem
Looking forward to it :)

runnableExamples need random - what can I do?

2021-03-23 Thread miran
> Running nim doc on my draft of median.nim Why is it important that runnable examples are inside of `static` and `block`? Are you aware they won't be run at runtime, even without `static`?

nim doc generates code with invalid indentation

2021-03-23 Thread miran
I copy-pasted the stuff you posted, fixed wrong types in several places, and the documentation seems ok: proc median*(A: var openArray[int], left, right: Natural, myCmp: proc(x, y: int): int {.nimcall} = cmp[int]): float = result = 1.0 runnableExamples

gtk gintro, hello world in object oriented way.

2021-03-23 Thread Stefan_Salewski
Subclassing is explained in I know that this topic is missing from the GTK4 book still, but I generally assume that people read the README first.

array sample slower than indexing into rand(size-1)

2021-03-23 Thread peheje
Nice shirleyquirk! I guess I should just use arrays when performance really matters and I know the size compile time. Would you do it like this? import sequtils import random import times const size = 10_000_000 iterations = 100_000_000 type

auto declaration of function prototype

2021-03-23 Thread exelotl
The experimental [codeReordering](https://nim-lang.github.io/Nim/manual_experimental.html#code-reordering) feature is probably what you're looking for :)

runnableExamples need random - what can I do?

2021-03-23 Thread HJarausch
Running `nim doc` on my draft of `median.nim` fails with `/usr/lib/nim/pure/random.nim(250, 8) Error: cannot evaluate at compile time: state`

gtk gintro, hello world in object oriented way.

2021-03-23 Thread devosalain2
I want to subclass "window" and call the initialiser. This is in python but the idea is clear, class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.button = Gtk.Button(label="Click Here") self

nim doc generates code with invalid indentation

2021-03-23 Thread HJarausch
If one copies the code after the `block:` statement below into a separate file and moves it to the left, it compiles just fine, but with `runnableExamples` it fails proc median*(A: var openArray[int], left, right : Natural, myCmp : proc(x,y:int):int {.nimcall

Search engine for free assets

2021-03-23 Thread Cnerd
Some time ago I made a search engine to get free animation and game assets on the web but, my server subscription will soon run out hence I am making the project open sourced. Here is the link . I'll drop updates to the project from time to time your P

gtk gintro , list of class objects and functions

2021-03-23 Thread Stefan_Salewski
Let me know when you have good ideas how we can generate fine API docs. I can currently not see something that would work better and faster than plain grep. At least for people familiar with GTK grep should work fine. For people new to GTK learning GTK is very much work, that people maybe better

gtk gintro , list of class objects and functions

2021-03-23 Thread devosalain2
I see , with grep I can come already a long way : I will use something like, egrep -i XXX ~/.nimble/pkgs/gintro-0.8.8/gintro/* | grep YYY

2nd Nim online meetup

2021-03-23 Thread Araq
This time, yes, I think so.

auto declaration of function prototype

2021-03-23 Thread jseb
Hello, This kind of code needs function prototyping. proc a() proc b() proc a() = echo "a" b() proc b() = echo "b" Run Is it possible to auto-declare the procedures ? May be with a macro, for generating the beginning (but should

2nd Nim online meetup

2021-03-23 Thread DavidKunz
That's great! Will there be recordings?

array sample slower than indexing into rand(size-1)

2021-03-23 Thread cblake
Also, I am pretty sure that, besides being slow, `proc rand(r: var Rand; max: Natural)` is also buggy/biased. Git VC history says it used to be correct, but then someone hastily re-did some logic to make it range-inclusive. Briefly, if x <= randMax - (randMax mod Ui(max)): re

gtk gintro , list of class objects and functions

2021-03-23 Thread Stefan_Salewski
Nice that you ask for permission first. I have no objection against that :-) Let us know how you did it, maybe it would be useful for others. I described how I use the API in We intended to list all the functions and objects on a html page

2nd Nim online meetup

2021-03-23 Thread miran
The 2nd Nim online meet will take place this **Friday (March 26th) at 4pm UTC** (the same time as the first meet). Araq will give you a short recap of the progress regarding incremental compilation, but other than that we would like to keep things casual and interactive: feel free to ask questi

gtk gintro , list of class objects and functions

2021-03-23 Thread devosalain2
Can I list all class/objects of gtk and functions or browse them ?

Norm & Functions

2021-03-23 Thread moigagoo
I've submitted a PR that adds `ON DELETE` support: With this change, you can add `onDelete: "CASCADE"` to your foreign key attrs to enable cascade deletion:

Resolving incorrectly deduced `raises` violations

2021-03-23 Thread arnetheduck
We've recently introduced some [exception-tracking cleanups](https://github.com/status-im/nim-chronos/pull/166) in `chronos` \- this change fixes several long-standing and practical issue we've had, namely that exception tracking was not working at all for async functions and instead infected l

Converter string to raw

2021-03-23 Thread ynfle
I believe you are looking for [addEscapedChar](https://nim-lang.org/docs/system.html#addEscapedChar%2Cstring%2Cchar)

Converter string to raw

2021-03-23 Thread PMunch
Raw strings are just the same as a normal string. Only difference is how they are created. With normal strings it will escape things like `\t` to be a tab, but with raw string literals it will be the two characters `\` and `t`. But I assume what you want is to replace all the escape characters b

Generics overload - which one is selected?

2021-03-23 Thread alexeypetrushin
A related RFC proposal [Improve overload resolution for generics and templates](https://github.com/nim-lang/RFCs/issues/346)

Converter string to raw

2021-03-23 Thread modolo
Hi! I know it is possible to create raw strings with r or R like: let msg = r"tHellon" # raw string But if I have a string that was not created as raw, is it possible to make it raw? let msg = "tHellon" # string let raw_msg = MakeStringRaw(msg) # my wish It is possible? I looked in the docum

Manually initializing exception handling

2021-03-23 Thread vitreo12
Thanks a lot! I'll give it a go :)

Generics overload - which one is selected?

2021-03-23 Thread xigoi
The sentence they quoted seem to imply that even if they're both generics, the more specific one should be chosen.

Compile-time string obfuscation

2021-03-23 Thread oyster
The answer is I need some way to protect my data from been extracting easily for common users. A weak protection goes well. But I am too lazy to encrypt every string to a hard-to-be-judged variable then use the decrypted string by adding, something like, `decrypted(strCryptedName)`, `decrypted(

Generics overload - which one is selected?

2021-03-23 Thread mratsim
`T` and `T` are both generics. You need to use disambiguation like that: proc foo[T: not SomeInteger](A:openArray[T]) = echo "Generic version" echo A proc foo[T:SomeInteger](A:openArray[T]) = echo "SomeInteger version" echo A Run

Compile-time string obfuscation

2021-03-23 Thread enthus1ast
I think it does not really matter which "encryption" is used since the key is stored somewhere next to the strings.

Compile-time string obfuscation

2021-03-23 Thread cheatfate
Why somebody needs this home-made encryption, if you can use `nimcrypto` to encrypt data using AES at compile time?

Manually initializing exception handling

2021-03-23 Thread Araq
You also should try `-d:noSignalHandler` which removes the exception seq handling code altogether.

Generating code coverage with Nim 1.4.0

2021-03-23 Thread Clonk
I've used rr in the past but I didn't know it could generate code coverage. Or is it using gcov under the hood when replaying a program ?