[stringtemplate-interest] ST, Django and get_something_display()

Roman Odaisky roma at qwertty.com
Fri Aug 1 01:32:08 PDT 2008


On Friday, 01.08.2008 01:27:39 Terence Parr wrote:

> Hi Roman, i assumed people would follow the javabeans notation of
> getFooDisplay.  Too bad django doesn't. hmm...well, I'd say create a
> wrapper object that converts syntax...register a renderer like
> djangoToBeans object that answers getFooDisplay and delegates to
> django object.  Might be Able to use reflection or something to make
> this more automatic...

Hi,

I guess the intent was only to allow calling methods which don’t modify the 
object?

What about modifying the logic a bit: for $o.m$ if m is a method of o, and 
either m starts with /[gG]et[A-Z]/, or /get_/, or it has a special attribute, 
for example, StringTemplate_safe, then call o.m(), otherwise use the old 
rules? All the languages which run StringTemplate have made a wise decision 
of supporting reflection and attributes (and the stupid decision of ignoring 
const, which would have been the ideal solution for this), so something like 
this seems easily implementable and it no longer imposes a certain naming 
convention. (I wonder whether the .NET version uses get or Get prefix.)

For example, those following the Qt style don’t use the get prefix at all 
(o.someProperty()/o.setSomeProperty()), those using the Apps Hungarian 
notation also don’t need it (the Hungarian prefix indicates quite clearly 
that a method is a getter).

So what about adding an attribute which would indicate safe methods?

-- 
WBR
Roman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2286 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080801/40475512/attachment.bin 


More information about the stringtemplate-interest mailing list