Perl-Sensitive Sunglasses | |
PerlMonks |
Is it a scalar or a hash?by DrZaius (Monk) |
on May 13, 2001 at 21:39 UTC ( [id://80066]=perlmeditation: print w/replies, xml ) | Need Help?? |
Good day, fellow patrons. I've been toying with this for every since I woke this morning. I was working on this problem before I went to bed.
Imagine you are writing code. Imagine you have a subroutine, foo(), that you think will only ever require one argument, ever. You're code base is growing and growing. Soon, there are many calls to this mysterious subroutine. One day, you realize your shortsightedness. You need to pass your subroutine a hash of data. A lot of stuff is using this subroutine and you don't want to break this code, or update it yet. Basically, too much uses the interface to change it. One solution I've toyed with is creating a wrapper to the old subroutine with a bit of magic like this: Of course, java/c++ have built in answers for this, but you also have to use subroutine prototypes everywhere to accomplish this. How do you elegantly solve this problem if foo() originally required 2 arguments?
Back to
Meditations
|
|