On 09/20/2019 12:02 PM, JN wrote:
> import std.stdio;
>
> interface IWriter
> {
> void write(U)(U x);
> }
>
> class Foo : IWriter
> {
> void write(U)(U x, int y)
> {
> writeln(x);
> }
> }
>
>
>
> void main()
> {
> }
>
> Does this code make sense?
No. Function template
On Friday, 20 September 2019 at 19:02:11 UTC, JN wrote:
If so, why doesn't it throw an error about unimplemented write
(or incorrectly implemented) method?
because you never used it. templates don't get checked by the
compiler until they are used...
import std.stdio;
interface IWriter
{
void write(U)(U x);
}
class Foo : IWriter
{
void write(U)(U x, int y)
{
writeln(x);
}
}
void main()
{
}
Does this code make sense? If so, why doesn't it throw an error
about unimplemented write (or incorrectly implemented) method