Do we really need const?

Janice Caron caron800 at googlemail.com
Tue Sep 18 12:41:23 PDT 2007


On 9/18/07, Bruce Adams <tortoise_74 at yeah.who.co.uk> wrote:
> > Under my suggestion, if the caller passes a struct...
> >
> > f(s)
> >
> > ...and the callee declares the function as...
> >
> > void f(S s)
> >
> > ...then all information is known. Both ends must surely know s.sizeof
> > at compile time? And since that's the /only/ thing the compiler needs
> > to know to make the decision.
> >
> S could be an opaque type so s.sizeof may still be undefined.

Could you explain further? I don't understand what an "opaque type" is
in D. Observe that the example I cited above explicitly states that s
be a struct, not a class.

Given that the struct would ordinarily have to be built on the stack
at the caller site, and copied onto the stack at the callee site, I
just don't see how s.sizeof can be unknown at the time the function is
instantiated, /even if/ was declared using a template. What am I
missing?



More information about the Digitalmars-d mailing list