Re: Confusion on implicit integer conversion.

2019-09-10 Thread Araq
IMO it's just a system.nim bug caused by misunderstandings about how generic parameters work.

Re: Confusion on implicit integer conversion.

2019-09-10 Thread mp035
@mashingan >tldr; if the size of integer is important, always opt to explicit conversion That seems to be very good advice. I was considering defining my own operators, but it seems like the first option is the most sensible. @mratsim I had never actually considered C to be a 'weakly typed' lang

Re: Confusion on implicit integer conversion.

2019-09-10 Thread mp035
@mashingan >tldr; if the size of integer is important, always opt to explicit conversion That seems to be very good advice. I was considering defining my own operators, but it seems like the first option is the most sensible. @mratsim I had never actually considered C to be a 'weakly typed' lang

Re: Confusion on implicit integer conversion.

2019-09-10 Thread mratsim
I'd also add to @mashingan answer than Nim is a strongly typed language. Lossless conversion are made explicit for safety reason, we don't want you to lose information or data by something done under-the-hood and very time-consuming to debug. Other strongly typed languages might just plain prev

Re: Confusion on implicit integer conversion.

2019-09-10 Thread mashingan
_tldr; if the size of integer is important, always opt to explicit conversion_ * * * you can define your own `+` operator for your case proc `+`(x: uint16, y: uint32): uint32 = x.uint32 + y Run But then the definition then become tedious if you have to define another

Small Details That Extend The Life of The Leaf Chain

2019-09-10 Thread kimminseok
Now the use of the leaf chain(GETECHAIN) [https://www.getechain.com/product/leaf-chain-product](https://www.getechain.com/product/leaf-chain-product)/ is still relatively large, and some of the prices of the leaf chain are relatively high, we all hope to buy a good quality leaf chain. Let's t

Re: Confusion on implicit integer conversion.

2019-09-10 Thread mp035
@cdome, thanks for the suggestion, but I am working with serial protocols involving integers of different lengths, so lenientops is not much help. It works by converting between int and float. @mratsim, thank you for the explanation. As an experienced user (I've seen your sig many times) can you

Re: Compiling fails with --gc:refc and --opt:speed

2019-09-10 Thread ThomasTJdev
Yes - but not at the exact moment when it crash. The CPU spikes almost immediately and stays up there, the memory has a quick high increase and then slowly keeps to increase. I don't have any data on the memory usage when it fails, I will setup a log to check it.

Re: Confusion on implicit integer conversion.

2019-09-10 Thread cdome
there is module in standard library: lenientops. it should help

Re: Confusion on implicit integer conversion.

2019-09-10 Thread mratsim
The signature of the proc is proc `+`[T: SomeInteger](x, y: T): T Run T is bound to uint32 in the first case, and we can convert uint16 to uint32 losslessly. In the second case, T is bound to uint16 and we can't convert uint32 to uint16 losslessly.

Re: Split on whitespace except for between quotes

2019-09-10 Thread Neil_H
Regex (w*b)*?|(?<=").*(?=")$

Confusion on implicit integer conversion.

2019-09-10 Thread mp035
Hi, I have a simple question. The Nim manual says that integer operations will promote the smaller of the two to the larger, but that behavior only seems to hold true with specific operand order, eg: `` var arg1:uint32 var arg2:uint16 arg1 = 10 arg2 =12 echo(arg1 + arg2) #works echo(arg2 + arg1