Re: GC:ARC passing '...' to a sink parameter introduces an implicit copy; use 'move(...)' to prevent it

2020-03-03 Thread cumulonimbus
If so, please make the current aggressive warning an option - and provide copy() to suppress it. Not sure what the default should be, but one of the the reason I switched back from C++ back to C is because it's way too easy to introduce unwanted operations (copies and other) -- which is usually

what [T] means in nim?

2020-03-03 Thread hany33
type GraphMap[T] = ref object > keyToNode: Table[T, Node] > > nodeToKey: Table[Node, T] proc newGraphMap[T](): GraphMap[T] = result.new() result.keyToNode = initTable[T, Node]() result.nodeToKey = initTable[Node, T]()

Re: parallel: bounds checker

2020-03-03 Thread Stefan_Salewski
You may see Araq's reply in [https://forum.nim-lang.org/t/4827#30222](https://forum.nim-lang.org/t/4827#30222)

Re: How to get immidiate disk-usage

2020-03-03 Thread Stefan_Salewski
If this really should be not spam then you may see [https://forum.nim-lang.org/t/5861](https://forum.nim-lang.org/t/5861)

How to get immidiate disk-usage

2020-03-03 Thread MinusMyX
Is there something similar to Java's File.length() method? I would like to know the immediate disk usage for a directory. A (1K) -> B (3k) -> C (9k) Here, directory A's immediate disk usage is 1k. What proc provides me this information? (Reference Java solution): public static long

Re: Nim devel branch: compiler doesn't throw an error when a variable is used after move-ing it

2020-03-03 Thread leorize
Looks like what you found was a bug in ARC :) [https://github.com/nim-lang/Nim/commit/8705ee7015382ac2957733dfef5e02a0831e7fb4](https://github.com/nim-lang/Nim/commit/8705ee7015382ac2957733dfef5e02a0831e7fb4)

Re: psuedo RFC for async Channels and FlowVars

2020-03-03 Thread rayman22201
The underlying mechanism needed for this is here: [https://github.com/nim-lang/Nim/pull/12372](https://github.com/nim-lang/Nim/pull/12372) It contains a race condition that needs to be fixed, and then flowVar refactored to use this mechanism. Unfortunately, Progress has stalled due to several

Re: GC:ARC passing '...' to a sink parameter introduces an implicit copy; use 'move(...)' to prevent it

2020-03-03 Thread trtt
I think this warning _would be_ super-useful and a major feature if it would be supported properly. Copying regular structs is not a good idea - explicitly notifying users about copies would be nice for performance sensitive programs.

Re: Nim devel branch: compiler doesn't throw an error when a variable is used after move-ing it

2020-03-03 Thread trtt
@leorize \- when I use the variable first to calculate the other thing and _then_ move it, there is no segfault. If I don't move at all there is also no segfault.

FFI questions - VapourSynth

2020-03-03 Thread mantielero
I am just playing around with FFI just for my learning (I am a newbie). I have the code [here](https://github.com/mantielero/VapourSynth.nim). I will put in this thread my questions. My first question is about how to make an struct with methods: *

parallel: bounds checker

2020-03-03 Thread daef
how can i satisfy parallel bounds checker in this example? it fails with test.nim(18, 19) Error: cannot prove: y * w8 + x <= len(s) + -1 (bounds check) strutils import math import threadpool {.experimental: "parallel".} proc getc() : char = 'b' let

Re: GC:ARC passing '...' to a sink parameter introduces an implicit copy; use 'move(...)' to prevent it

2020-03-03 Thread cdome
There is no copy() yet, but I think it is good idea. I suggest placing it at github as a feature request issue.

Re: GC:ARC passing '...' to a sink parameter introduces an implicit copy; use 'move(...)' to prevent it

2020-03-03 Thread Araq
This warning is much too aggressive, I'm thinking of a better heuristic. One idea is that the warning will only be produced for `seq` as usually that's the really expensive copy.

Re: Nim devel branch: compiler doesn't throw an error when a variable is used after move-ing it

2020-03-03 Thread leorize
If you do an explicit move, the variable will be cleared, so it can be reused. The segfault is an indicator of a different problem.

Nim devel branch: compiler doesn't throw an error when a variable is used after move-ing it

2020-03-03 Thread trtt
type Example* = object str: string code: int proc x0(s: string): int = s.len proc x1(b: bool): Example = var x = "abc" if b: return Example(str: move x, code: x0(x)) else: return Example(str: "...") echo x1(true)

GC:ARC passing '...' to a sink parameter introduces an implicit copy; use 'move(...)' to prevent it

2020-03-03 Thread trtt
Is there a copy operator I can use to suppress this hint? Both the move() and copy operators can be useful in certain situations.

Re: Some rant about nim

2020-03-03 Thread sschwarzer
Regarding `with` and `else` in Python: $ cat with_else.py with open("/etc/passwd") as fobj: pass else: pass $ python3.8 with_else.py File "with_else.py", line 3 else: ^ SyntaxError: invalid syntax Run At least

Re: Some rant about nim

2020-03-03 Thread r3c
Yap, compiling with -d:release only adds range checker helper function static N_INLINE(NI, chckRange)(NI i, NI a, NI b) Run This is a design decision, should the codegen generate range checker with -d:danger, not my call :P

Re: Some rant about nim

2020-03-03 Thread leorize
Well it said `-d:danger` (in case you don't know, it disables all runtime checks). Also you won't be able to find types like these in C, because they just don't exist. Nim instead implements these via checked conversions IIRC.

Re: Some rant about nim

2020-03-03 Thread juancarlospaco
$ cat example.nim type iX = range[1..5] var a: iX = 3 var b = 10 a = b $ nim c -r -d:release -d:danger --rangeChecks:on example.nim Hint: 8022 LOC; 0.029 sec; 11.656MiB peakmem; Dangerous Release build; proj: Hint: /home/juan/code/temp1/example [Exec]

Re: Some rant about nim

2020-03-03 Thread r3c
type iX = range[1..5] var a: iX = 3 var b = 10 a = b Run When you compile this with -d:release -d:danger it doesn't throw any error. In the generated C file, type iX doesn't exist at all

Re: nimkernel capabilities

2020-03-03 Thread enthus1ast
I think the "kernel" is more or less a proof of concept / experiment. If you find it Interesting: play with it! I can imagine dom96 is open for pr's.

Re: Some rant about nim

2020-03-03 Thread juancarlospaco
It is _not_ a macro. :)

Re: Some rant about nim

2020-03-03 Thread Somerandomguy
In the ideal world,this should compile var b = 10 var a: iX = 5 if b >= 1 and b<=5: a = b Run and if you remove that `if` it doesn't. Of course it is hard(it's called subtraction type or something) Otherwise it is still implicit downcast and it's

Re: how to deal with C string with \0?

2020-03-03 Thread Ward
You can try running this code with different mode: import winim/lean, strutils var bufLen = GetLogicalDriveStrings(0, nil) var buffer = T(bufLen) GetLogicalDriveStrings(bufLen, buffer) echo buffer echo buffer.repr echo ($buffer).repr echo

Re: Module queues is not working? Is it deprecated?

2020-03-03 Thread hany33
Thanks

Re: Some rant about nim

2020-03-03 Thread Somerandomguy
I know it's trivial, but it's still nice to have, and I'm against overuse marco. Now support the `else` branch too.

Re: Some rant about nim

2020-03-03 Thread timothee
> It's known at compile time as int32 int, not int32 > It's known at compile time as int32, not iX, while nim compiler totally > ignores this and assume they are compatible. But they aren't. [...] the more > sane option is not provide a subrange type in the first place. again, not-a-bug.

Re: Module queues is not working? Is it deprecated?

2020-03-03 Thread enthus1ast
Think it is called dqeues now [https://nim-lang.org/docs/deques.html](https://nim-lang.org/docs/deques.html)

Re: Module queues is not working? Is it deprecated?

2020-03-03 Thread hany33
import queues var q = initQueue[int]() q.add(8) q.add(18) Error: cannot open file: queues

Re: Module queues is not working? Is it deprecated?

2020-03-03 Thread Varriount
What problems are you having? Can you post code that demonstrates your problems?

Re: Some rant about nim

2020-03-03 Thread juancarlospaco
That is literally an example on the documentation: [https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates)

Module queues is not working? Is it deprecated?

2020-03-03 Thread hany33
Is it deprecated?

Re: Some rant about nim

2020-03-03 Thread Somerandomguy
> b is know at RT, not CT. It's known at compile time as int32, not `iX`, while nim compiler totally ignores this and assume they are compatible. But they aren't. Of course it's hard to use CFA or whatever technique to make compile time check possible, but the more sane option is not provide a

Re: Nested list comprehension

2020-03-03 Thread whospal
@trtt & @miran, Thanks very much. Yes, i notice I made the mistake of the return type in the proc.

Re: Nested list comprehension

2020-03-03 Thread miran
There are few problems with your Nim version, e.g. returning `string` instead of `seq[string]` (cause this is what the Python version does - it returns a list). Here is a correct Nim version: proc cross(xs, ys: string): seq[string] = ## Cross product of elements in A and

Re: Nested list comprehension

2020-03-03 Thread trtt
That's not list comprehension in nim, you just iterated over two strings and then joined the elements without using them. proc cross(a, b: string): seq[string] = for ac in a: for bc in b: result.add(ac & bc) let digits = "123456789" let letters =

Nested list comprehension

2020-03-03 Thread whospal
Hi, I'm new to Nim-lang. I wanted to convert a Python script to Nim to improve my understanding of Nim. I have the following Python code: # Python codes: def cross(A, B): """Cross product of elements in A and elements in B.""" return [a+b for a in A for b in B]

Re: do we need travis+appveyor in nim repo now that we have azure-pipelines?

2020-03-03 Thread miran
> and it translates in a badge saying build failing or passing on > [https://github.com/nim-lang/Nim](https://github.com/nim-lang/Nim) Nothing has been pushed after I disabled Travis. So don't jump to conclusions just yet.

Re: do we need travis+appveyor in nim repo now that we have azure-pipelines?

2020-03-03 Thread timothee
[https://travis-ci.org/nim-lang/Nim](https://travis-ci.org/nim-lang/Nim) still shows at least travis is still in use; and it translates in a badge saying build failing or passing on [https://github.com/nim-lang/Nim](https://github.com/nim-lang/Nim)

Re: How to declare a thread-global variable?

2020-03-03 Thread trtt
createShared doesn't really work well with datatypes like Table.