Re: consistent way to handle structs
| From: | Markus Fischer | Date: | Fri, 11 Jan 2002 10:45:20 +0000 |
| Subject: | Re: consistent way to handle structs | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-76604@lists.php.net to get a copy of this message | ||
On Fri, Jan 11, 2002 at 11:22:22AM +0100, Hartmut Holzgraefe wrote :
> Georg Richter wrote:
>
> >is there (should be) a consistent way to pass or return a structure?!
> >
> >e.g.:
> >
> >a) Function mktime splits the structure in lot of parameters
> >b) fstat returns a non assoc array
> >c) dio_fstat (which seems to be identical to fstat) returns an assoc array
>
> assoc array IMHO
>
> especialy mktime() is a good example on how *not* to things
> as not everyone in the world is used to month-day-year dates :(
I'm for (+1) assoc return values.
I think the code which is used to handle it is more verbose
then ( $day = $assoc['day']; and not $day = $arr[0]; or
whatever) and it also helps debugging because you can just do
a print_r() on the return type.
If we start to agree on assoc params we should also think of
new functions to more easily parse them to expected variable
types
zend_parse_parameters_hash(hashtable TSRMLS_CC,
" key1:type1,
|optional_key2:type2",
&var1, &var2);
Ok, don't sue me, its just an idea how to simplify those kind
of param-parsings. Zak and I were also discussing about such
a way of parsing more optional argument after his recent
mysql propose.
Maybe Andrei has an idea too?
- Markus
--
Please always Cc to me when replying to me on the lists.