Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Re (tilly) 4: Exegesis 2 - Perl 6

by eduardo (Curate)
on May 16, 2001 at 20:09 UTC ( #80939=note: print w/replies, xml ) Need Help??

in reply to Re (tilly) 4: Exegesis 2 - Perl 6
in thread Exegesis 2 - Perl 6

As for the third point, Larry will have to decide on a string concatenation operation other than the current. Personally I can learn a new concatenation operation fairly easily. As long as he doesn't pick +, I won't really care what he does there...

This point seemed a bit confusing to me, being that so many languages already use the + operator for both addition and string concatenation, why would you be opposed to using + for this particular operation?

Replies are listed 'Best First'.
Re (tilly) 6: Exegesis 2 - Perl 6
by tilly (Archbishop) on May 16, 2001 at 20:27 UTC
    It has to do with type systems.

    Perl's typing strategy has always been to type its core operations but not its variables. Then it will cast its variables as implied by its operations. The alternative that most other languages use is to type their variables but not their core operations.

    What this means is that in Perl you very rarely even have to think about the fact that "33" is different from 33. The following two are the same:

    $x = 33 + 55; # -> 88 $x = "33" + "55"; # -> 88, in other languages "3355".
    I think that, whether or not you think that Perl's type system is the best design, changing whether you have to think about the difference between strings and numbers would make Perl no longer Perl...
Re: Re: Re (tilly) 4: Exegesis 2 - Perl 6
by danger (Priest) on May 16, 2001 at 20:31 UTC

    Well, the biggest problem with using + for concatenate in Perl is that it introduces ambiguity. Consider:

    print "Enter a number: "; chomp(my $num1 = <STDIN>); print "Enter another number: "; chomp(my $num2 = <STDIN>); print "$num1 + $num2 is ", $num1 + $num2, "\n";

    Right now, the + means numerical addition so Perl converts those strings read in from STDIN to numbers, adds them, and converts the result back to a string to print it. In other words, now the operator (+ or .) imposes context (numeric or string) on its operands. Would you prefer having to do explicit type declarations or casting to provide context to the operator?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2021-03-02 15:06 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (51 votes). Check out past polls.