explicit syntax for accessing class members and globals

Serg Kovrov kovrov at no.spam
Mon Sep 4 14:38:43 PDT 2006


Hello D-people,

It is strange I didn't encounter debates regarding subject so far. That 
I mean is a way to distinct class members and globals from local 
identifiers. For example forcing to use 'this' to access member data and 
methods.

Then I first saw this approach in PHP (after C++ background), I was 
thinking that it is a stupidest idea - to type (and see) 'this->' 
allover again. But in time I get used to it and do really appreciate it. 
You see, benefits for a little more typing is code, much easier to 
follow. I find exploring foreign C/C++/D code is a bit pain because I 
always need to lookup and track identifiers - is it member or local or 
perhaps global, or even worse it might be hidden by local member... I 
bet you know the feeling.

Personally I avoid those pitfalls using (my own, sorry) naming 
contentions. So I have no problems with my own code, but what is my code 
compared to whole world =)

Good IDE able to highlight such information, say in tooltip, could help 
a lot. To bad we do not have one =(  And not always even if exist, good 
IDE available. For example looking at code on web page or paper.

It's a bit late for proposal, as such change will break too much 
existing code (although, fixing this would be not so hard for code 
maintainers), but I'd like to know your opinions on that matter.

thanks
-- 
serg.



More information about the Digitalmars-d mailing list