Reading UTF32 files

Oskar Linde olREM at OVEnada.kth.se
Thu Aug 10 16:44:26 PDT 2006


Markus Dangl wrote:

>> BTW: that should probably read "auto content = file.read();" with
>> parens, since otherwise the 'auto' will try to take the function
>> reference
> 
> Just a note:
> I think all methods that don't take parameters can be called without
> parens, just like you normally use properties, but it's a bit clearer to
> use parens here (because "read" should actually be used as a method).
> To take the reference you'd have to use sth like "auto pointer =
> &file.read" ...

In this case, due to a bug or an unfortunate side effect, 

auto content = file.read;

will neither call file.read() or make content a reference to the function.
It will try to make content a function type (as opposed to a reference to a
function) which will fail to compile.

There is also still at least one case where an empty pair of parentheses are
needed at a function call. Array extension methods:

void func(int[] t) {}

can not be called as:

arr.func;

Though I'm not sure there is any fundamental reason it has to be that way.

All function (reference) and delegate types will also require the
parentheses, which is more or less necessary to avoid ambiguities:

int delegate() func() { return { return 1; }; }

...

func;

/Oskar



More information about the Digitalmars-d-learn mailing list