Slashdot Mirror


Exegesis 6 (Perl 6 Subroutines) Released

chromatic writes "Perl.com has just published Damian Conway's Exegesis 6 which gives practical examples demonstrating how to use the new subroutine and method semantics in Perl 6. This is the companion to Larry Wall's Apocalypse 6 which discussed the changes planned for subroutines in Perl 6."

8 of 234 comments (clear)

  1. For those who don't know.... by ajs · · Score: 5, Informative
    The way Perl 6 is being developed is thus:
    • Everyone in the world had a chance to submit RFCs
    • Larry is taking each section of the 3rd edition Programming Perl and turning it into a white-paper on the way Perl 6 will work, using the RFCs that touch on that section of Perl as a sort of shopping list, and accepting, modifying or rejecting them as needed. These are called the Apocalypses.
    • After an Apocolypse is out, Damian starts working on some real-world examples to make it all more concrete. These are called the Exegeses. Sometimes these also have examples of syntax and semantics that have been worked out via the mailing lists
    • Eventually, this will lead to the Design Documents
    Hope that helps clear this up for those who aren't sure what's going on when they see a new Apocolypse or Exegesis come forth.

  2. oh yeah by tomstdenis · · Score: 5, Insightful

    sub Fahrenheit_to_Kelvin (Num $temp is rw) {

    Verbosity in coding, yeah that will go over well with people who are used to

    int lbn, rax, ... ; :-)

    Don't get me wrong I'm a big fan of Perl, but not for its completeness as a language but for the ability to quickly write small utils to parse text.

    But I suppose whatever floats peoples boats.

    Tom

    --
    Someday, I'll have a real sig.
  3. Perl floats *all* boats by flicken · · Score: 5, Funny
    That's the point of Perl. If you don't want to use the verbosity of:

    sub Fahrenheit_to_Kelvin (Num $temp is rw) {

    You don't have to! You could just as well use:

    sub f2k ($temp) {

    Perl will allow either. It's your choice. You can do the quick one-off-hack-it-up-at-3am-after-two-large-pots-of- coffee, and you can have a large programming project that must be maintained for years to come.

    You have the choice. Pick whichever method fits the task at hand.

    --
    20 mil and I will! Learn Esperanto with 20M others.
  4. Re:seems like by chromatic · · Score: 5, Insightful
    the language is becoming more obtuse if thats possible.

    Read the last page of Exegesis 6 to see the Perl 5 version of the code. It's astonishingly simpler and clearer in Perl 6.

    The perl programmers I know don't get along well with other languages, mostly because they have spent so much time learning the intricacies of Perl syntax.

    See the Inline modules on the CPAN.

    I've never met a perl programmer who could tell me what a design pattern is either.

    See Perl Design Paterns, an article on Perl.com.

    I guess they don't go for re-use much in perl progging.

    See the CPAN.

    I think if I went to hell, satan would probably make me write a Perl parser. (without the help of Yacc)

    I've read the Perl parser. You're right about this one.

  5. Holy syntax overload batman! by jtdubs · · Score: 5, Informative

    I've never seen a language with so much syntax. Perl 5 had more than enough, now they've more than doubled it.

    You have { } for blocks, and for automatically parameterized blocks (ie. anonymous functions).

    You have =, := and ::=, ~=, ~~, .... = does assignment, := does binding and ::= works at compile time and is normally used to define types and such, ~= is pattern matching, and I have no idea what ~~ does.

    You have the new <== and ==> pipeline operators. They are dataflow operators. Like so:

    $foo ==> my_func ==> $bar;
    is the same as
    $bar <== my_func <== $foo
    is the same as
    $bar = my_func($foo);
    is the same as ...

    You already had the $,@,%,& to prefix variables with.

    You have more uses for * now, as in slurpy arrays and splicing. As in, the * can make an array parameter slurp up all the remaining arguments, or it can make an argument flatten into a list of arguments.

    They've added some wierd << foo >> syntax that I didn't even bother to read about as I was in syntax shock.

    They've added ^ which indicates that a variable in a block is actually a parameter and therefore the blocks is actually a parameterized blocks (ie. anonymous function). So, now you can't tell if something surrounded by { }'s is just a block of code or whether it's an anonymous function. Although, I don't think this is a problem as it's usually obvious from the context.

    And I didn't even read to the end of the paper!

    Makes me want to go write some Lisp, which is perhaps the antithesis of Perl. Lisp has the maximum possibile flexibility through having the minimum possible syntax. Perl originally had little flexibility, now they are trying to add more by adding more syntax. The problem is, if they want to get anywhere near Lisp-level flexibility with this method they'll need to move to Unicode for the syntax!

    Justin Dubs

  6. Any Sufficiently Advanced Language... by Vagary · · Score: 5, Interesting
    A disclaimer: I used to program Perl for a living, but we had a falling out some years ago (around 5.0?). So if you don't think there's any merit to what I'm saying, then feel free to consider this a troll:

    Shortly after I started reading Exegesis 6 I was somewhat frightened by how complex Perl had become since I stopped keeping track of updates. Of course scripting languages have always been known for borrowing the best from other programming languages, so I kept reading in the hopes that I'd recognise something. I saw some features like the is constant declaration and started worrying that maybe they'd decided to borrow some features from the very popular but insanely evil Visual Basic. But then I saw this:

    type Selector ::= Code | Class | Rule | Hash;

    and realised that, just as Python is (alleged to be?) adding Lisp-like features, Perl is adding ML-like features! That line above is (minus the '::' and ';') straight out of a Haskell program. Then I started to notice more Haskell-like syntax:

    • Anonymous function declaration syntax: -> $animal { $animal.size < $breadbox } would be (\animal -> animal.size < breadbox) in Haskell
    • Multisubs are like pattern matching: multi sub feed(Cat $c) {...} multi sub feed(Lion $l) {...} would be
      feed (Cat c) = ...
      feed (Lion l) = ...
    • New infix operator definitions: infix:~|_|~ would be the function named (~|_|~)
    • Junctions are like list comprehensions: all(newvals) would be [x | x <- newvals] (it almost seems like junctions are lazy from the way Damian talks about them?!)

    And I'm sure a more thorough reading would turn up even more. (For example, the smart-match operator reminds me of the type inferences done in a Hindley-Milner type system.) So it appears that any sufficiently advanced language contains an implementation of a purely functional language, not specifically Scheme. :) Has Damian (who certainly has Haskell exposure) or Larry ever mentioned any of these influences?

  7. There's more than one way to do it? by MoxFulder · · Score: 5, Funny

    Perhaps the Perl motto should be changed from TMTOWTDI to TAMODVPCWDSSAAMSTWDI:

    "There's a multitude of different visually pleasing constructions with deceptively subtle syntax and auto-magical semantics that will do it."

    Okay, I love Perl 5... Perl 6 looks really cool but overwhelming. I'm glad they're adding the options for stricter type-checking and such, but remembering the syntactic shortcuts is gonna be even harder. I don't even want to know what the parser code looks like...

  8. Re:Perl 6 \not\in Perl ? by chromatic · · Score: 5, Informative

    It's not just you, but about 80% of the syntax stays the same. Much of the rest requires a few parser rule overrides. See ... And Now For Something Completely Similar, also by Damian.

    Backwards compatibility is a huge concern. That's why Ponie exists and why Dan's so careful about supporting Perl 5 semantics on Parrot. (As well, I expect 80% of the core Perl 5 tests will port to Perl 6 with surprisingly little work.)