Re: About Nim memory management

2017-12-30 Thread jibal
Compare the generated code. let probably puts the pointer somewhere that valgrind considers accessible.

Re: About Nim memory management

2017-12-30 Thread woggioni
Maybe, it's a problem with valgrind, if I run it with \--show-leak-kinds=all I can see the leak in both cases, even if is considered 'definitely lost' in the discard case and 'still reachable' in the let case (which still I do not fully understand but I will search on Valgrind documentation the

Re: About Nim memory management

2017-12-30 Thread woggioni
yes, that' basically what happen.. I'll just add that the above example can be simply rewritten in this way import libcurl discard global_init(GLOBAL_DEFAULT) let curl = easy_init() with the same results depending on the presence of the discard keyword in spite o

Re: Prevent accidental object copies

2017-12-30 Thread cdome
Udiknedormin, nice trick thanks for sharing

Re: Problem with default values for a generic parameter

2017-12-30 Thread doofenstein
Thank you for responses, I created an issue on Github: [https://github.com/nim-lang/Nim/issues/7000](https://github.com/nim-lang/Nim/issues/7000) Does somebody knows of a workaround to this issue? For now the only thing I can do is probably to just remove the default values.

Re: About Nim memory management

2017-12-30 Thread twetzel59
That's definately odd. So, as I understand, it doesn't leak when a let binding is used?

Re: ASM on Windows basically dead?

2017-12-30 Thread cheatfate
@monster, you can easily find information and even youtube video, how to setup Visual Studio 2017 to compile assembler files. Microsoft Macro Assembler is a part of Visual Studio by default.

Re: I'm getting a type mismatch despite using a type cast

2017-12-30 Thread monster
@Udiknedormin I can't say 100% for sure, because now I get some error that it cannot find the required "Interlocked" function (maybe wrong version of Visual Studio installed?), but at least the original error message is gone, so I think your solution worked.

Re: I'm getting a type mismatch despite using a type cast

2017-12-30 Thread Udiknedormin
# Replace: proc atomicIncRelaxed*[T: AtomType](p: VolatilePtr[T], x: T = 1): T # with: proc atomicIncRelaxed*[T: AtomType](p: VolatilePtr[T], x: T = 1.int32): T Note it will still work for int64 thanks to the conversion. The reason of this problem is that int32 is int at the

Re: ASM on Windows basically dead?

2017-12-30 Thread monster
@cheatfate So, I _could_ still code something like interlockedExchangeAddNoFence64() in ASM, and use it both in 32-bits and 64-bits with MSVC, but I have to put it in a separate ASM file? And maybe explicitly "compile" (not sure if this is the right term) it with some ASM tool? I currently have

Re: Prevent accidental object copies

2017-12-30 Thread Udiknedormin
Well, the whole problem is that = can't be AST-overloaded. That would be the best and most nimish solution. However, I found three other solutions as well, one of which I will quote. Sadly, all three require patterns so if you use \--patterns:off, the checks will be disabled. Here it comes, the

Re: Problem with default values for a generic parameter

2017-12-30 Thread yglukhov
@doofenstein, I think your issue is worth reporting. Your code looks pretty valid.

Re: Problem with default values for a generic parameter

2017-12-30 Thread Udiknedormin
In fact, I consider it a bug in the compiler that the following doesn't work: proc button*[W, H: UILength = UIAbsLength](self: UISystem, buttonLabel = none(string), width = W(0.0),

Re: ASM on Windows basically dead?

2017-12-30 Thread cheatfate
Inline assembler works only for 32bit target architecture in MSVC, 64bit is not supported, but you still able to make asm file and compile it for both 32/64bit architectures.

Re: Error invalid module name: nim_1.1.1

2017-12-30 Thread jibal
> No, I can't! It has nothing to do with the input file name! You mean that it has nothing to do with the output file name, surely. I don't know why Ar would think his suggestion was relevant.

Re: Problem with default values for a generic parameter

2017-12-30 Thread jibal
The error message seems strange, but you really can't expect this to work. At compile time, width and height are UILength, not UIAbsLength, so your when tests will fail. You need a template if you want to generate different code depending on the type at the call site. And if you want the decisio

Re: Prevent accidental object copies

2017-12-30 Thread sendell
if you're ok with a var object, you can do: type Person = object first, last: string proc init(self: var Person, first, last: string) = self.first = first self.last = last proc `=`*[T](d: var Person; src: Person) {.error.} = discard va

Problem with default values for a generic parameter

2017-12-30 Thread doofenstein
I have a procedure which should accept two units(absolute width and width relative to the parent widget). For this purpose I created two distinct types and a typeclass which contains both: type UIAbsLength = distinct float32 UIRelLength = distinct float32