Delayed const variable initialization
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 13 02:08:11 PDT 2015
On Mon, 13 Jul 2015 09:02:34 +0000, Yuxuan Shui wrote:
> IMO this is too restrictive. Can't we just spit compile error for uses
> before initialization, and allow const variables to be initialized
> somewhere other than where it is defined?
there is no "use before initialization", `x` is initialized at the
declaration site. this is by design -- there are no uninitialized
variables in D.
also, you want `const` to stop being `const`. or, `const` to became C++
`const`. and C++ `const` is `Rebindable`. ;-)
this is the way variable initialization and constness are defined in D,
and i don't think that design will change -- at least not in D2. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150713/78bb1787/attachment.sig>
More information about the Digitalmars-d-learn
mailing list