built-in array ptrEnd
monarch_dodra
monarchdodra at gmail.com
Mon Sep 17 09:46:56 PDT 2012
On Monday, 17 September 2012 at 16:39:21 UTC, bearophile wrote:
> monarch_dodra:
>
>> IMO, this should really be built-in, in particular, since, in
>> my understanding, an array is internally represented by the
>> ptr and ptrEnd pair anyways.
>
> Currently this is not true, take a look at the ABI part in the
> D site. Currently it's a pointer and length. Walter and/or
> Andrei discussed the idea of turning them into two pointers,
> but I don't know if and why that change was refused.
>
> Bye,
> bearophile
Thank you for sharing. My guess would be this makes more sense,
since "arr.length" is the most called method. I *supposed* it was
this way, because C++ has a way of working with pairs of
pointers. That said, C is more of a pointer plus length approach.
Not that it should matter for us users anyways, such low level
implementation details should not leak into code. The pull is
purely for convenience. My "motivation" for making it built-in is
just that it makes sense to have it as such. You shouldn't have
to import a module just to (conveniently) get the end pointer.
More information about the Digitalmars-d
mailing list