On Tuesday, 12 March 2013 at 14:44:04 UTC, Jonathan M Davis wrote:
On Tuesday, March 12, 2013 12:28:29 monarch_dodra wrote:
IMO, I think accepting the S type makes sense. Thoughts?
Honestly, I find implicit conversion on template constraints to
be very
dangerous, because it's so insanely easy to get something that
passes the
constraint but doesn't actually work with the code (which is a
big reason that
isDynamicArray only works on the exact type).
I agree, things like "isXXX" should answer true iff said thing IS
an XXX, not merelly "is convertible to".
On the other hand, with proper template semi-specialization, you
can get the arguments converted at the call site, meaning that
inside the implementation, the constraints are passed fair and
square.
So, I'm not really a fan of the
idea of the alias this working like you're trying to do. But
the fact that
it's inconsistent definitely isn't good. It should either work
with both front
and popFront or reject both.
- Jonathan M Davis
I definitely agree on the "both" point.
However, given the "philosophy" of "alias this", if a function
accepts a T, it should be "callable" with an object that defines
"alias T this" (note I said callable, not accepts... nuance). So
I'd be inclined to use the "void popFront(T)(ref T[] a)" version.
I'll try to spend the next couple of days to see try to find if a
case that would break with this scheme.