Perl 5.10, 20 Year Anniversary 304
alfcateat writes "Perl 1 was released to the public by Larry Wall 20 years ago yesterday. To celebrate, Perl5Porters have released Perl5.10, the latest stable version of Perl 5. Happy Birthday Perl!
Perl 5.10 isn't just a bug fix version: it's full of new features that I'm eager to use: named captures in regular expressions, state variables for subroutines, the defined-or operator, a switch statement (called given-when, though), a faster regex engine, and more. You can read more about the changes in perldelta."
Re:Hmmmmmm (Score:3, Informative)
Re:Switch statements are syntactic sugar (Score:3, Informative)
C/C++ only allows constants to be used as case values in a switch statement, you can't use a variable as a case label. This allows the compiler to optimise the comparisons based on the numerical value of each constant case label. Performing the case evaluations in different orders, using subtraction and addition and testing against zero can be more efficient than comparison to each value in turn.
So, a switch statement can be more efficient than nested if/then/else.
Re:Switch statements are syntactic sugar (Score:3, Informative)
Well, most languages have a ternary operator ?:, which allows to get away without if in any situation. In Perl and Python you can do:
Where CASEx is boolean and STUFF_TODOx is some statement. It has to return true in order to halt the search though, so, in general case you have to go for something likeAs well as in your LISP example, this is ugly enough to be avoided whenever possible :)
Re:Switch statements are syntactic sugar (Score:3, Informative)
$ perl -e 'print 2 . "3", "\n"'
returns 23 on my system (perl, v5.8.8 built for x86_64-linux-gnu-thread-multi). Note you need a space before the dot, otherwise Perl gets its knickers in a twist because a dot looks like the fraction delimiter; but that's OK, because we don't have to strip out unnecessary spaces to make our code fit into the remaining 6KB of RAM (after allowing 20K for the framebuffer and 6K reserved for the system) anymore. And Python throws an error for "2" + 3. That's correct, strictly, but it goes against the Principle of Least Surprise (Perl gives you 5, which is both correct and Least Surprising. JavaScript gives you "23", which is neither correct nor in accordance with the Principle of Least Surprise).
Anyway, my point is that where there is an addition sign, there should be addition (and if a string has to be converted to a number, so be it; don't throw an error unless it's NaN. And provide a mechanism whereby NaN values can be silently treated as zero).
Re:Hmmmmmm (Score:2, Informative)
Having access to the CPAN from other languages would be useful (Ruby programmers take note). I want Pygame and Pyglet available to Perl 6 as well.
Library support, primarily. mod_php is well-understood and widely deployed. However, it's possible that the Parrot security model may make mod_parrot more appealing to deploy than mod_php.
There's no real formal name, but a PBC file is as close as you get. It's just a bunch of bytecode. As yet we haven't decided on any formal interface that it needs to support.
It can be any of those. For example, my little Scheme-like language has self-hosted tests. They use a testing library I wrote in PIR. The testing library provides a series of multimethods that my language can call as if they were native functions -- and my language doesn't support multi-dispatch!
Yes. The semantics of how that object will behave depends on its class, but as long as PHP on Parrot and Perl on Parrot use Parrot's calling conventions and its PMC interfaces for things like calling methods and creating objects, each language can have its own special semantics and can use objects defined in other languages.
Each high-level language has its own top-level namespace. I imagine that the PHP implementation just lobs some three-thousand functions into that namespace, where Perl 6 stores things differently.
Data structures created in Perl and passed into PHP will have Perl semantics for all equivalent operations performed in PHP. If PHP supports a keyed lookup operation, Parrot will perform that operation on the data structure. How that structure's underlying object handles keyed lookup is up to the object, and it'll have Perl semantics.
Yes. (I don't know how well that works right now; I don't know if anyone has specifically tried it.)
As long as the debugger knows about Parrot, it should.
Reconstructing a language from PBC is non-trivial, but one of the goals of Parrot (and Perl 6) is to encourage better tool support by making it easier to plug an editor into the VM somehow. The answer is "it depends".
Re:Much Thanks to Mr. Wall (Score:3, Informative)
The flexibility isn't just CPAN, although that's a good thing. It's in the ability to express the same program in more than one way, too. That flies in the face of orthogonality, but orthogonality is a means and not an end. In Perl one can write a functional program, a procedural program, an OO program, or a largely declarative program. One can even use an OO module in a procedural program or a procedural module in an OO program with little hassle.
Perl has bindings into OpenGL, SDL, Qt, GTK, Tk, WxWidgets, and Motif. That is doesn't have a standard GUI binding is kind of sad, but it has lots of bindings from which to choose.
The language being more flexible and the end product of a program written in the language being more flexible are two very different things. A program written in Perl can be very rigid and inflexible, while a program written in RPG could be, at great difficulty to the programmer, fairly flexible. The difference is that Perl makes it easy to make the program you're writing either rigid or flexible.
While it's true that any Turing-complete language can in theory produce the same program as any other Turing-complete language, you've got to be kidding if you think 70 lines of COBOL vs. 10 lines of C vs. 3 lines of Perl means they're all equally expressive. Expressibility and expressiveness are not the same thing.