null [re: spec#]
Jonathan M Davis
jmdavisProg at gmx.com
Mon Nov 8 17:38:47 PST 2010
On Monday, November 08, 2010 15:23:40 Walter Bright wrote:
> dsimcha wrote:
> > While I'm also skeptical of the idea that simply declaring a variable can
> > cause arbitrarily complex code to be executed, I'll play Devil's
> > Advocate a little: What if we required the default struct constructor to
> > be nothrow? We could also require some level of purity (at least weak
> > pure).
>
> Not a bad idea, but this still leaves people nowhere who need non-trivial
> construction in order to have a valid object.
Well, if it's a default constructer which has to be nothrow and maybe pure or
nothing, I'll take the default constructor. Now, if there's a better way to
handle this which would result in full-blown, arbitrary default constructors,
then that would be better, but something is better than nothing.
Another thought relates to the discussion of @disable on a struct's default
constructor to disable init. What if we allowed default constructors but
disabled init in the same way that we'd be doing with @disable? So, a struct
uses init if it has no default constructor, but if it has one, then you can't
use it where init would be required. Would that help fix things? It certainly
would make some sense given that when using a default constructor, you don't
really want init anyway. It could just be annoying with static arrays and the
like (though = void should make it possible to make that work I think, if you
really need to).
- Jonathan M Davis
More information about the Digitalmars-d
mailing list