Re: Template-style polymorphism in table structure

2016-09-09 Thread Kagamin via Digitalmars-d-learn
On Monday, 5 September 2016 at 06:45:07 UTC, data pulverizer wrote: I just realized that typeid only gives the class and not the actual type, so the object will still need to be cast as you mentioned above, however your above function will not infer T, so the user will have to provide it. I

Re: Template-style polymorphism in table structure

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 06:45:07 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type:

Re: Template-style polymorphism in table structure

2016-09-05 Thread data pulverizer via Digitalmars-d-learn
On Monday, 5 September 2016 at 06:45:07 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type:

Re: Template-style polymorphism in table structure

2016-09-05 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type: GenericVector!T getCol!T(size_t i) { if(typeid(cols[i]) ==

Re: Template-style polymorphism in table structure

2016-09-04 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: On Sunday, 4 September 2016 at 14:24:12 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:20:24 UTC, data pulverizer wrote: @Lodovico Giaretta BTW what do you mean that my code is not very D style? Please expand

Re: Template-style polymorphism in table structure

2016-09-04 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:24:12 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:20:24 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:07:54 UTC, data pulverizer wrote: @Lodovico Giaretta Thanks I just saw your update! @Lodovico Giaretta BTW what do you

Re: Template-style polymorphism in table structure

2016-09-04 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:02:03 UTC, Lodovico Giaretta wrote: Your code is not very D style ... Well I guess I could have contracted the multiple constructors in GenericVector(T) and and DataFrame?

Re: Template-style polymorphism in table structure

2016-09-04 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:07:54 UTC, data pulverizer wrote: @Lodovico Giaretta Thanks I just saw your update!

Re: Template-style polymorphism in table structure

2016-09-04 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:20:24 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:07:54 UTC, data pulverizer wrote: @Lodovico Giaretta Thanks I just saw your update! @Lodovico Giaretta BTW what do you mean that my code is not very D style? Please expand on this ...

Re: Template-style polymorphism in table structure

2016-09-04 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 09:55:53 UTC, data pulverizer wrote: My main question is how to return GenericVector!(T) from the getCol() method in the Table class instead of BaseVector. I think I just solved my own query, change the BaseVector interface to a class and override it in the

Re: Template-style polymorphism in table structure

2016-09-04 Thread ZombineDev via Digitalmars-d-learn
On Sunday, 4 September 2016 at 09:55:53 UTC, data pulverizer wrote: I am trying to build a data table object with unrestricted column types. The approach I am taking is to build a generic interface BaseVector class and then a subtype GenericVector(T) which inherits from the BaseVector. I then

Re: Template-style polymorphism in table structure

2016-09-04 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 4 September 2016 at 09:55:53 UTC, data pulverizer wrote: [...] Your code is not very D style and, based on your needs, there may be better ways to achieve your goal, but without knowing your use case, it's difficult to give correct advice. Talking about that writeln statement,

Template-style polymorphism in table structure

2016-09-04 Thread data pulverizer via Digitalmars-d-learn
I am trying to build a data table object with unrestricted column types. The approach I am taking is to build a generic interface BaseVector class and then a subtype GenericVector(T) which inherits from the BaseVector. I then to build a Table class which contains columns that is a BaseVector