Why can't I use my macro like this?

2021-07-27 Thread solo989
Your example doesn't work. It doesn't crash but it also doesn't the problem 50 proc.

Why can't I use my macro like this?

2021-07-27 Thread juancarlospaco
https://play.nim-lang.org/#ix=3uhh

Why can't I use my macro like this?

2021-07-27 Thread solo989
try this: import macros macro genTuple(startI, endI : static[int]) : untyped = result = nnkTupleConstr.newTree() for i in startI..endI: result.add newLit(i) macro test(number: static[string]) = let procName = newIdentNode("problem"

String related Segmentation Faults

2021-07-27 Thread Araq
Also compile your project with the Nim development version of the compiler which now produces warnings for dangerous implicit conversions to `cstring`.

Why can't I use my macro like this?

2021-07-27 Thread Araq
You cannot generate code at runtime. And you don't need to.

gladloadgl

2021-07-27 Thread veksha
import dynlib let GLlib = loadLib("opengl32.dll") # Windows OS only proc GetGLSymbolAddr(symbol: string): pointer = GLlib.symAddr(symbol) var window = newRenderWindow(videoMode(800, 600), "OpenGL") window.verticalSyncEnabled = true if(not gladLoadGL(GetGLSymbolAdd

Youtube "Software Drag Racing" to count primes in Nim

2021-07-27 Thread GordonBGood
@GamzWithJamz: > Also you’re right, it’s superfluous from a perf standpoint to change method > to func in this case, but it still makes me cringe to see dynamic dispatch > anywhere in code meant to be as fast as possible. I have long left the camp of programmers who think that OOP is the cat's

Mac GUI

2021-07-27 Thread AIR
> is it possible to make a kind of tree-view or expandable view widget? Maybe, I'll have to look into it > the app is starting with terminal window behind main window even with > --app:gui key - how to fix it? macOS uses Application Bundles for it's GUI applications. You'll need to create the

Mac GUI

2021-07-27 Thread Neodim
Just tried it and found it really perfect! 100% native GUI lib! Few questions: * is it possible to make a kind of tree-view or expandable view? * the app is starting with terminal window behind main window even with --app:gui key - how to fix it? * what are future plans about other midgets(

Why can't I use my macro like this?

2021-07-27 Thread ErikWDev
I'm very new to macros and just recently started playing around with them when I discovered the following thing: import macros macro test(number: string) = let procName = newIdentNode("problem" & $number) quote do: proc `procName`() = echo "test: "

String related Segmentation Faults

2021-07-27 Thread Akito
Thanks a lot to everyone for these very helpful replies. :) I will investigate all cstring usages extremely carefully and will try to avoid juggling with (c)strings. I'll keep this thread updated. Thank you!!

String related Segmentation Faults

2021-07-27 Thread doofenstein
> Every single segmentation fault is essentially triggered in this exact place: > that sounds a lot like a heap corruption. So it's probably either some code wrtinig more into a cstring than

String related Segmentation Faults

2021-07-27 Thread Akito
I have been trying to find the reason for this issue for days, and can't seem to find it. Perhaps something stupidly easy I am simply missing? I don't know. The problem is, that I am unable to reproduce the error in a small example. I only encounter this problem in a bigger project, that I canno

String related Segmentation Faults

2021-07-27 Thread Stefan_Salewski
I would bet that it is not a Nim problem, but related to your wrong casts or a winnim issue. Try compiling with --gc:arc to see the difference. Then try --gc:arc -d:useMalloc and run it with valgrind. Maybe that gives you more informations.

String related Segmentation Faults

2021-07-27 Thread Clonk
Using `cstring` is an unsafe operation that yields a view of a Nim string. If your string gets deallocated while you hold a `string` view of it you will get a segmentation fault. To proceed from there, review carefully the code using the `cstring`; even if the stacktrace in the segfault doesn't

build long strings, speed.

2021-07-27 Thread ingo
> -d:danger this about halves the total time taken. The time spent in the conversion to string seems to creeps up a little towards ~70% of the total execution time. @planetis @treeform I'll play with your suggestions later. Thanks.

build long strings, speed.

2021-07-27 Thread treeform
Wow I love optimizing things. Most of the time is taken up but the float to string conversion. I tried to eliminate all of the unnecessary copies, index checks and buffer grows: name ... min time avg timestd dv runs var str

static generics with concept

2021-07-27 Thread chaemon
Thanks! I understand the reason. I wonder why S[int, true] don't satisfy the concept SC but S[int, TRUE] in my alternative satisfy the concept SC.

static generics with concept

2021-07-27 Thread shirleyquirk
what are you trying to do? type S[T;b:static[bool]] = object a:int when b: x:int var af:S[int, false] var at:S[int, true] type SC = concept x,type T T is S # when commnet out this, it can be compiled discard static:

build long strings, speed.

2021-07-27 Thread planetis
No, but it would be better if you directly append to your buffers `vecStr`, etc by changing the signature to `proc povVec2*(a:Vec2, result: var string)`

build long strings, speed.

2021-07-27 Thread ingo
> This could save atleast a few allocations. Thanks. Could a (closure) iterator and streaming to file work? Just thinking loud. for i in uvArr: yield "<" yield $i.x yield "," yield $i.y yield ">" Run

static generics with concept

2021-07-27 Thread chaemon
I want to use static generics in object definition for memory efficiency. But this makes many trouble especially with concepts. The following code cannot be compiled with message "SC: cannot generate code for: b". What is happening? I also know that if I comment out line "x is S" in the concept

build long strings, speed.

2021-07-27 Thread doofenstein
try proc povVec2*(a:Vec2):string {.inline.}= result = "<" result.addFloat a.x result &= ", " result.addFloat a.y result &= ">" Run This could save atleast a few allocations.

Nim earns mention in the news (unfortunately?)

2021-07-27 Thread juancarlospaco
It is a tool, can be used for good or for bad, malware can be used for good too, like in Red-Team or Scam-Baiting. :)

