Do we want functions to act as properties, or merely omit parens for ufcs/chaining?

simendsjo simendsjo at gmail.com
Tue Jan 29 00:17:40 PST 2013


On Tuesday, 29 January 2013 at 08:05:25 UTC, eles wrote:
> On Tuesday, 29 January 2013 at 01:24:45 UTC, Chad Joan wrote:
>> On 01/28/2013 08:09 PM, F i L wrote:
>>> why in the hell would you want:
>>>
>>> writeln = "lolwut";
>>
>> But it does right now ;)
>
> Joking here, but what about renaming writeln into cout and 
> overloading the <<?

Great idea :)

import std.stdio;
struct COut {
     COut opBinary(string op, T)(T other) if(op == "<<") {
             write(other);
             return this;
     }
}

@property COut cout() {
     return COut();
}

void main() {
     cout << "cout" << " " << "rocks" << "\n";
}


More information about the Digitalmars-d mailing list