More type-flexible arrays?

Ozan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 15 02:13:55 PDT 2015


On Sunday, 14 June 2015 at 06:43:48 UTC, ketmar wrote:
> On Sun, 14 Jun 2015 06:12:29 +0000, Ozan wrote:
>
>> Hallo!
>> 
>> Is it possible to create arrays which has more then one type,
>> f. ex. array[0] = 1; array[1] = "z"; array[2] = new clazz(), 
>> ....
>> 
>> I tried "Variant", but it slow down heavily my app.
>
> it is possible. with Variant. ;-)
>
> chances are that you're doing something by the wrong way in 
> your code. not syntactically wrong, but algorithmically wrong. 
> why to you need such an array? weak typing is slow. strong 
> typing is fast. seems that you are used to scripting languages 
> with weak typing, and designed your algorithm with weak typing 
> in mind. i think it's better to try to redesign your algorithm, 
> not looking for faster weak typing solution.

Thanks for your advise.
You read my mind. It's a strong Groovy background.
I think with D, I'm on right way to solve my personal problems ;-)

Regards Ozan


More information about the Digitalmars-d-learn mailing list