[nem-en] Some problems with typeof operator (when applied to a tuple type)

Kamil Skalski kamil.skalski at gmail.com
Wed Feb 14 20:09:14 CET 2007


This is a feature we implemented to mimick C#'s  typeof (A<,,>)
ability to reflect open types. So this is not by accident - it simply
does not work as expected for tuples, which give closed System.Type
for _*_

2007/2/14, Michal Moskal <michal.moskal at gmail.com>:
> On 2/14/07, Vladimir Reshetnikov <v.reshetnikov at gmail.com> wrote:
> > [nemerle]
> > using System.Console;
> >
> > class A[T,S] { }
> >
> > WriteLine(typeof(A[_,_]).IsGenericTypeDefinition); // True
> > WriteLine(typeof(A[_,_]).Equals(typeof(A[object,object]))); // False
> >
> > WriteLine(typeof(_ * _).IsGenericTypeDefinition); // False
> > WriteLine(typeof(_ * _).Equals(typeof(object * object))); // True
> > [/nemerle]
> >
> > Obviously, that (_ * _) is treated as closed constructed polymorphic
> > type (object * object), not as unbounded polymorpic type (_ * _), that
> > is Nemerle.Builtins.Tuple[_,_].
> > IMO, this is an error.
>
> This is because _ is treated as "fresh type variable" in most type
> contexts, so I think this is some kind of special case for typeof.
>
>
> --
>    Michał
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
>


-- 
Kamil Skalski
http://nazgul.omega.pl


More information about the devel-en mailing list