@property - take it behind the woodshed and shoot it?

Adam D. Ruppe destructionator at gmail.com
Sun Jan 27 15:18:15 PST 2013


I was just working on some work code and noticed this line that I 
wrote a while ago:

public @property string userId(string file = __FILE__, size_t 
line = __LINE__) {


That's a getter, I always use it "getUser(userId);" etc..... but 
it "takes" two arguments.

If we require getters to have zero arguments, it will break this, 
and that will annoy me. We need to be careful about arbitrarily 
deciding something doesn't make sense and restricting it when 
there's no real technical reason for it.


(Wondering why I did this? If you aren't logged in, this throws a 
Not Logged In Exception. The file and line are passed to the 
exception constructor, meaning then the error message will tell 
me exactly where I forgot the nicer login check.

After wasting cumulative hours on similar problems in earlier 
iterations, I put this in there to eliminate that time sink.)


More information about the Digitalmars-d mailing list