On 2008-Dec-3, at 10:18 am, TSa wrote:
Darren Duncan wrote:
Strong typing in Perl means that Perl is conveniently and reliably keeping track of this user-intended interpretation of the data, so it is easy for any piece of code to act on it in a reasonable way. Strong typing lets user code be clean and understandable as it doesn't have to do a lot of manual book keeping or error checking that Perl can do for it, such as detecting the error of passing a character string to a numeric multiplication operator.

First I have a question to the example of the behavior of a string in a multiplication. Perl 6 automatically attempts a numerification. But does that result in a failure for 'foo' or does that return 0? That is, '3' * 3 == 9 is well formed and 'foo' * 3 is malformed, right?

That's what I would expect. A reasonable default would be for lossless conversions to happen automatically and lossy ones to throw an error.


[...Are Enums === Ints?]
This multi is only allowed if A and B are types distinct from Int which to me implies that enums have a WHAT that is not Int. Opinions?

Using int8 vs Int is presumably a performance issue, but "int8 29" and "Int 29" *mean* the same thing, so they should be ===. An Enum doesn't mean the same thing as a plain Int, so it shouldn't.

(As you point out, you can always use something like "Weekday::Sun eq Star::Sun" or "Weekday::Sun == 0" if you want string or numeric equality.)

A further question is which operators are automatically generated for enums. Does
  my Int $a = A::One;
  $a++;
increment from A::One to A::Two or to the Int 2? What shall happen when A::Three is incremented? Failure or switch to Int? What happens with non-continuous enums? My vote would be to not generate any operators

Since ++ works on strings without making them numbers, I think it should increment from A::One to A::Two. But if that's ambiguous, we could drop the ++ and stick with .=succ for non-numeric objects instead.



-David

Reply via email to