[stringtemplate-interest] StringTemplate in C# - attribute lookuprules

Micheal J open.zone at virgin.net
Sat Jan 5 01:20:44 PST 2008


Hi,
 
Interesting comments. Perhaps the ordering of the various checks can be
adjusted so that the less likely (for C#) getXXX, isXXX and GetXXX variants
come last?
 
Micheal


  _____  

From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Natan Vivo
Sent: 27 December 2007 16:16
To: stringtemplate-interest at antlr.org
Subject: [stringtemplate-interest] StringTemplate in C# - attribute
lookuprules


Why are there so many lookup rules for C# in contrast to Java or Python
versions?

In this page
http://www.antlr.org/wiki/display/ST/Expressions#Expressions-Propertyreferen
ces
<http://www.antlr.org/wiki/display/ST/Expressions#Expressions-Propertyrefere
nces> , it tells me C# version would try to get a value from 7 different
places before trying an indexer.

I ask this because an application I wrote makes extensive use of indexers to
add custom attributes to an object, and although the performance is good
enough, I just wonder if this lookup rules aren't too bloated. 

For example, why to have rules for get_name, getname and Getname? The
probability of someone writing like this in C# is the same of writing a
method called Name() in java. The property X in c# is the direct equivalent
of getX() in java. 

This also makes my indexer called "type" be dropped in favor of the method
GetType on the System.Object, making me declare a property called "type"
calling the indexer.

I would suggest that this rule to be 1. Property, 2. IsProperty, 3. indexer,
but I guess that would cause a lot of compatibility problems by now. 


Also I just found out that ST will look for private members too on attribute
lookup. Shoudn't it look for public instance members only?

Thanks,
Natan Vivo


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080105/ac575539/attachment.html 


More information about the stringtemplate-interest mailing list