Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

(tye)Re2: Exegesis 2 - Perl 6

by tye (Cardinal)
on May 16, 2001 at 10:24 UTC ( #80815=note: print w/ replies, xml ) Need Help??


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

1) The real win advertised (to my reading, which was a bit between the lines) was that something of type "int" would take up less space, so I doubt that will take interations to get working. Speed improvements may also eventually come (or not).

3) But how do you concatenate strings in Perl 6?

        - tye (but my friends call me "Tye")


Comment on (tye)Re2: Exegesis 2 - Perl 6
Re (tilly) 4: Exegesis 2 - Perl 6
by tilly (Archbishop) on May 16, 2001 at 14:50 UTC
    First you are right about the real reading of the win. But I think that their first implementation should just work without much worrying about optional optimizations at all. Attempts to have multiple things that could be scalars should be a second pass. Attempts to become smart about it (and not promote those ints to full scalars at the first moment) might take a while.

    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...

      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?
        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...

        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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2014-12-29 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls