How about a special null template parameter?

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 19 18:42:38 PDT 2016


On Fri, 19 Aug 2016 23:43:05 +0000, Engine Machine wrote:
> then the only question is can the current compiler interpret ^n
> unambiguously and without undue complexity. If it can, and such a
> syntactic rewrite is useful, then it should be implemented.

No. You must weigh the added complexity against the benefits. The less 
frequently a feature will be used, the more surprise you will inflict on 
people when they encounter it. The less like other things in the language 
this new feature is, the more awkward it will be for users.

You called your suggestion "syntactic sugar", but if we can call it that, 
we can say the same of templates. Your implication that it is a simple 
change is incorrect.

Your proposal clashes with existing features. It's even a breaking 
change. It's implemented easily enough by hand with:

class SomeFoo {
  // common fields and methods, possibly abstract
}

class Foo(T) : SomeFoo {
  // everything else
}

The by-hand implementation is also more obvious.

You would have to change the proposed syntax, show that this can't be 
reasonably done in a library, and show what it gives you that's 
appreciably better than what's currently there.


More information about the Digitalmars-d mailing list