Error: unknown substition variable: attype

2021-03-28 Thread user71383
Yep, it ran through this time and `Success: choosenim installed successfully.` showed up on the screen. And `nim doc ...` is working fine again :) Thank you very much. FYI: I found another remainder from the interrupted download ... `~/.nimble/bin/nimble` linked to `../pkgs/nimble-#8f7af86/ni

Are Source Code Filters still needed now that we have strformat?

2021-03-28 Thread alexeypetrushin
Also, in with React.JS, complex expressions are usually rendered with helpers. import strformat, strutils, sugar, sequtils proc render_user*(user: tuple[name: string, is_human: bool, skills: seq[string]]): string = let human_partial = if user.is_human: "Human" else: "

Are Source Code Filters still needed now that we have strformat?

2021-03-28 Thread alexeypetrushin
`fmt` does support loops, and it should support ifs. The `fmt` is very similar to the `JSX` templating system in React.JS. import strformat, strutils, sugar, sequtils proc cond[T](cond: bool, t: () -> T, f: () -> T): T = if cond: t() else: f() proc render_user

converting a hex string to uint32 in JS context

2021-03-28 Thread shirleyquirk
the js isn't emiting the `>>> 0` it ought. this workaround convinces it to do so, (although it then does it twice): var mask = 0x8000'u32 if mask == (mask and mask) shr 0: echo "good" else: echo "not good" Run

quit() - inconsistent behavior - osx terminal vs visual studio

2021-03-28 Thread masiarek2
> # OSX terminal > > > head n.nim > > quit("bar")⏎ > > > ./n > > bar > # now compare to VS Code IDE: > >> Hint: /Applications/nim-1.4-1.4/bin/n [Exec] bar >> >> Error: execution of an external program failed: >> '/Applications/nim-1.4-1.4/bin/n ' >> >> # I am expecting in both cases the sam

Chrome Extensions with Nim, who would have thought?

2021-03-28 Thread akavel
I wrote one (a Webextension) for Firefox for my private use:

Neovim users, how are you setting up Nim?

2021-03-28 Thread zetashift
@DavidKunz your setup worked perfectly :D.

converting a hex string to uint32 in JS context

2021-03-28 Thread JohnAD
Sadly, this did lead to an odd JS bug. I'll look into posting in a `issue`. var mask = 0x8000'u32 if mask == (mask and mask): echo "good" else: echo "not good" Run One gets different results based on compiler target. I suspect the lack of in

strange behavior (Bug?) of member-iterator of object

2021-03-28 Thread ElegantBeef
It's not overly weird behaviour, your `closure.finished` is true, and when iterating over closures the for loop is practically just the following. Running [this code](https://play.nim-lang.org/#ix=2Upy) shows that the closure is finished and needs reset. while not closure.finished

Neovim users, how are you setting up Nim?

2021-03-28 Thread DavidKunz
Glad I could help, I also have made some videos on how to configure Neovim:

converting a hex string to uint32 in JS context

2021-03-28 Thread JohnAD
I had trouble under certain circumstances with `parseHexInt` with JS and unsigned integers. Ah, but `fromHex`. How the heck did I not see that? That also simplifies my code under C. Thanks!

converting a hex string to uint32 in JS context

2021-03-28 Thread Yardanico
This works just fine with both C and JS backends, so I'm not sure what's your question :) import std/strutils let hex = "7c00" var a = fromHex[uint](hex) echo a Run

converting a hex string to uint32 in JS context

2021-03-28 Thread JohnAD
I've got a project that converts strings of hex digits into unsigned 32-bit numbers. Under C / C++ this has been easy and straightforward using casting and/or other techniques. But under javascript... I can't seem to find a method that works. let hex = "7c00" var a: uint

Neovim users, how are you setting up Nim?

2021-03-28 Thread zetashift
@vitreo12 ahh I was gonna go for coc but I was curious about the inbuilt lsp since nightly. @DavidKunz thanks a lot that's gonna help me out a lot!!

converting a hex string to uint32 in JS context

2021-03-28 Thread juancarlospaco
`strutils.parseHexInt` ?.

Neovim users, how are you setting up Nim?

2021-03-28 Thread DavidKunz
I'm using Neovim 0.5 with its native LSP client and nvim-compe. Works good! For syntax highlighting I use `alaviss/nim.nvim` since I didn't find nim support for tree-sitter. My config is here:

Neovim users, how are you setting up Nim?

2021-03-28 Thread vitreo12
coc + nimlsp works great for me

Neovim users, how are you setting up Nim?

2021-03-28 Thread zetashift
What completion frameworks are you using, or are you using nimlsp? I want to try out nvim-compe: , but it's just easier to go with `prabirshrestha/asyncomplete.vim`

How to use global immutable variables in Threads?

2021-03-28 Thread boia01
@alexeypetrushin Unfortunately, accessing any graph containing ref objects using multiple threads is generally unsafe. This is true even if the access starts through a pointer; the pointer doesn't make it any safer, even if the graph is immutable. It would work if it was just a plain object stru

strange behavior (Bug?) of member-iterator of object

2021-03-28 Thread chaemon
I found the strange behavior related to iterator. In the following code, iterator "greater" iterates over all integer greater than a and less than 10. Then, put this iterator to an object S. Now, call these iterators two times. First one ("test by iterator") works well. But second one("test by i

Initializing subclassed objects, like C++ Constructors

2021-03-28 Thread boia01
Nice pattern! I will be using it too.

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread DIzer
of course, you may if you rely on your own codebase solely.. the problems will arise when your projects use forign components and libraries that havily relyed on global states..

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread dom96
Personally I would avoid {.global.} and "static" in C too, just like I would avoid global variables. Why not create a state object for all your state and pass it around? I know it's a bit more painful but it avoids a lot of problems and makes your code far better organised.

Error: unknown substition variable: attype

2021-03-28 Thread shirleyquirk
i'll check later but i have a memory that the empty git folder was in /tmp?

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread jseb
yes i wonder how {.global.} can be replaced when used for a static var (its main use, i guess). I have read the github discussion and even if i don't understand everything, the issue seems serious. But if i understand well, the solution would be to use « global top level variables », that is in

Error: unknown substition variable: attype

2021-03-28 Thread user71383
There was no `nimterop` to remove, only a `nimble-#8f7af86` from yesterday, which very much looks like an interrupted git clone. I kicked it and running `nimble install choosenim` again produces the same error. I send you this time the full error msg ... [user71383@Lenovo ~]$ nimbl

