At 06:47 25/01/2009, Jim Idle wrote:
 >It is a convenience function that creates (and tracks) a memory
 >structure that copies the string from the input every time you
 >call getText(). It is this way because (and I think this is in
 >the docs) sometimes you want a new copy of the input string
 >and sometimes you want to modify the string you get back but
 >not modify the input.

I don't think that's a good argument.  Strings in Java and C# are 
immutable; in C/C++ they're not, but they should be treated as if 
they were (reading a string is a far more common operation than 
modifying one).  So the getText() function should return a const 
string and should only construct it once.  (For performance 
reasons, it should probably keep the existing behaviour of not 
constructing the string until first requested.)

For another argument: it's trivial to take a read-only string and 
convert it into a writable one (without affecting the 
original).  It's non-trivial to extract text from the token 
stream.  So the latter function should be implemented by the 
runtime in such a way that the former can be applied afterwards in 
the unlikely event that it's needed.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to