Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Creating modules with OO and functional interfaces.

by broquaint (Abbot)
on May 14, 2002 at 11:58 UTC ( [id://166420]=note: print w/replies, xml ) Need Help??


in reply to Creating modules with OO and functional interfaces.

This sort of thing is generally discouraged in the world of OO where a consistent interface to the class is fairly key[1]. The mixing of a procedural[2] interface with class/object methods is rather counter-intuitive (where's my object state kept?!?). If you look at the source of CGI you can see it implements this mixing of styles by using a 'magical' method called self_or_default() which basically gets around the fact that a method is being called as a function. However if you're deadset on implementing both styles, then perl's certainly the language to do it in ;-) Check out the code for the self_or_default() method in CGI for some pointers on how to do this (it basically checks whether it's first argument is a reference to a CGI object or not and does the right thing).
HTH

_________
broquaint

[1] there's an interesting debate on this topic here between TheDamian and tilly
[2] not functional, for functional + OO programming check out Haskell or OCaml

  • Comment on Re: Creating modules with OO and functional interfaces.

Log In?
Username:
Password:

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

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

    No recent polls found