New in C#4
Bent Rasmussen
IncredibleShrinkingSphere at Gmail.com
Mon Nov 10 14:15:27 PST 2008
The nestable object literal syntax obsoletes some cases where constructutors
were used before, and where named arguments would be used, but clearly not
all (deterministic initialization) - it can be used to initialize properties
via new Person() { First = "Bob", Last = "Smith" }; I can't remember the
exact syntax.
- Bent
"bearophile" <bearophileHUGS at lycos.com> skrev i meddelelsen
news:ge9sf5$1vdc$1 at digitalmars.com...
> Thanks to Reddit I have found a nice short document that lists some of the
> differences of C#4:
> https://docs.google.com/View?docid=dcj4xk6_17ffc7nmgv
>
> They have added a dynamic invocation, useful if you want to implement a
> dynamic language (like IronPython, IronRuby, etc) on top of the dotnet.
> Object-C shows this is doable in a very C-like language, and the Boo
> language shows that in a statically typed language it can be useful to use
> a Duck type once in a while to reduce the "static type pressure". More
> info on this last concept in the Boo site.
>
> Something that I like a lot is the named arguments, that I hope to see in
> D and Delight someday. They are used often in Python, and they help
> increase the readability of the code, sometimes even reducing mistakes.
> They have used colons:
> foo(x: 1, z: 3)
> While Python uses equal signs:
> foo(x=1, z=3)
> I think they are about equally readable.
> (I think there's a problem with named arguments, that you can solve in
> some ways, for example with an extra hidden bitfield argument that encodes
> what arguments are given and what not).
>
> Bye,
> bearophile
More information about the Digitalmars-d
mailing list