PhobosWatch: manifest => enum
"Jérôme M. Berger"
jeberger at free.fr
Sat Dec 29 15:14:48 PST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Walter Bright wrote:
> Jérôme M. Berger wrote:
>> Walter Bright wrote:
>>> Yes, that could be done, but we're still stymied by the problem that we
>>> are unable to declare a constant of type 'int', only 'const(int)'.
>>
>> I don't see any situation in which we would need a constant of type
>> "int" instead of "const (int)" or "invariant (int)". After all, if
>> it is a *constant*, it should be either "const" or "invariant", no?
>
> Consider the following:
>
> const int X = 3;
> auto i = X;
> i = 4; // error, i is const
>
> Essentially, it would make type inference far less useful.
Except that this is a different issue, on which I rambled at some
length here:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=64262
Basically, "auto" should drop the tail-most "const" if the language
allows such types to exist and keep the "const" when it can't be
dropped, e.g:
- "const int" => "int";
- "const (T*)" => "(const (T))*" (if such is allowed);
- "const (MyClass)" => "const (MyClass)" (since the tailmost type
is actually the hidden reference type).
This should be done whether the right-hand expression is a manifest
constant, a "const" variable or an "invariant" variable.
Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
| mailto:jeberger at free.fr | ICQ: 238062172 |
| http://jeberger.free.fr/ | Jabber: jeberger at jabber.fr |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFHdtTnd0kWM4JG3k8RAtvGAKCKVXzhXMe286aco7/2ruWJl4KbiACfYgoE
8UPHk7cbO7bDQt9Q04tDnj0=
=DyHZ
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list