Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^15: Strong typing and Type Safety.A multilanguage approach (implicit)

by chromatic (Archbishop)
on Nov 22, 2010 at 19:14 UTC ( [id://873022]=note: print w/replies, xml ) Need Help??


in reply to Re^14: Strong typing and Type Safety.A multilanguage approach (implicit)
in thread Strong typing and Type Safety.A multilanguage approach

(I know you know all of this; I belabor it only for the sake of other people reading who may not know, and because I think most of the talk about the Perl 5 type system is incorrect in subtle and imprecise ways.)

Monomorphic has nothing to do with it.

It has everything to do with it. Perl 5's type system expresses types by operators, not values. There is no implicit conversion occurring because the typed monomorphic operators are all explicit. (Without an operator, you have only a single-term expression.

Would you say that the C macro:

#define INTEGER_ADD(a, b) (int)(a) + (int)(b)

... performs implicit conversion because when you use it, you don't see the casts?

z = INTEGER_ADD(x, y);

Would you not characterize this code as clunky?

my $z = "$x" . "$y";

To anyone who understands the concatenation operator, the explicit stringification is unnecessary because the operator explicitly expresses the type of the values it expects from its operands.

Replies are listed 'Best First'.
Re^16: Strong typing and Type Safety.A multilanguage approach (implicit)
by ikegami (Patriarch) on Nov 22, 2010 at 20:04 UTC

    Would you say that the C macro ... performs implicit conversion

    Yes. The code is in the macro, not outside the macro. If you're looking at it from the perspective of the code using the macro, the conversion is implicit. If you're looking at it from the perspective of the "+", the conversion is explicit.

    Would you not characterize this code as clunky?

    Yes. It's clunky because there's no need for explicit conversion — it's being done implicitly. Let the concatenation operator coerce the operand.

    You've said coercion occurs and you've shown that explicit conversion is unnecessary. I have no idea what you are arguing.

    • Do you think a scalar is being converted to a number?
    • Do you think the addition operator does this conversion or its caller?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://873022]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-23 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found