[antlr-interest] Use partial classes for C#

Hill, Robert rhill03 at eds.com
Wed Mar 28 07:09:12 PDT 2007


Hi All, 
	I'd like to see partial classes (but...I'd like to see the C# uptodate first ;)  ) but partial classes do allow you to organise your code more easily - marginally.
For the really fussy you can just surround the offensive code with #region - #endregion and then collapse it.
Inheritance implies some kind of relationship that partials don't, they just split the definition across multiple files for convenience. It's a nice feature of .Net I have to agree. But it's not *that* essential. Prior to 2.0 the standard was to surround the code with #region which you can do by hand anyway if you're desperate.
Nothing worth getting' your panties in a bunch for if you have a folding editor!

/2ob


Robert Hill
Information Analyst (C/C++,C#,.NET,Java)
Agile Alliance Member
EDS UKIMEA DWP ACU
Hallamshire Business Park, 100 Napier St, Sheffield. S11 8HD
email:	rhill03 at eds.com
Office:	+44 114 291 1928
Mobile:	+44 7903 185 516

This email contains information which is confidential and may be privileged. Unless you are the intended addressee (or authorised to receive for the addressee) you may not use, forward, copy or disclose to anyone this email or any information contained in this email. If you have received this email in error, please advise the sender by reply email immediately and delete this email.

Electronic Data Systems Ltd
Registered Office:, Lansdowne House, Berkeley Square, London  W1J 6ER 
Registered in England no: 53419
VAT number: 432 99 5915


 

>-----Original Message-----
>From: antlr-interest-bounces at antlr.org 
>[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Dr. 
>Hartmut Kocher
>Sent: 28 March 2007 14:58
>To: 'Martin Probst'
>Cc: antlr-interest at antlr.org
>Subject: Re: [antlr-interest] Use partial classes for C#
>
>Hi,
>
>Of course, this is how I do it for now. However, partial 
>classes were invented for exactly this reason: Mix generated 
>and hand written code in one class but in different files. 
>ASP.NET / WinForms etc. do it and a whole bunch of other 
>generators do it as well. This is the standard way of 
>generating code in the .NET world.
>
>So I think ANTLR should follow this.
>
>Regards,
>Dr. Hartmut Kocher
>
>-----Ursprüngliche Nachricht-----
>Von: Martin Probst [mailto:mail at martin-probst.com]
>Gesendet: Mittwoch, 28. März 2007 10:31
>An: hwk at cortex-brainware.de
>Cc: antlr-interest at antlr.org
>Betreff: Re: [antlr-interest] Use partial classes for C#
>
>Hi,
>
>> I'd like to see the use of partial classes in the C# code 
>generator of 
>> ANTLR 3. This would simplify coding parsers as new code can be added 
>> to a generated class in a separate file (without using the @members 
>> directive).
>> This gives all the advantages of having Intellisense during 
>> development.
>
>Why don't you simply have your Parser/Lexer/Whatever extend an 
>abstract base class that defines the required methods and be 
>done with it? I do this in Java development with v2.7, like this:
>class MyParser extends Parser("com.example.mypackage.AbstractParser");
>
>Then in AbstractParser you define the methods you really need 
>as abstract. In my case I didn't need any, it's only the 
>concrete parser using methods of the abstract parser, but it's 
>possible to e.g. define:
> > public abstract void expr() throws RecognitionException; 
>(or similar in .NET), and then use that method. So you can 
>happily code in your regular IDE.
>
>I generally really wonder why one would need something like 
>partial classes, it seems like a totally superfluos feature to 
>me if you have inheritance and abstract base classes...
>
>Regards,
>Martin
>
>
>


More information about the antlr-interest mailing list