Make dur a property?

Adam D. Ruppe destructionator at gmail.com
Wed Jan 23 12:48:32 PST 2013


On Wednesday, 23 January 2013 at 20:37:23 UTC, Jacob Carlborg 
wrote:
> What about functions not marked with @property?
>
> writeln = "asd";
>
> Doesn't look very nice.

struct FileNotFound {
    int payload;  FileNotFound opBinary(string op : 
"+")(FileNotFound rhs) {
return this.payload * rhs.payload;
                 }
                         } /* LOL INDENTATION */

FileNotFound descriptiveVariableNamesArentMyThingLOLOLOLOL;
descriptiveVariableNamesArentMyThingLOLOLOLOL.payload = 20;

auto rofl = descriptiveVariableNamesArentMyThingLOLOLOLOL + 
FileNotFound(100);


// LOLOLOLOL rofl.payload == 2000!!!!!!!!!!!!!!!!




All of that looks pretty terrible too, from the awful names, the 
broken indentation, the useless comment, and of course, the + 
operator being overloaded to mean multiplication too.

But that's no reason to for the compiler to reject operator 
overloading, comments, or long variable names, because these 
things are useful, when not abused by a deranged lunatic.



Simlarly, writeln = 10 might not look very nice, but className = 
"foo" does.... and it is the same feature, used in real world D 
code now (that would break if we changed it).


More information about the Digitalmars-d mailing list