Slashdot Mirror


Ask Larry Wall

About what? Perl is probably a good topic choice. No one knows more about Perl than Larry Wall, right? We'll send 10 of the highest-moderated questions to Larry by email, and post his answers when we get them back. Note: Due to Slashdot's line length restrictions, lines of code over 50 characters long may not display correctly. Please be aware of this if you include code samples in your question.

10 of 616 comments (clear)

  1. Re:How Object-Oriented is Perl by gorilla · · Score: 3, Informative

    Perl handles inheritance. It's not ideal, because subclasses have to know about their parent classes to avoid stomping on the parent's private data.

  2. Re:Perl's Roots... by rsd · · Score: 3, Informative

    AWK couldn't handle opening and closing multiple files at that time.

    This is answered in Chapter 27 page 645-647 of the camel book.

    Please let's keep with questions not answered already.

  3. Examples of doing inheritance and polymorphism by twoshortplanks · · Score: 3, Informative
    INHERITENCE
    ===========

    package Foo;
    use strict;
    use warnings;

    sub new
    {
    my $class = shift;
    my $this = bless {}, $class;
    }

    sub foo { "foo from foo\n" }
    sub bar { "bar from foo\n" }

    package Foo::Bar;
    use base qw(Foo);
    use strict;
    use warnings;

    sub bar { "bar from bar\n" }

    -- later in a script

    #!/usr/bin/perl

    use strict;
    use warnings;

    use Foo::Bar;

    # call inherited methods from Foo
    my $foobar = Foo::Bar->new();
    print $foobar->foo;

    # call overloaded method from Foo::Bar
    print $foobar->bar

    -- prints

    foo from foo
    bar from bar

    POLYMORPHISM
    ============

    This is hard to describe...everything is polymorphic

    my $foo = IO::File->new("bob",">")
    or die "Problem with file: $!"

    # treat $foo as a IO::Handle, and print to it
    print $foo "hello";
    Sorry, this is needed to defeat slash.
    • Please try to keep posts on topic.
    • Try to reply to other people comments instead of starting new threads.
    • Read other people's messages before posting your own to avoid simply duplicating what has already been said.
    • Use a clear subject that describes what your message is about.
    • Offtopic, Inflammatory, Inappropriate, Illegal, or Offensive comments might be moderated. (You can read everything, even moderated posts, by adjusting your threshold on the User Preferences Page)
    --
    -- Sorry, I can't think of anything funny to say here.
  4. Re:Dear Larry: Are you crazy? by legLess · · Score: 4, Informative
    Yowza. Blockquothe the Scareduck:
    The regexp changes you're talking about in Apocalypse 5 [perl.com] will make Perl 6 deeply incompatible with existing scripts and practice. ...Something this radical and wrong will hurt Perl 6 adoption and will retard the acceptance of some very nifty features.
    First of all, in case you missed it, one of the explicit design goals of Perl 6 is to run Perl 5 code perfectly and with no changes. If you don't want to use Perl 6 features - don't. End of story.

    This makes your pithy Issawi quote pointless. Larry's not pushing the Perl mule, he's giving riders a choice of a new, different mule that many of them will like better. If you feel pushed - again, keep writing Perl 5.

    Larry's said several times that he's going to break everything that needs to be broken, mercilessly, in the design of Perl 6. Only those to whom this appeals need come along for the ride. I think your hysteria is misplaced.
    --
    This isn't as much "normalization" as it is "don't take so many drugs when you're designing tables."
  5. Re:Thanks Larry by Second_Derivative · · Score: 2, Informative

    Uhm, the Perl Foundation seems to be in need of some donations...

  6. Re:My Question by yankeezulu · · Score: 2, Informative

    there are others who would say the same about java...take a look at what Paul Graham (lisp master)
    has to say about java in item 2: Java's Cover, by P. Graham

  7. Re:Dear Larry: Are you crazy? by buttahead · · Score: 2, Informative

    There is an option in the new rx to turn on perl5 rx parsing and forgo the new perl6 parsing (or rather perl uses the perl6 engine to convert the perl5 rx into a perl6 rx, I beleive). For those that are too lazy to learn a new and improved rx engine, this should be a nice substitute. As for the incompatibility issues, stick to using perl5 for legacy apps, and use perl6 for the new ones. This is as easy as changing a single char at the top of a perl script from 5 to 6.

    A more gradual change in this case seems impossible. Adding bit by bit caused many of the problems with the current rx implementation. The new way has been thought out, rather than hodge-podged.

    I don't know Issawi, but he sounds like he has problems accepting change. Adapt and overcome.

  8. Re:Dear Larry: Are you crazy? by rgmoore · · Score: 3, Informative

    I think that you're overreacting. Larry has specifically mentioned that there will be a Perl5 compatibility mode. Just put a :p5 after your matching character (m or s) and you can do things the old way. Meanwhile, those of us who want to do non-capturing groups can now use [...] instead of (?...), and for defined groups can use <[...]> instead of [...]. As Larry says, which do you use more, non-capturing groups or non-named character classes? Note that at the same time you're gaining the very powerful ability to create your own named character classes, so when you have an odd group of characters that you want to use again and again it won't be a problem.

    --

    There's no point in questioning authority if you aren't going to listen to the answers.

  9. Re:Perl, XP, and test-driven development by chromatic · · Score: 2, Informative

    Perl has fairly good testing support, if you choose to use it. Writing a refactoring browser for Perl is non-trivial, but test first development is possible. I do it regularly.

  10. Re:Line Length by jesser · · Score: 3, Informative

    Due to Slashdot's line length restrictions, lines of code over 50 characters long may not display correctly.

    Isn't this something that can be fixed in Perl?


    No. It can only be fixed by reducing the use of the <TABLE> tag and then turning off word-length restrictions.

    One of the evil things about using tables for layout is that it forces you to use word-length restrictions on text content and width restrictions on image content. Tables expand when there is a single long word. Since all of the comments are in a single table, one 9000px-long word in a comment causes other paragraphs, even paragraphs in other comments, to wrap at 9000px instead of at the edge of the browser window. Without layout tables, the long word would still make a horizontal scrollbar appear, but other comments would wrap at the edge of the screen as if there had been no scrollbar-forcing comment.

    For some other problems with table layouts, see my comment at webmasterworld. Note that tables are great for tabular data, but using them for layout at the same time makes them less useful for tabular data.

    One other advantage of using CSS rather than tables is especially applicable to Slashdot: over a slow connection, users of older browsers such as IE 6 for Windows would be able to see the first comment without waiting for the rest of the comments to load. Mozilla can display comments one at a time despite the table-heavy layout, but last time I checked, it could only do so in Slashdot's light mode.

    In Slashdot light mode, fixing the page-expanding-comment problem may be as simple as removing a single table tag. In heavy mode, it requires rewriting the layout to replace several layers of nested tables with divs and CSS. (Examples of existing light and heavy modes: light, heavy.) You can use the "block structure" web development bookmarklet to give each table a border (blue, green, or red depending on nesting level) if you want to see how the tables are nested without digging through the HTML source.

    --
    The shareholder is always right.