Does Nim support name for anonymous procedures?

2021-10-20 Thread shirleyquirk
works on 1.6.0 on 1.4.8, change the parameter list to `macro name*(name:static string, f: untyped): untyped`

min 1.6 help --passc:-flto problème

2021-10-20 Thread Stefan_Salewski
OK, I was able to strip it down to import times var qt = "NGIQ" & $epochTime() if true:#g_quark_try_string(qt) != 0: qt = "NGIQ" & $epochTime() Run $ nim c -f --gc:arc -d:useMalloc -d:release -d:lto gobject.nim Hint: used config file '/hom

Does Nim support name for anonymous procedures?

2021-10-20 Thread demotomohiro
Why do you want to write code like callbacks.add proc (){.named:"foo".} = raise Run instead of proc foo() = raise callbacks.add foo Run ? Using anonymous procedure with `named` macro doesn't seem to reduce amount of code compared to named

Does Nim support name for anonymous procedures?

2021-10-20 Thread shirleyquirk
a return value like this? let callbacks = @[ (proc():int{.named:"foo".} = 3 ), (proc ():int{.named:"foo".} = raise ) ] for callback in callbacks: echo callback() Run

Does Nim support name for anonymous procedures?

2021-10-20 Thread gcao
Like this import macros macro name*(name:static string, f: proc): untyped = f.expectKind(nnkLambda) result = nnkProcDef.newNimNode() f.copyChildrenTo(result) let id = ident(name) result[0] = id result = quote do: block: `r

Does Nim support name for anonymous procedures?

2021-10-20 Thread gcao
The macro didn't like procs with a return value (e.g. proc(): int ). I'm trying to adapt it but not sure where to look.

Does Nim support name for anonymous procedures?

2021-10-20 Thread shirleyquirk
There are situations where lots of different lambdas are flying around, and when in debug mode it could save 5s per cycle not having to open a file. Now that I've written it I might use it, sure.

Does Nim support name for anonymous procedures?

2021-10-20 Thread ElegantBeef
Well to make it less clumsy here you go, but I very much still see it as silly: type Callback = proc() template namedCallback(name, body: untyped): CallBack = proc name() = body name var callbacks: seq[Callback] callbacks.add: namedCallback(hel

Does Nim support name for anonymous procedures?

2021-10-20 Thread gcao
The reason is the inlined proc may fail. If the programmer feels it makes sense to give it a name so the stacktrace is easier to follow, it should be the programmer's choice. It's clumsy to define proc first, then add to the list. In my project, I have something like below. I would like to name

min 1.6 help --passc:-flto problème

2021-10-20 Thread Stefan_Salewski
Sorry, I have the feeling this is more an issue for the Nim core devs -- which may be tired now after the 1.6 release. cat label.nim import gintro/gobject proc main = echo "OK" main() salewski@nuc /tmp/nim $ nim c -f --gc:arc -d:useMalloc -d:release -

Runtime Regex string replacing

2021-10-20 Thread xigoi
Nim's `let` is like JavaScript's `const`. JS doesn't have an equivalent of Nim's `const`.

min 1.6 help --passc:-flto problème

2021-10-20 Thread Stefan_Salewski
Yes, I can verify that, e.g. for the fontchooser.nim example from the GTK4 book. Will investigate soon, thanks for reporting.

Runtime Regex string replacing

2021-10-20 Thread Yardanico
To explain a bit more - in Nim `var`, `let` and `const` have (IMO) more consistent meanings that in other languages - they don't modify the variable's scope, they affect immutability and runtime vs compile-time. See

Runtime Regex string replacing

2021-10-20 Thread Araq
Instead of `const chomped_file` use `let chomped_file`.

Runtime Regex string replacing

2021-10-20 Thread Sensanaty
Ah wow, incredibly simple. Thanks!

Runtime Regex string replacing

2021-10-20 Thread Sensanaty
So first off, sorry for the extremely noobie question, I've never really used compiled languages before so I'm struggling a bit with the concept. I'm trying to write a small chunk of code that reads the contents of a directory and returns a list of items in that directory sans a specific file e

min 1.6 help --passc:-flto problème

2021-10-20 Thread JPLRouge
hello batch procedure compil : * * * nim c -f --gc:arc -d:forceGtk -d:useMalloc --verbosity:0 --hints:off --threads:on --app:GUI --passc:-flto -d:release -o:termvte termvte.nim Dans la fonction « nimCopyMem », mis en ligne depuis « copyMem_system_1709 » à /home/solei

Is Nim a Transpiler?

2021-10-20 Thread zetashift
I always love your articles, this quote is very nice: > After all, standing on the shoulders of giants is a great way to reach a long > way without having to do a lot of climbing But I must admit, I feel like a lot of recent topics on the internet about Nim are more about bikeshedding rather th

Continuous use of parseJson causes software crash

2021-10-20 Thread nnahito
Thank you! I'll try it

Is Nim a Transpiler?

2021-10-20 Thread Araq
According to Wikipedia a tanspiler is: > A source-to-source translator converts between programming languages that > operate at approximately the same level of abstraction. And this definition is flawed. Let's consider TinyC and GCC, TinyC proves that C is very easy to directly translate into a

Is Nim a Transpiler?

2021-10-20 Thread PMunch
This is a question that gets asked from time to time, decided it was time to write my answer as an article so I can simply link to it instead of repeating myself. Thought some of you might also like it:

Getting Started with googleapi module

2021-10-20 Thread Asarmir
Sorry Treeform for the late reply. I have drop the project for now since my skill level is to low. I plan on trying this later on. Right now I am working on a Roblox game improving my basic programing knowledge and trying small more beginner Nim projects. Trying to work my way up to this in the

Debugging a SIGSEGV

2021-10-20 Thread vsajip
Great, that worked! Thank you very much indeed. I will try asking on IRC next time something like this comes up.

Nim 2.0 -- thoughts

2021-10-20 Thread Lennart
Incremental Compilation ☺

Continuous use of parseJson causes software crash

2021-10-20 Thread ynfle
Try jsony

Debugging a SIGSEGV

2021-10-20 Thread Yardanico
See for an example (I don't think it's 100% correct, but it shows one of the ways to use object variants in your code).

Debugging a SIGSEGV

2021-10-20 Thread vsajip
OK, thanks very much. I will switch to trying object variants.

Debugging a SIGSEGV

2021-10-20 Thread Yardanico
It would be better if you were in Discord or IRC so I can explain stuff in a real-time chat, but basically, your crashes come from the fact that you're using `{.union.}` pragma. It's mainly aimed at C FFI and is not really supposed to be used in pure Nim code, instead you should use object varia

Debugging a SIGSEGV

2021-10-20 Thread Stefan_Salewski
> Does your code contain use of ptr, cast or addr()? > TokenValue {.union.} = object I think union pragma can be dangerous too. Can you not use Nim's object variants instead?

Debugging a SIGSEGV

2021-10-20 Thread Stefan_Salewski
Does your code contain use of ptr, cast or addr()? Try compile on linux with --gc:arc -d:useMalloc and run with valgrind.

Continuous use of parseJson causes software crash

2021-10-20 Thread nnahito
Thank you for your reply. I now understand that parseJson is unlikely to be the source of the crash. I feel very sorry that I cannot present the source code.

Debugging a SIGSEGV

2021-10-20 Thread vsajip
Tried with all of the `--gc:` options other than `--gc:go`. Same results :-( Fails also with `--gc:none`, except that I get lots of `uses GC'ed memory [GcMem]` messages from e.g. `unittest`. A `SIGSEGV` in all cases.

Debugging a SIGSEGV

2021-10-20 Thread vsajip
I'm working on a [project](https://github.com/vsajip/nim-cfg-lib) (early days) which crashes with a `SIGSEGV` in tests. It's pure Nim (no calls into C or anything like that) and it crashes at a point where that bit of code has been executed dozens of times. It's basically a tokenizer, and hits t

Debugging a SIGSEGV

2021-10-20 Thread Yardanico
Can you try running the code with --gc:orc just out of curiosity?

Continuous use of parseJson causes software crash

2021-10-20 Thread Araq
It's much more likely the crash comes from wNim than from our JSON components, no offense to wNim implied.

Nanim: Inspired by 3b1b's manim, I created a GPU-accelerated framework for smooth animations in Nim!

2021-10-20 Thread Arrrrrx2
This looks great, I like it. Pure CPU implementation when?

Reporting security issues

2021-10-20 Thread Arrrrrx2
Yes

Nim 1.6 is out!!

2021-10-20 Thread Arrrrrx2
Congratulations to the nim development team (plus contributors) for yet another fantastic release. This one is so big I wasn't even aware of half the upgrades despite the fact that I build the compiler from devel. I hope the next release is the release of IC and lazy symbol sem checking, two ex