Re: Ported a Python game to Nim

2020-01-16 Thread SolitudeSF
doesn't compile. i tried fixing the errors, but each time a new pops up. you probably pushed old version or missed some file.

Who would I implement simd to do fast md5 checksums ?

2020-01-16 Thread zulu
Anyone has a short how to how would one go about it ?

Re: ELI5: newruntime and arc

2020-01-16 Thread andrea
The issue for me is that posts about `--gc:arc` still reference concepts like `sink` and `lent` parameters. These are described in [the post about destructors](https://github.com/nim-lang/Nim/blob/devel/doc/destructors.rst#nim-destructors-and-move-semantics), but, well, that document is not

Re: Naming conventions - need leading underscore

2020-01-16 Thread sschwarzer
> Yet I am new to Nim (coming from C, C++, Python) and wonder, what this.x then > will mean in my Euler class. Is it the pointer to the method x or is it the > attribute x? I tried Skaruts's code in the [Nim playground](https://play.nim-lang.org/#ix=27xV) and it seems accessing `Euler(x:

Re: Naming conventions - need leading underscore

2020-01-16 Thread Libman
According to the upcoming Official 21st Century Universal Code Style Guide, the correct way to write this is: type Euler* = object x, y, z, a, b. c: float64 method x( this: Euler): float64 = return this.x Run Leading and

Re: Who would I implement simd to do fast md5 checksums ?

2020-01-16 Thread Stefan_Salewski
[https://irclogs.nim-lang.org/23-12-2019.html#16:10:45](https://irclogs.nim-lang.org/23-12-2019.html#16:10:45) 16:10:45 FromDiscord the best simd wrapper is here: [https://github.com/numforge/laser/blob/master/laser/simd.nim](https://github.com/numforge/laser/blob/master/laser/simd.nim)  But

Re: Naming conventions - need leading underscore

2020-01-16 Thread sschwarzer
> How underscores improve readability? The idea is that you could use `_name` for a private field and `name` for an accessor proc. It's a nice convention. So I agree, it doesn't improve readability directly, or maybe just in the sense that you avoid less readable names like my `privateX`

Re: Ported a Python game to Nim

2020-01-16 Thread Jjp137
That's odd. Can you revert any changes you made and show me the compiler errors? Also, what version of the Nim compiler are you using? I tried compiling it in a Linux VM that initially didn't have Nim 1.0.4 in it and it was successful, so the error message will be very helpful in figuring out

how to evaluate a code block in a different context in a macro

2020-01-16 Thread egx
Hi, Is it possible to evaluate function body, or some other code block, in a different context, e.g. consider this simple repro: import macros # this macro evaluates function body in a different context # and prints result at compile time macro eval1(fun: untyped):

Re: ELI5: newruntime and arc

2020-01-16 Thread rockcavera
A few days ago I reported about not understanding the destructors document on the #nim @ freenode.net IRC channel. Unfortunately, as a weekend developer (just for fun), I will have to close my eyes to such changes until they are applied (something that scares).

Re: ELI5: newruntime and arc

2020-01-16 Thread andrea
> there is no reason to despair and stop developing Nim libraries. Thank you, I ensure you that I do not despair, but I feel a little lost with all the recent changes :-)

Re: Naming conventions - need leading underscore

2020-01-16 Thread poseidon
@sschwarzer: You hit the point, thank you!

Re: Naming conventions - need leading underscore

2020-01-16 Thread juancarlospaco
But Nim wont use underscore for private vs public. How underscores improve readability?. `let __variable = 42` Vs `let variable = 42`.

Re: Naming conventions - need leading underscore

2020-01-16 Thread poseidon
@Skaruts: Alas, Nim doesn't accept this code: ### Define the class # type Euler* = object x, y, z, a, b, c: float64 method dump( self: Euler): string = return "x" method print( self: Euler): void = echo( self.x, ", ",

Re: nbindgen - calling rust code from nim

2020-01-16 Thread ducktape
This is awesome and I look forward to seeing where it goes. Projects like these that can exponentially expand the ecosystem are very cool.

Re: Naming conventions - need leading underscore

2020-01-16 Thread Skaruts
@sshw > I tried Skaruts's code in the Nim playground and it seems accessing Euler(x: > 3.0).x doesn't call the method, but returns the field value. That's because you're accessing it from within the same module. I didn't think of mentioning this before, but the trick will only work if you

Re: ELI5: newruntime and arc

2020-01-16 Thread b3liever
For me to understand it, I considered Nim's copy semantics. Find an variable inside a procedure that gets copied and apply sink to the proc's parameter. If the argument is not used after the call, then it will be moved to the proc (or better the memory location it points to), else a copy is

Re: Naming conventions - need leading underscore

2020-01-16 Thread Skaruts
Seems to be conflicting with property `x`. But you're also calling `x` as a method with a parameter, when the method that takes a parameter is `x=`. What you want there is something more like: euler.`x=`(42)# I suppose using back-ticks is advisable, as sometimes this doesn't

Re: Who would I implement simd to do fast md5 checksums ?

2020-01-16 Thread treeform
How I would go about it: * Figure out which version/instruction set of SIMD you want. If you are making it for games steam survey can help:

What is the keyword "end" reserved for?

2020-01-16 Thread Hlaaftana
Searching `tkEnd` in the compiler code gives only enum definitions, and the word `end` is shown as a keyword in the manual, where it says unused keywords are reserved for future features of the language. I remember `atomic` and `shared` also being unused keywords that got removed eventually, so

Re: Why does this proc have side effects?

2020-01-16 Thread miran
> Why does this proc yield `Error: 'crossover' can have side effects`? You are using `rand` which makes this proc non-deterministic, i.e. you will not always get the same result for the same input.

Why does this proc have side effects?

2020-01-16 Thread benjamindlee
Sorry if this is a dumb question; I just started my first real Nim project a few days ago. Why does this proc yield Error: 'crossover' can have side effects? import random func crossover*[T](parent_1: seq[T], parent_2: seq[T]): (seq[T], seq[T]) = ## The default

Re: Status of mixin statement?

2020-01-16 Thread Araq
If what you say is true, your 64bit build of Nim is broken... :-/ Please report it on github.

Re: Naming conventions - need leading underscore

2020-01-16 Thread mashingan
Having _ as initial variable name only acts as visual cue, it's not related to readability or anything. Having clear/distinct/helpful/noisy visual cues doesn't change the fact whether the code is well written or not. What actually helpful is good structure and sane APIs. Whatever the variable

Re: Why does this proc have side effects?

2020-01-16 Thread mashingan
rand proc has side effect.

Re: Naming conventions - need leading underscore

2020-01-16 Thread tedlavarias
@Libman I think an MC Hammer emoji would be more appropriate than your smiling poop emoji... If only one existed... 樂

Re: What is the keyword "end" reserved for?

2020-01-16 Thread mratsim
Surprisingly `begin` is not reserved or I would think it's a hidden plot for Pascal/Ada to takeover Nim.

Re: What is the keyword "end" reserved for?

2020-01-16 Thread kaushalmodi
**end** is used (and required for `if`) in the [Nim Source Code Filters](https://nim-lang.github.io/Nim/filters).

Re: Ported a Python game to Nim

2020-01-16 Thread Jjp137
Ah, right. The version of nimgame2 you currently have is either not from the devel branch, or it was from the devel branch but is now too old. Just run `nimble install nimgame2@#devel` to fix that. You'll also need to update sdl2_nim or else you'll run into [this

How to properly append/replace DOM elements using just karax

2020-01-16 Thread NerdRat
I am fairly new using karax. Playing with it, I tried to make elements spawn by clicking a button. The following approach works fine but it throws an exception ruining other karax components. type Selector = ref object selected: kstring ...

Re: Ported a Python game to Nim

2020-01-16 Thread SolitudeSF
last-gardener/src/pattern.nim(73, 16) Error: type mismatch: got this one can be fixed by importing random, but then this error pops up. last-gardener/src/scenes.nim(104, 9) Error: attempting to call undeclared routine: 'initScene'

Re: [vscode] Anyone willing to share his tasks.json needed to build nim files?

2020-01-16 Thread hyl
At first I used it because it seemed like an easy way to run the compiler on save. But I switched to a method like @treeform described and I prefer that now.

Re: Naming conventions - need leading underscore

2020-01-16 Thread sschwarzer
> People don't complain about Python not allowing unicode characters as > identifiers (something possible in Julia for example). For the record, Python 3 _does_ allow unicode characters in identifiers. :-) $ python3 Python 3.7.5 (default, Oct 17 2019, 12:09:47) [GCC 9.2.1

Re: Nim lang for beginners?????

2020-01-16 Thread Skaruts
Also, in case you're gonna end up doing any OOP in Nim, [this blog post](https://matthiashager.com/nim-object-oriented-programming) helped me quite a bit.

Re: Naming conventions - need leading underscore

2020-01-16 Thread jibal
And before Python 3.0, there were probably people who did complain about their absence. Rationalizations tend to be disingenuous, and there's a lot of that here. Not that it matters, because Nim's handling--and lack of handling--of underscores is not something that's going to change.

Status of mixin statement?

2020-01-16 Thread spip
The following code is compiling without error on Linux 64 bits but generates an `unknown symbol 'initE'` on Linux 32 bits. module `a.nim` proc algo*[T] = proc a: T = result = initE[T]() result += 3 echo "algo", a() Run

Re: Naming conventions - need leading underscore

2020-01-16 Thread mratsim
Don't use the same name for the field and the proc. Also don't use `methods` when you don't need inheritance/dynamic dispatch it's a pessimization. Use `proc` instead. Lastly, naming conventions allow consistency within a language and depends on many factors. People don't complain about Python

Re: What is the keyword "end" reserved for?

2020-01-16 Thread Araq
It's probably way too late for this but I always had the idea of allowing (but not requiring) explicit `end if` etc markers: proc dasDing(arg: int): string = if arg == 0: result = "0" else: result = "not 0" end if end proc Run

Re: how to evaluate a code block in a different context in a macro

2020-01-16 Thread mratsim
I'm not exactly sure what you mean but I assumed that: * by context you mean scope, if so you can use a block statement * for compile-tie printing you can use `static` * You wanted to see 84 printed and not 48 import macros # this macro evaluates function body in a

Re: [vscode] Anyone willing to share his tasks.json needed to build nim files?

2020-01-16 Thread mratsim
Genuinely curious, why would VS Code tasks be preferable than a nimble file? You can't run VS Code tasks in CI for example which ultimately your local testing should be a mirror of.

Re: ELI5: newruntime and arc

2020-01-16 Thread Araq
> In short: I am lost. I don't know which mechanism will be used in place of a > GC. I don't know if that requires me, as a library author, to introduce sink > or lent parameters, which I still do not understand. (related to this, I have > stopped writing Nim libraries, because I am unsure

Re: Who would I implement simd to do fast md5 checksums ?

2020-01-16 Thread Yardanico
Well there are [https://github.com/jackmott/nim_simd](https://github.com/jackmott/nim_simd) and [https://github.com/bsegovia/simd.nim](https://github.com/bsegovia/simd.nim) for some SIMD wrapping

Re: Naming conventions - need leading underscore

2020-01-16 Thread sschwarzer
_At least_ in Python, an underscore at the beginning of a variable means it's private and shouldn't be accessed by client code. At some point I was wondering the same as the OP, but I think in Nim you just use the `*` suffix to distinguish "public" and "private" fields: type

Re: Naming conventions - need leading underscore

2020-01-16 Thread poseidon
A workaround, thank you. Yet I am new to Nim (coming from C, C++, Python) and wonder, what this.x then will mean in my Euler class. Is it the pointer to the method x or is it the attribute x? I consider this insensitivity being a severe restriction, the lang designers are pulling the users'

Re: Naming conventions - need leading underscore

2020-01-16 Thread poseidon
The comparison with a leading comma is misleading. It's not only about scope (private vs public) but about readability, when a leading underscore is used. Paul