[nem-en] 0000898: 'int' treated as an identifier even if used
without verbatim specifier (@)
Vladimir Reshetnikov
v.reshetnikov at gmail.com
Tue Feb 20 09:50:40 CET 2007
On 2/14/07, Kamil Skalski <kamil.skalski at gmail.com> wrote:
> Continuing discussion on
> http://nemerle.org/bugs/view.php?id=898
>
> I think it doesn't make sense to forbid using type name as variable
> references. Even ignoring the fact that int/string/ushort/etc. as
> plain type aliases, which we do not handle in any special way:
> type int = System.Int32;
>
> so this forbid would need to go to ALL type aliases.
> This clearly does not make sense, since it is still possible to do:
>
> using System;
>
> match (x) {
> | x as String => ...
> }
>
> The point is that user will be warned that the variable name "String"
> or "int" (in case of | x as int => ) is not used. So I don't think
> this is a real problem.
There are cases when programmer explicitly (via 'def' or 'mutable'
keyword) says that he wants to redefine meaning of an identifier in
the current scope. And those are rather clear (non-confusing) cases.
def Int32 = "Int32";
But in other cases redefinition occurs more or less implicitly (via
usage of an idenifier in a pattern, for instance).
| x as int => ...
If an identifier change its meaning from a type name to a variable, it
may be very-very confusing, particularly for beginner Nemerle users.
Warning does not help enough here.
We (VladD2, me and others) discussed this a lot at RSDN, so, we
urgently ask you to issue an error if an implicitly introduced
variable name hides a type.
It will prevent many mistakes, and we do not see any strong reasons against it.
More information about the devel-en
mailing list