in reply to Re^3: Prototype for constant items???
in thread Prototype for constant items???

Sadly thats only half of the truth. Many builtins can't be modelled with prototypes and rely on magicly hidden parsing rules.

So prototypes are only a crippled mechanism.

The fact that you can restrict to scalarrefs of $variables with \$ but not to refs of literals is an obvious gap in the definition, which you can't deny.

The possibility to warn about errors like in join @a,@b could make perl much more user friendly.

I don't even see a possibility to warn about this at runtime!!!

(well except magic things like using caller to parse the calling the line of code)

Cheers Rolf

Replies are listed 'Best First'.
Re^5: Prototype for constant items???
by moritz (Cardinal) on Sep 25, 2009 at 14:04 UTC
    Sadly thats only half of the truth. Many builtins can't be modelled with prototypes and rely on magicly hidden parsing rules.

    That's why I wrote syntactically resemble

    And yes, this is indeed a problem. Maybe not for own function (which rarely need such things), but when you try to override built-ins. For example autodie does that, but can't handle all the variants that the core functions do.

    It's one of the things we try to make better in Perl 6: no built-in should rely on magic that's not available to the user, so that everything can be overridden and mimicked. So far I think we did a rather good job at that, though much of that isn't implemented yet.

    As far as we can assure that candidate lists known at compile time, it would also be possible to catch some form of errors then (like arity mismatch).

    Perl 6 - links to (nearly) everything that is Perl 6.