[Php-tuxedo-development] Advice wanted on function arguments
Status: Pre-Alpha
Brought to you by:
cdog1977
From: Brian F. <bf...@mn...> - 2002-01-05 19:12:19
|
In an external php module project (php-tuxedo), we have a group of about 7 php functions that, depending on how we design them, could take two different types of arguments. 1. A integer argument 2. A string argument. If the string argument is given, there is another routine that can convert it to the corresponding integer argument, but its not guarenteed to match. Using the integer argument is guarenteed to work; hence we really need to support the integer args. However, the majority of users will want to use the string argument because its more intuitive and they should provide the translation tables to allow strings to work. I'd like to come up with a solution flexible enough for both. And I have come up with three different solutions... 1. Create two different function names/entry points, one set for ints, one set for strings. 2. Overload the function arguments and check which type of arg is being passed. 3. Screw it and just accept the ints, and let the users nest a function (in their PHP code) to convert to strings if they want. Questions... 1. Any slick way to do solution 1, say with aliases or something? 2. How difficult / successful is it to test the arg type for solution 2. Let me re-stress, I'm talking about a PHP C code module, not PHP code. I can provide more detailed description if you need. Thoughts? Brian |