Even with something as simple as Str, if you put ten Perl developers in a room, I'd expect them to have eleven different opinions on how it should be implemented.
my Str $x = $y;
- If $y is undef, then $x should be "" because of type casting.
- If $y is undef, then there should be an exception thrown because undef isn't a string.
- If $y is an overloaded object, then $x should now be an overloaded object.
- If $y is an overloaded object, then $x should now be the stringified version of that object.
- If $y is an overloaded object, then there should be an exception thrown because an object isn't really a string and overloading sucks anyway.
- Even if $y is a non-overloaded object, $x should now be the stringified version of that object.
- If $y is 42 (no quote marks), then there should be an exception thrown because integers aren't a subset of strings dammit!
- If $y is 42 (no quote marks), then $x should be "42" (with quotes) and poking around with B:: stuff you should be able to tell the difference between them.
- A lot of these cases could be handled by using warnings instead of exceptions. It's basically the same kind of error as use warnings "numeric" anyway, and we're happy enough having those be non-fatal.
- Empty strings are always an error in my application, so if $y is "", it should throw an exception, shut down the computer, and set the building on fire. (In all seriousness, I know of at least one case in Perl where empty strings are special-cased, treating them differently from non-empty strings.)
- But dualvars! Waaaaaah!