Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • sub setHiddenInNavigation {
      my ($this, $hideInNavigation) = @_;
      $this->{hideInNavigation} = $hideInNavigation;
    }

    really isn't any worse than the PHP version. Sure, you gain an extra line, but you 'sub' is shorter than 'function', and you can lose the 'return' and 'public'. So, less typing overall.

    • What happens if you call it with 17 arguments? A signature can guard against that. Second, what happens if you misspell the hash key? You may or may not get an error at that point, but have it happen later on (if at all). PHP's version will have a failure when calling a non-existent method. (I also hope that PHP's syntax allows validation rather than blanket assignment, but I don't know it well enough.)

      • What happens if you call it with 17 arguments? A signature can guard against that.

        You'd expect that to be the case, but it isn't in PHP. PHP actually handles that exactly like my Perl version---it ignores the extra 16 arguments. That's how PHP implements variable numbers of arguments. So, PHP's method signature's have fooled you.

        Second, what happens if you misspell the hash key? You may or may not get an error at that point, but have it happen later on (if at all).

        This is indeed one drawback to the use of hash keys for object variable storage. But... PHP does the same thing. It'll happily create that variable for you on assignment.

        (I also hope that PHP's syntax allows validation rather than blanket assignment, but I don't know it well enough.)

        Not sure if its been added in PHP5, but 4 didn't.