Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread pp
Why don't get rid of this for Nim 2.0? Is it overcomplicated?

Nim 2: What’s special about Task?

2022-10-26 Thread Araq
> simply because in the first block I initialized Runnable outside of arguments > list? Yes.

Change ref object variant in-place - drawbacks?

2022-10-26 Thread Araq
Orc supports this code IIRC but I think it's a bad idea.

Nim 2: What’s special about Task?

2022-10-26 Thread hamidrb80
I've looked at std/tasks page in the stdlib, and cannot understand why's first block does not work: import std/tasks type Runnable = ref object data: int proc hello(a: Runnable) = a.data += 2 block: let x = Runnable(data:

Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread sls1005
I've read the [second example](https://play.nim-lang.org/#ix=4e9w). It's really a problem. A use-element-address-after-moved bug, with no pointer or `addr` used explicitly.

Has 'IsNullOrEmpty' been deprecated?

2022-10-26 Thread chikegar
As you can tell, my C# training is tripping me up. Thanks for the clarification everyone! Cheers!

Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread matkuki
> Nim does "left-to-right" everywhere but it's a design bug for assignments: > assignments should be right-to-left. Has this been added to the issues on Github? > Well actually this is only 1 of the two issues I mentioned and I don't think > the issue I was facing was either of those. Could yo

Newbie first impressions

2022-10-26 Thread olmikul
Yes, for newbies it will be the true disaster - errors, dependencies hell, no example source code in gitlab/github, some unexplained words in examples and so on. But the book is not for newbies - om page 5 it is explicitly stated "this book for people who can already program". I would add - "an

Has 'IsNullOrEmpty' been deprecated?

2022-10-26 Thread sls1005
`isNil` for seqs and strings can still be found in the [documentation](https://nim-lang.org/docs/system.html#isNil%2Cstring), but marked as `{.error.}`.

Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread JohnLuck
Well actually this is only 1 of the two issues I mentioned and also I don't think the issue I was facing was either of those. But also, I do understand that these things are not easy to solve from a compiler perspective.

Change ref object variant in-place - drawbacks?

2022-10-26 Thread planetis
Your code shouldn't compile on devel (nimv2). The problems are many. For one the i member might now contain garbage, if it was a variable with an internal pointer like a seq/string/etc that could cause segmentation fault. Also is if you switch branches without freeing memory you get a memory lea

Change ref object variant in-place - drawbacks?

2022-10-26 Thread drkameleon
Let's say I have this type of _ref object_ : type ValueKind = enum Integer String Block Value = ref object case kind: ValueKind: of Integer: i: int of String:

Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread Araq
Nim does "left-to-right" everywhere but it's a design bug for assignments: assignments should be right-to-left. ;-)

Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread japplegame
This is a relatively well-known corner case. Different languages define the order of evaluation for assignments differently. **C++:** implementation defined. **D:** implementation defined. **Python:** order of evaluation is left-to right, but for assignment it's right-to-left. **Java:** chose

Tips on how to avoid Nim pointer instability bugs?

2022-10-26 Thread JohnLuck
Ok I will try that, thank you.