build long strings, speed.

2021-07-27 Thread GamzWithJamz
Have you tried running with -d:danger? I’m not sure how much it may help, but it may bring in some good string optimizations.

Youtube "Software Drag Racing" to count primes in Nim

2021-07-27 Thread GamzWithJamz
@GordonBGood I have commented on a few things with your PR. Stuff regarding Dockerfile and README inconsistencies. As well as the usage of -d:release and -d:danger together.

Youtube "Software Drag Racing" to count primes in Nim

2021-07-27 Thread GamzWithJamz
At any rate, big thanks to you @GordonBGood for like @cblake said, this may end up a dumb language marketing thing, but Nim will put it’s best foot forward with this and show it’s community can still win despite being much smaller.

Youtube "Software Drag Racing" to count primes in Nim

2021-07-27 Thread GamzWithJamz
@GordonBGood Thank you so much for responding to everything. As @dom96 said, I really only get to check on the forum when I’m not busy with work or home life so I deeply appreciate people like you having the time to come in and really teach us a thing or two on such an interesting topic. :) I ha

Nim earns mention in the news (unfortunately?)

2021-07-27 Thread xhevahir
It's named as one of a few "exotic" languages that are reportedly being used in malware attacks: /

build long strings, speed.

2021-07-27 Thread ingo
> Binary -> decimal conversion is generally very slow. The best thing to do is > to not do it at all if possible, but just stay in binary. To give you an idea of speed; Generating the same mesh in the same resolution directly in POV-Ray using similar code, without writing the file takes ~30 s h

build long strings, speed.

2021-07-27 Thread Stefan_Salewski
> create triangle mesh or for a 2D triangulation you may want

build long strings, speed.

2021-07-27 Thread cblake
Binary -> decimal conversion is generally very slow. The best thing to do is to not do it at all if possible, but just stay in binary. If external requirements really force you into ASCII and if you can use the head/tip of nim-devel then you can make your code much faster with `-d:nimPreviewFlo

build long strings, speed.

2021-07-27 Thread ingo
For a little program to create triangle mesh I have to convert 2-3d vectors ([vmath](https://github.com/treeform/vmath)) to strings and write them to file. The code snippet below shows what takes 65% of the run time, it feels unnecessary slow. [(Full source of current state)](https://ingoogni.n

Proposed table changes - get and getOrDefault

2021-07-27 Thread cblake
Maybe `it` notation (from `sortedByIt` fame) is also an abomination (or maybe only in combination with `do`), but you can do a pointer free, view type free, classic Nim (template impl at [lptabz.nim:587](https://github.com/c-blake/adix/blob/master/adix/lptabz.nim#L587)): import a

Mac GUI

2021-07-27 Thread enthus1ast
Any chance this could be added to nigui? :)