[stringtemplate-interest] StringTemplate in C# - attribute lookup rules

Natan Vivo nvivo.misc at gmail.com
Thu Dec 27 08:16:12 PST 2007


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-Propertyreferences,
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/20071227/ecdaee0c/attachment.html 


More information about the stringtemplate-interest mailing list