Re: Generic openarray param

2016-10-28 Thread Javi
Thank you. Wouldn't be a good idea to expand internally a convertible type like _openarray_ before matching? For example, expand **test[T](x: openarray[T])** as **test[T](x: (seq|array)[T])** And maybe create also a priority queue to try to match first with non-generic functions, and then try

Re: Nim in Action is now available!

2016-10-28 Thread dom96
> Which chapter was canceled? Chapter 10 Direct Hardware Control > I was going to buy it, but the chapter that I wanted is now cancelled. Sorry to hear that. Good news is that I am planning on writing a condensed version of it as an article.

Re: crashing closure iterator for file/directory searching object

2016-10-28 Thread jordan
I found the problem in the file lib/pure/os,nim and it does not look right to me. Looking at the implementation there is the defer clause on line 974. 972var d = opendir(dir) 973if d != nil: 974 defer: discard closedir(d) 975 while true: 976

Re: Generic openarray param

2016-10-28 Thread alex
Seems like overload resolution for generic procedures works incorrectly when generic parameters are limited by the type classes or concepts, or I mistake?

Re: Generic openarray param

2016-10-28 Thread alex
I tried next two variants and they are working as expected: #proc test[T](x: T) = # this signature doesn't work. Why?! proc test[T:not(array|seq)](x: T) = echo x proc test_impl[T](x: openarray[T]) = for i in x: echo i proc

Re: Generic openarray param

2016-10-28 Thread flyx
I wonder why this fails: type Iterable = concept c for i in c: discard proc test[T](x: T) = echo x proc test(x: Iterable) = for i in x: echo i test(1) test([1, 2, 3]) Shouldn't `Iterable` be a better match?

Re: Unable to compile with latest nim version

2016-10-28 Thread rishavs
woops! sorry, newb mistake. the problem was that the path of another installation of MingW was higher up in the tree than the nim one. used Rapid Env editor to restructure it and now it works fine. thanks.

Re: Generic openarray param

2016-10-28 Thread filwit
Just specialize within one generic function: proc test[T](x: T) = when T is seq or T is array: for i in x: echo i else: echo x test(1) test([1, 2, 3]) test(@[4, 5, 6])

Re: Nim in Action is now available!

2016-10-28 Thread halibetlector
Which chapter was canceled?