Re: compile time code execution problem

2017-11-04 Thread Stefan_Salewski
> Coming from Ruby/Elixir, Maybe some C exercises would help Note that modpg.unit and rescnt.uint are not plain casts (reinterpretation of bit pattern) but type conversions. Type conversions may ensure that the values are not negative before conversion and raise exceptions otherwise. I don't

Re: Bitwise lowercase

2017-11-04 Thread olwi
rotated = rotated or rotated # is this correct? I doubt this is correct. For any `x`: expression `x or x` gives just `x` (always), so this line is equivalent to rotated = rotated which is pointless and does nothing (unlike the original `rotated &= ~c;`).

Re: Bitwise lowercase

2017-11-04 Thread Stefan_Salewski
Dippo, your observations is interesting. It is very obvious that something strange is going on... For your test code the implementation of toLowerAscii() should have nearly no impact, as that operation is really trivial and gcc is smart. Note that it is generally recommended to put all your

Re: Why isn't this concept working as I would expect?

2017-11-04 Thread stisa
This works for me: type ConceptA = concept c ConceptB = concept c c.myProc(ConceptA) Obj = object proc myProc(obj: Obj, x: ConceptA) = discard echo Obj is ConceptB #true As for why, I'm not really sure as

Re: Bitwise lowercase

2017-11-04 Thread Dippo
The source is from Facebook, it can be found here: [https://github.com/facebook/folly](https://github.com/facebook/folly) I see now it uses Apache 2.0 license, not MIT.

Re: compile time code execution problem

2017-11-04 Thread jzakiya
Hey thanks for the help! Here's what I had to do to get it to compile/work fully (using Nim 0.17.2). proc genPGparameters(prime: int): (int, int, int, seq[int]) = echo("generating parameters for P", prime) let primes = [2, 3, 5, 7, 11, 13, 17, 19, 23] var

Bitwise lowercase

2017-11-04 Thread Dippo
Hello all, Everybody here wants to make Nim the best language ever made. The question is however, can we take code from other projects to use in Nim? The reason i am asking this is because i found a website that contains allot of cool tricks to make Nim faster. They are using the MIT license,

Re: compile time code execution problem

2017-11-04 Thread mikra
Hi woggioni, the static code block is executed at compiletime inside the vm. you cannot access the parameters outside the block. It´s out of scope. This is why you get undecleared identifier. But indeed there should be a meaningful error message instead of the compiler complain. this works:

Missing methods/properties/objects in JS Backend

2017-11-04 Thread grazil
Hello, I have detect two missing things in JS Backend. First the method **removeEventListener**, that i have wrote taking **addEventListener** as example: proc removeEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), useCapture: bool = false) {.importcpp.}

Re: compile time code execution problem

2017-11-04 Thread woggioni
If you want to unpack the tuple you have to declare the resulting variables first, like this: proc foo(): (int, int, int) = (1,2,3) static: var a,b,c : int (a,b,c) = foo() echo a,b,c what is quite strange is that this does not pass gcc

Re: compile time code execution problem

2017-11-04 Thread mikra
Hi jzakiya, you simply can not use brackets within your constant-name. Here is the BNF which literals are allowed: [https://nim-lang.org/docs/manual.html#lexical-analysis-numerical-constants](https://nim-lang.org/docs/manual.html#lexical-analysis-numerical-constants) As long as your tuple have

Re: compile time code execution problem

2017-11-04 Thread woggioni
This should work import math proc genPGparameters(prime: int): (int, int, seq[int], int) = echo("generating parameters for P", prime) let primes = [2, 3, 5, 7, 11, 13, 17, 19, 23] var modpg = 1 var excluded_primes = 0 for prm in primes:

Re: compile time code execution problem

2017-11-04 Thread jzakiya
I do `import math` to get `gcd` in my program, that's why you got that error. I still can't get the output from `getPGparameters` assigned to constants of the same names, to be used later in the program. I thought you could do assignments like: const (a, b, c) = tuple(x, y, z)

Re: How do you get thread count in Nim

2017-11-04 Thread JohnS
For Linux systems, this is how I do it in the [psutil library](https://github.com/johnscillieri/psutil-nim): proc cpu_count_logical*(): int = ## Return the number of logical CPUs in the system. try: return sysconf( SC_NPROCESSORS_ONLN ) except

Re: compile time code execution problem

2017-11-04 Thread mikra
Hi jzakiya, for me I will get: Error: undeclared identifier: 'gcd' (also when you type the run-button below your code snippet). >From the tutorial: >[https://nim-lang.org/docs/tut1.html#constants](https://nim-lang.org/docs/tut1.html#constants)