*** New C# Language V2.0 Specification Now Available ***

  • Thread starter Thread starter Eric Gunnerson [MS]
  • Start date Start date
E

Eric Gunnerson [MS]

You may download the new specification at the C# Developer Center
(http://msdn.microsoft.com/vcsharp/language). There is a discussion forum
for the C# language on that same page.


If you don't own a copy of MS Word, you can download the free viewer at:

http://www.microsoft.com/downloads/...60-E4F3-436D-A5A7-DA0E5431E5C1&displaylang=EN


--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Eric Gunnerson said:
You may download the new specification at the C# Developer Center
(http://msdn.microsoft.com/vcsharp/language). There is a discussion forum
for the C# language on that same page.

<snip>

Any word on when the other new features in C# are likely to be released
in a specification (draft or otherwise)? I'm looking forward to seeing
exactly how properties with different access modifiers for the accessor
and mutator are specified. (That and whether or not a property will be
able to define its own variables which aren't accessible outside the
property itself.)
 
It's a draft . See the page's C# 2.0 Specification paragraph.

Willy.


Jesse said:
Is that the new spec or is it the new "draft" spec.........hmmmm
 
Eric Gunnerson said:
You may download the new specification at the C# Developer Center
(http://msdn.microsoft.com/vcsharp/language). There is a discussion forum
for the C# language on that same page.

I now have three C# language specs:

C# Language Specification (from Microsoft), dated 2001
ECMA-334, dated 2002
C# Language Specification v1.2, dated 2003

Where can I find descriptions of how they differ?
 
I don't like the verbose syntax "yield return" and "yield break". Why not
simply "yield" and "return"?

If someboy sees "return" he expects the end of the method. Why not
preserving this?

Yield is only reserved within iterator methods so there should really be no
problem with code breaking. Even if someboy was so stupid to use "yield" as
identifier - this is quickly corrected, as yield is not reserved as class,
method, property-name, only locals would be affected and ONLY within
iterator methods! Already built assemblies are not affected.
 
Partials are just stupid, and anonymous methods, argue all you want about
spaghetti code, its still spaghetti code.

The only real gain from 2.0 is generics

Still doesnt fix all the gaps in libraries, how much time is wasted wrapping
things that should have been wrapped. how much of a typical project has to
end up going to native calls. Time wasted in my view.
 
Partials are just stupid

I have a bad feeling about them too but look into reality programming. Often
Forms-classes can get really huge and now imagine you are working in a team
and more than 1 programmer wants to work on that class. Additionally
automatically generated code can be separated from written code. Maybe they
aren't as bad when you once get used to them-
, and anonymous methods, argue all you want about
spaghetti code, its still spaghetti code.

It depends. Imagine you have 30 controls in one form and have to add a
eventhandler to each of them where the handling code is just a few lines
each time. Do you want to write 30 methods and make sure that each method
belongs to excact one handler and you don't left one out or want to define
the eventhandling methods where they are used?
The only real gain from 2.0 is generics

Indeed! No more stupid unneccessary casting!
Still doesnt fix all the gaps in libraries, how much time is wasted wrapping
things that should have been wrapped. how much of a typical project has to
end up going to native calls. Time wasted in my view.

..Net isn't a wrapper to the Windows API or to COM objects. It is a
independent platform (although it runs only on windows-how funny :) )
When you want to use functionality which is not part of .Net you have to use
Interop and build your own wrappers.

In my experience native calls are very rarely used. On which kind of
projects do you work where you need to many native stuff?
 
The first two should be identical, though the ECMA one has different
numbering.
The third one has some clarifications and updates, and a new introduction.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 
We had originally used "yield" by itself, but unfortunately, that would
require us to add a new keyword to the language, which has the potential to
break current code. By using "yield return", we don't have to do this.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 
--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
cody said:
I have a bad feeling about them too but look into reality programming. Often
Forms-classes can get really huge and now imagine you are working in a team
and more than 1 programmer wants to work on that class. Additionally
automatically generated code can be separated from written code. Maybe they
aren't as bad when you once get used to them-

The big goal for partial classes *is* for generated code. Being able to keep
that separate from the user code simpifies the user model.
 
Partials are just stupid, and anonymous methods, argue all you want
about spaghetti code, its still spaghetti code.

Anonymous methods are indeed something I'll probably never use, but
Partial types are a thing that should have been present in v1.0 (as generics
should have been too). Partial types gives you the ability to separate
generated code from handwritten code, which is important for code generates,
something that will be used more and more. Even vs.net generates code for
you, which can now be separated from your own code (which is a plus IMHO).

FB
 
Thats up to the wizard, I bet most dont, they currently (or should at
presnt) use #region and #endregion for marking uneditable code.

Look at the current usage of lambada functions on other languages, or rather
MISUSE.
 
You should not overvalue code breaking - programmers who was really stupid
enough to use yield as identifier can quickly change that in their code
(That yield would be used as identifier later was known a long time). The
change will also *not* break already compiledd assemblies. In other
languages including C++ there was lots of keywords added, years after the
original specification of the language and there was not problem.

But I know lots of people (even in a few years) will hate this unneccessary
verbose and annoying syntax only because in the *very* early days somebody
decided that yield *could* *eventually* break some code written in the early
days of c#.

However, "yield return" or not, I don't understand why "yield break" is
neccessary as a simple "return" would do it perfectly. The meaning of return
is: The method ends here. You should preserve that..

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
 
cody said:
You should not overvalue code breaking - programmers who was really stupid
enough to use yield as identifier can quickly change that in their code
(That yield would be used as identifier later was known a long time). The
change will also *not* break already compiledd assemblies. In other
languages including C++ there was lots of keywords added, years after the
original specification of the language and there was not problem.

But how long, some code may be 2 or 3 years old by this point, I didn't hear
about yield likely being an identifier until about a year ago, maybe a
little longer. I don't know if some of my own code would break, not to
mention however millions of lines were written before anyone had any clue
that iterators would be a C# feature with the .NET 2.0 framework.
And as I recall, C\C++ reserved all names starting with __ or something to
that effect, so it was your fault if you screwed up, they told you
beforehand what not to use. I don't want to see C# take the approach of
prefixing keywords with __ (or any other sequence) just to maintain the
ability to add keywords. Add onto that the utter complexity of a C++ and a
C++ compiler, and I don't think that argument is worth much. C++ is maybe
too complex, has too many keywords, it does have an effect on C++ itself, if
not with the compiler then with the language itself, a concious decision to
avoid bloating the language is very important for C#.
But I know lots of people (even in a few years) will hate this unneccessary
verbose and annoying syntax only because in the *very* early days somebody
decided that yield *could* *eventually* break some code written in the early
days of c#.

I doubt it, its not a big deal and it maintains a simplier grammer, plus its
clearer, reserving a keyword really should be a last resort. If you are too
lazy to type yield return one time per iterator(twice maybe, I doubt it
would be much more than that), you really shouldn't be programming. Its
really not a big deal. However, even if yield could have been used as a
contextual statement, it would have confused people when used with yield
break, which I argue about below.
However, "yield return" or not, I don't understand why "yield break" is
neccessary as a simple "return" would do it perfectly. The meaning of return
is: The method ends here. You should preserve that..

The meaning of return is NOT the method ends here, it means this CODE PATH
in this method ends here, here is the value you were interested in, or
atleast as close as I could get, it inessence returns a value from the
method, a return is not needed to end a method(however the langauge and
probably the runtime enforces it when there is a return type specified).
Blank returns are valid only in void methods where there is no return value
but in that case it is a syntatic nicety that makes logical sense, no value
to return, so return can stand alone. An iterator, on the other hande, does
have a return value, an enumerator or enumerable interface. A empty return
statement doesn't make sense, yield break does.
It keeps the complexity of the language grammer from growing to high, it
doesn't require changing the rules of return, which would be, by far, the
worst choice they could make.
--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


Eric Gunnerson said:
We had originally used "yield" by itself, but unfortunately, that would
require us to add a new keyword to the language, which has the potential to
break current code. By using "yield return", we don't have to do this.

--
Eric Gunnerson

be
no "yield"
as
 
Partials are just stupid

I couldn't disagree more. In our project, we have a class that's
approaching 7000 lines of code. This gets to be a problem when we have 2 or
3 people who want to work on the file at the same time. It'd be so much
easier with partials.
and anonymous methods, argue all you want about spaghetti
code, its still spaghetti code.

One practical application I see for anonymous methods is with dynamically
created forms. It would be possible to modify controls directly without
traversing the 'object sender' var passed in events. You also would not
have to have dynamically created forms events inside of other classes (where
they don't really belong anyway).


If you don't like the additions, nobody is saying you have to use them. You
clearly criticized them while only considering your own coding situation.

Chris Lajoie
 
You dont need partials to redesign code (more like shuffle about the mess of
7000 lines).
 
Chris LaJoie said:
I couldn't disagree more. In our project, we have a class that's
approaching 7000 lines of code. This gets to be a problem when we have 2 or
3 people who want to work on the file at the same time. It'd be so much
easier with partials.

That sounds like a really bad reason to use partial types, IMO. Is it
really not possible to refactor that code into more classes which would
increase the readability of the code to start with? I've only *very*
rarely seen classes which really deserve to be that long.
 
Thats up to the wizard, I bet most dont, they currently (or should at
presnt) use #region and #endregion for marking uneditable code.

THat's cludgy too. It also requires that the generator parses the
complete file.

I always found it a stupid idea of having 1 class per file. A class
is a concept you use to write code, why should it be bound to a concept that
has nothing to do with writing code: a file? The same stupidity as designing
an ORM model in Visio and then having to deal with a canvas that represents
A4 paper. Why? I'm designing it on the computer, not on paper.

Now, the class code can be developed in an IDE as a single unit and
stored in multiple 'buckets' (today they are files, tomorrow HOPEFULLY
elements directly inside a source control system or code database).

FB
 
That sounds like a really bad reason to use partial types, IMO. Is it
really not possible to refactor that code into more classes which would
increase the readability of the code to start with? I've only *very*
rarely seen classes which really deserve to be that long.

A class should be a logical element in the structure of the system.
Not a way to cut up code because a random person cooked up the idea that a
file of XYZ lines is too large. After all, cutting up a class in multiple
classes pollutes the class hierarchy with extra types that are hardly
different, creating extra problems when the types require each-others
data/logic (they were first stored in the same class, remember ;) ).

Although 7000 lines is a lot, you sometimes end up with large
classes, for example a main form class which controls all child windows
and main gui application logic (not the core application logic). It can
become very messy when you are chopping that up in smaller classes, which
will be used in just 1 spot: the main gui form, but because they're other
classes, you have add overhead code to communicate with them to reach
their data.

FB
 
Back
Top