Poll: what should this program do?
Basile B.
b2.temp at gmx.com
Thu Mar 20 08:02:20 UTC 2025
On Wednesday, 19 March 2025 at 03:40:28 UTC, Paul Backus wrote:
> Here's a weird little program that came up in a recent Discord
> discussion:
>
> template fun(T)
> {
> string fun(T) => fun("hi");
> string fun(string) => "inner";
> }
> string fun(string) => "outer";
>
> void main()
> {
> import std.stdio;
> writeln(fun(123));
> }
>
What an overload-set nightmare.
> **What SHOULD this program do?**
>
> 1. Print "inner".
> 2. Print "outer".
> 3. It shouldn't compile.
>
3 because two candidates of the set match.
> **What do you think it ACTUALLY does?**
>
> 1. Print "inner".
> 2. Print "outer".
> 3. It doesn't compile.
I play the game, I haven't compiled the thing but I'd say "hi".
More information about the Digitalmars-d
mailing list