pointer array?

Leandro Motta Barros via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 30 08:30:01 PDT 2014


Justin's  answers seems correct to me, and I don't know anything about your
specific use case, but I cannot resist to add:

Think twice before doing this kind of things. I know that sometimes this is
necessary or handy, but one of the great things about D is that it provides
so many higher-level abstractions that we should feel ashamed to not use
them.

So, yes, an array of void* will work in D, as will many of the classic
lower-level tricks used in, say, C. But when using them, the compiler will
not be able to help you much finding errors and such. As rule I'd say that,
if you can (and we usually can), try using something higher level. (In your
case, perhaps an array of objects of some base class, or implementing a
certain interface? Or some more radical redesign?)

Cheers,

LMB



On Wed, Jul 30, 2014 at 11:33 AM, seany via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> In Ali's excllent book, somehow one thing has escaped my attention, and
> that it the mentioning of pointer arrays.
>
> Can pointers of any type of pointed variable be inserted in an int array?
> Using to!(int) perhaps? If not directly, then what else would achieve the
> same effect?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140730/988bdb39/attachment.html>


More information about the Digitalmars-d-learn mailing list