[nem-en] My thoughts on Nemerle
Kamil Skalski
kamil.skalski at gmail.com
Sun Jan 8 10:59:51 CET 2006
>
> The problem if we allow [Extension] on other than first parameter? Would
> this be compatible with extension methods in C# 3.0?
I don't thing this is a good idea. Let simply foo (this x : a) be a
syntax extension of macro foo (Extension x : a). This should Just Work
that way.
> >
> > Ah, this is one thing, which would require some additional effort in
> > implementation. I like your idea of requiring opening the class with
> > extension methods. It seems much more clean than the MS (One) way ;-)
>
> I'm not sure: while this seems cleaner, forcing people to write ten more
> 'using's in front of their file may not be that good idea.
Right. I imagine two use-cases, which would be lost this way:
- one declares extension module in top namespace and it would be nice
to have those methods available immediately in a whole program.
- One declares 10 extension modules, each grouping methods extending
one type. It would be much better to just open one namespace they are
in.
Also, maybe it would be easy to add a parameter to Extension macro,
like GloballyVisible, or
Visibility=global/"Nemerle.Utility.NString"/"bla". The default would
be the current namespace :)
> >
> > Well, I'm quite neutral about nullable types. I never needed them in
> > Nemerle / C# yet, though I like the idea of convenient (at least as
> > convenient as in Java 5) wrappers for value types, so maybe adding
> > this additional syntax wouldn't be a bad idea.
>
> I believe they are useful for static contract checking.
I don't think they have much relation to contract checking.
Non-nullable type checked by contracts validator is a implicitly
inferred information about normal nullable variables, like
def f (x : string) {
when (x == null) throw System.ArgumentException ("null");
x.Foo(); // we compiler can statically be sure, that x is of type
string! here
}
NonNullable (T!) is a different thing than Nullable (T?)
> >
> > Note that nullable types also have some special cases for typer, like
> > implicit conversions between T and T?. After I get used to this idea,
> > it seems quite nice.
>
> Maybe this is just op_Implicit in Nullable[T]?
public static implicit operator T?(T value)
Member of System.Nullable<T>
But I'm not sure if compler does some additional magic with respect to them.
I need some experiments... :)
If not, then this would be a really trivial feature - just add X?
alias for Nullable[X]
--
Kamil Skalski
http://nazgul.omega.pl
More information about the devel-en
mailing list