Initializing subclassed objects, like C++ Constructors

2021-03-28 Thread Stefan_Salewski
I don't like and know well C++. But the fact is that papers today most often use C++, so Nim should support C++ notations or have good substitute. (OOP does not mean that we have to use ref objects always, for some use cases inheritance may work with value objects. For the QuickHullDisks code I

Initializing subclassed objects, like C++ Constructors

2021-03-28 Thread shirleyquirk
maybe after you've used it for more than a toy example you'll be able to tell how robust it is and whether its useful enough to document. I avoid oop whenever possible so i'm not the person to try it out I super hate the triple repetition,but its necessary to a)differentiate which constructor o

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Stefan_Salewski
> not use the global pragma You may not be able to avoid it. It is the "static" from C variables, we need it when variables in procs should remember its state between proc calls.

Initializing subclassed objects, like C++ Constructors

2021-03-28 Thread Stefan_Salewski
That is an interesting trick, I was not aware of it. I think I will use it for my current module (QuickHullOfDisks) which follows a paper and a C++ implementation. As this seems the only and best solution currently, so can we add it to the official tutorial or manual? If not I will have forgott

Trying to use openssl RSA funcitonality in nim

2021-03-28 Thread PMunch
Ah, quite a simple mistake, or rather two small mistakes, both easily made. The OpenSSL wrapper is just a very thin wrapper around the C library, this means that it isn't really aware of Nims types and needs a little bit of extra help. When you write `addr publickey` that is the address of the N

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread iortega
Thank you for you help Yardanico. I will take this into account and not use the global pragma when I start programming on Nim

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Yardanico
Yes, see e.g.

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread jseb
Can we infer as a rule of thumb than {.global.} should not be used with arc/orc ?

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Yardanico
https://github.com/nim-lang/Nim/issues/17552

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Yardanico
type TextCache = ref object var cnt = 0 proc newTc(): TextCache = inc cnt result = TextCache() proc use(tc: TextCache) = discard template renderTextCached(text: string) = block: var tc {.global.} = newTc() use(tc)

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Yardanico
I think I found out the issue: template rendertextCached(game: Game, text: string, x, y: cint, color: Color) = block: var tc {.global.} = newTextCache() game.renderText(text, x, y, color, tc) Run `{.global.}` doesn't really play well with ARC/ORC,

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Yardanico
After debugging with Valgrind's massif I found out that the issue is in the text rendering. If you comment out lines 226-232, there's no leak, so it must be something in there that's causing issues.

Why memory leaks with ARC/ORC on platform game?

2021-03-28 Thread Yardanico
What Nim version are you on? For me on devel (355985ac89dd13d5b317744b30842155d9321565) there are no leaks with ARC/ORC with that game. Also, you don't need that patch, you can just change a single line 236 so that it becomes `template time: untyped = game.player.time`