C#5 desiderata

Simen kjaeraas simen.kjaras at gmail.com
Fri May 28 16:28:20 PDT 2010


bearophile <bearophileHUGS at lycos.com> wrote:

> Return tuples:

Absolutely. While it's possible today, some more sugar wouldn't hurt.


> in for arrays:

Yes.


> Automatic Flag Enums (automatically enumerate in powers of two).

Neat. Worthy an @keyword, I think. "@flag enum foo {...}"


> Null Safe Member Operator:
> var value = obj?.Bar?.Something?.DoSomething();

I feel this is a tad too sweet. On the one hand I like it, on the
other I feel it will lead to bugs at a later point, by hiding null
pointers and not teaching programmers to deal with them.
"Add a ? to all object accesses. It is magical and removes bugs."


> Weak delegates, to make it easy to implement weak events.

 From what I read about this, it seems nice, but also possible to
implement with current metaprogramming capabilities. Given an
event system, what are the advantages to language support for
this?


> Arrays indexed by enums, delphi style:

This seems to work for me in D2. But you probably meant an array
that has exactly the same number of elements as has the enum.
I can imagine this being a problem with enums having completely
random values (which they may). That might be even more of an
argument for @flag, as mentioned above. If non- at flag enums may
not expose internal details such as equivalent values, while
@flags may (to allow for composite flag shortcuts), you could
easily allow this for non- at flag enums.
Also, manifest constants should have a different name than
'enum', as they have nothing to do with enums.


> Exception grouping to avoid duplicating the same handling logic

Very nice.


> @memoize
>
> Or something similar user-defined. It is really useful, to avoid coding  
> true dynamic programming algorithms.

This again is to sweet for me. What does @memoize do? Does it
store the last 5 results? All results? The last result only?
Does it depend on the phase of the moon, time of day and what
socks I'm wearing?

> "as" operator for objects (This is already present in C#4).

So "a as b" rather than "cast(b)(a)" or "to!(b)(a)"? Or is there
some other magic at work that I don't see?

-- 
Simen


More information about the Digitalmars-d mailing list