in reply to Re^5: What would you change?
in thread What would you change?
That results with "Not enough arguments for vec()." And, illustrates in brilliant colors the stupidity of compile-time checking in a dynamic language.
I see what you mean. And boy, do I ever agree with you regarding attempts to force static language semantics upon dynamic languages.
Playing with this, my first thought was to disable the prototype checking:
&vec( $thing, @params ) = 1;
but that resulted in: Can't modify non-lvalue subroutine call which came as a complete surprise.
I never knew that the l-valueness of a subroutine was allied to its prototype. The best alternative I came up with is:
sub myvec :lvalue { CORE::vec( $_[ 0 ], $_[ 1 ], $_[ 2 ] ) }
which once you get past the deliberate error ;) in the example:
my $thing = 'a' x 10; my @params = ( 2, 3 ); myvec( $thing, @p ) = 1;; Illegal number of bits in vec
seems to work fine. Of course, you pay a performance penalty for the indirection, but hey. CPU cycles don't matter :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: What would you change?
by ikegami (Patriarch) on May 20, 2008 at 00:40 UTC | |
by BrowserUk (Patriarch) on May 20, 2008 at 00:45 UTC | |
by ikegami (Patriarch) on May 20, 2008 at 06:31 UTC | |
|
Re^7: What would you change?
by dragonchild (Archbishop) on May 20, 2008 at 00:08 UTC | |
by BrowserUk (Patriarch) on May 20, 2008 at 00:39 UTC | |
by dragonchild (Archbishop) on May 20, 2008 at 02:51 UTC | |
by BrowserUk (Patriarch) on May 20, 2008 at 03:26 UTC |