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

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

by danger (Priest)
on May 16, 2001 at 20:31 UTC ( #80945=note: print w/ replies, xml ) Need Help??


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

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?


Comment on Re: Re: Re (tilly) 4: Exegesis 2 - Perl 6
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2015-07-28 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (259 votes), past polls