Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: The value of declarations

by moritz (Cardinal)
on Apr 07, 2009 at 17:38 UTC ( [id://756092]=note: print w/replies, xml ) Need Help??


in reply to Re^2: The value of declarations
in thread The value of declarations

I wonder, can you do any reliable compile time checks on methods at all? I think this is valid:
my $x = eval 'class A { method foo($bar, $baz} }; A.new'; $x.foo();

Any compile time check would complain about a missing method.

Replies are listed 'Best First'.
Re^4: The value of declarations
by TGI (Parson) on Apr 08, 2009 at 22:00 UTC

    Some checks could be done if you had a way to tell the compiler you weren't going to do something like this.

    __PACKAGE__->no_monkey_business; # no new methods/method signatures c +an happen now. # or perhaps use static_methods qw( MyClass ); #compile this class with only expli +citly declared methods allowed.

    Where the declaration says that only the methods that exist for the class at that time, or perhaps those that have been explicitly declared are available.

    Even better if you could turn it off from outside the class file, so you could do some monkey patching if needed:

    # in main: no static_methods MyClass; # uses MyClass with static_methods turned +off.


    TGI says moo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-12-06 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (39 votes). Check out past polls.