Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: What would you change?

by dragonchild (Archbishop)
on May 19, 2008 at 01:51 UTC ( [id://687272]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What would you change?
in thread What would you change?

vec() is prototyped. This pisses me off.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^4: What would you change?
by BrowserUk (Patriarch) on May 19, 2008 at 02:43 UTC
      my $thing = 'a' x 10; my @params = ( 2, 3 ); vec( $thing, @params ) = 0;
      That results with "Not enough arguments for vec()." And, illustrates in brilliant colors the stupidity of compile-time checking in a dynamic language.

      Frankly, if we wanted to have compile-time checks, we should be telling the compiler what we expect to happen. So, for example, if @params should have 2 and only 2 things, we should be able to say that. Then, vec() knows that if @params makes it to him, it's got two things. But, even that sucks because you'd have to assign two things to @params - you wouldn't be be able to build it up using push.

      So, compile-time checks suck.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
        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 :)


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://687272]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found