Re: Problem getting the element type of a generic container

2019-02-28 Thread mratsim
I tried the same with getTypeInst but got V symbol instead of an expansion :/

Re: Problem getting the element type of a generic container

2019-02-26 Thread gemath
Any problem on Earth can be solved with the careful application of meta-programming. The trick is not to be around when the AST spec changes. :o) import macros type Range[V] = object v: V slice: Slice[int] var r: Range[seq[int]] = Range[seq[int]](v: @[0,

Re: Problem getting the element type of a generic container

2019-02-25 Thread mratsim
Regarding lazy ranges, @timotheecour was interested in implementing D ranges in Nim, see [https://github.com/timotheecour/vitanim/tree/master/drange/src/drange](https://github.com/timotheecour/vitanim/tree/master/drange/src/drange). I often struggled with the same need, Nim offers genericHead bu

Problem getting the element type of a generic container

2019-02-22 Thread juanv
This is a type to represent lazy ranges parametrized by the container type: type Range[V] = object v: V slice: Slice[int] var r: Range[seq[int]] = Range[seq[int]](v: @[0, 10, 20, 30, 40], slice: 2..3) # r represents the range [20, 30] var x : r.v[0]