Re: Changing chained attributes of object taken by var - Is this desired behaviour?

2017-08-06 Thread PeterSR
I must have been tired when I wrote this code. I am pretty certain that I understand how the indirection works now. I just remember thinking that it was super weird that I could change something and then another variable suddenly changed its contents. But of course they pointed to the same

Re: Working with ZIP files

2017-08-06 Thread Araq
Can we get these fixes/improvements as a PR please?

Re: Working with ZIP files

2017-08-06 Thread Nox
Thanks, it seems to work fine, though I've already modified libzip to suit my needs It has one advantage over miniz that you can replace existing files in ZIP without unpacking everything. One downside of libzip is that precompiled binary that I have is linked to zlib1.dll and I guess there

Changing chained attributes of object taken by var - Is this desired behaviour?

2017-08-06 Thread PeterSR
Consider the following code to create linked list-like structure: type A = ref AObj AObj = object id: int parent: A child: A proc `$`(a: A): string = $a.id proc takeAsVar(curr: var A, next: A) = if curr == nil:

Re: casting address of pointer functions to a type

2017-08-06 Thread Araq
Your type `PFN_vkCreateDebugReportCallbackEXT` must have a calling convention like `stdcall` or `cdecl` for this to work. The default is `closure` which is actually a (fn, env) pair.

Re: Nim in Action is finally here

2017-08-06 Thread moigagoo
> Debugging Nim Programs and Using Nim on Microcontrollers OMG, so cool! I feel like a five-year-old waiting for Christmas

casting address of pointer functions to a type

2017-08-06 Thread Kerp
Hi again just need to know what i'm doing wrong on this subject But first here is my code var vkCreateDebugReportCallbackEXT = cast[PFN_vkCreateDebugReportCallbackEXT](vkGetInstanceProcAddr(inst,"vkCreateDebugReportCallbackExt")) i get a message from the compiler about

Re: Any method to set backend by configuration or nim code?

2017-08-06 Thread Libman
With a sufficiently ugly hack, all things are possible... import strutils static: proc getNimCompilerCmdLine(): string = return staticRead("/proc/self/cmdline").replace('\0', ' ') const nimCompilerCmdLine = getNimCompilerCmdLine()

Re: What can Nim learn from Crystal

2017-08-06 Thread bpr
@Araq > Which is at least one way too many... Drop `method`. @Honhon I agree that the Nim JS backend is interesting, but I would not try to argue for using it in our SW stack. Even OCaml is more of a contender in that space since [Reason](https://reasonml.github.io/) . I also agree that

Re: What can Nim learn from Crystal

2017-08-06 Thread honhon
Agree with BPR mostly. For me OOP is not really a big deal compared to V1.0 and in that regard Crystal has the same drawback as Nim. I think the obvious trade off with the more aggressive type inference is the much slower Crystal compiler. Also you can do things like this in Crystal which I

Nim in Action is finally here

2017-08-06 Thread dom96
Hey guys! As you may have already seen Nim in Action is now completely finished. I'd like to thank all of you for your patience and kind words throughout the development of this book. I'm excited to receive my copies of the book even though I must have read it at least 5 times by now.

Re: Any method to set backend by configuration or nim code?

2017-08-06 Thread Araq
Interestingly, you cannot do that for now. All you can do is to do something like when not defined(cpp): {.error: "compile via the 'cpp' command".}

Re: What can Nim learn from Crystal

2017-08-06 Thread Araq
My current plans for `method` are: * Change the semantics slightly: Only the first argument is considered in the dynamic lookups. Nothing else will change really. The only problem with that is that then we have 3 ways to do dynamic binding: 1. via closures. 2. via proc type fields with