How does D distnguish managed pointers from raw pointers?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Oct 4 19:16:33 UTC 2019


On Fri, Oct 04, 2019 at 07:08:04PM +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:
> On Friday, 4 October 2019 at 19:03:14 UTC, Dennis wrote:
> > You're right, I'm confused. I recall there was a situation where you
> > had to explicitly slice a static array, but I can't think of it now.
> 
> When passing to a range template it is necessary, otherwise the
> template will see it as non-resizable and it will fail the range
> constraint check.
> 
> (personally though I like to explicitly slice it all the time though,
> it is more clear and the habit is nice)

Yeah, and it's always better to consciously slice it, and therefore be
reminded to think about the implications of slicing it, so that you'll
be aware not to let the slice leak past the lifetime of the underlying
static array.


T

-- 
Unix was not designed to stop people from doing stupid things, because that would also stop them from doing clever things. -- Doug Gwyn


More information about the Digitalmars-d-learn mailing list