--- Comment #2 from 2012-09-11 08:22:55 PDT ---
(In reply to comment #1)

Thanks for the reply.

> This is as designed. Doing otherwise would let a lot of bugs through.
> In fact one of the oldest open rejects-valid bug reports is a request to make
> the compiler check template functions even when they are NOT called.
> There are strong reasons for the current behaviour.
> * This request would interact badly with functions which return auto (the
> compiler needs to compile them, to find out what the return type is).

*Does* it need to compile them if no-one calls them? Who cares what the return
value is, if there is no return value to be evaluated?

> * It's impossible for classes (you need to put the function into the vtable,
> regardless of whether it is called or not), making a new, surprising 
> difference
> between classes and structs.

That is a good point, although arguably, it only holds for virtual vs final
methods. So there is no reason for the same behavior to also apply to the final
(non-virtual) methods of templated classes.

> Generally in these cases I just turn the function into a template function.
> @property void front(Dummy = void)(T value)
>         {val = value;} //HERE
> I never tested that with property functions though.

I had considered doing that, with the even simpler:

@property void front()(T value)
    {val = value;}

However, as pointed out by bearophile, this approach means this:
struct C(T) {
    private T val;
    @property void front()(T value) {
        val = value;
void main() {
    C!int ci;
    auto f = &ci.front; //Should be &ci.front!()
    assert(ci.val == 0);
    assert(ci.val == 1);
Ceases to work. So it does have client-side impacts :'(

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to