From:             garyb at fxt dot com
Operating system: 
PHP version:      5.1.0b3
PHP Bug Type:     Feature/Change Request
Bug description:  Restructure array functions for PHP6

Description:
------------
The list of PHP functions that operate on arrays has grown large, but
could be restructured to fit into a more coherent model.  Multidimensional
array operations in any language can be confusing even in the best
situations.  PHP's array functions seem to have been implemented one at a
time, as someone saw a need.  Some of the functions are overly specific to
a given, rare applicationm and others are not defined well particularly for
multidimensional applications.  It can be difficult to figure out which
function(s) to use/combine to accomplish a particular task.  Just as one
example, array_slice could be more useful for multidimensional arrays if
an array could be given for the offset and length  This would allow one to
slice, for example, all instances of a particular field in a set of
database results.

I would propose a new array function set for a later version of PHP, that
works the same without regard to dimension.  In my experience, the best
implementation of array functionality (disregarding the language syntax)
that I have ever used is the one in APL.  Every function that works on
arrays (which is most of them) does what's expected regardless of
dimensionality, and in almost all cases every argument can be an array. 
Like PHP, APL can view a string as a string or as an array of char.  Later
versions supported structured arrays, akin to objects.  I found APL's basic
functions to be easier to learn and use than any of the 'Mathematica'
clones.  Of course APL just represents one potential approach.

If nobody else is already working on anything in this line, I'd be
amenable to participating in such a project, perhaps first as an extension
- though I can't say I'd be that much help.  It may be that the APL
functions could be used as models for named functions, with similar
monadic/dyadic effects; or an interface to the Octave libraries could be
the best approach.

Reproduce code:
---------------
Example of APL equivalents:
APL          :== function()
    --> effect or equivalent using PHP syntax

A = iota(6)  :== iterate (6)
    --> A = range(6);

B = rho (A)  :== shape (A)
    --> B = count (A);

B = (2 3) rho (A) :== reshape A
    --> B = array ( array (0, 1, 2), array ( 3, 4, 5);
    --> or B = array (range (0,3), range(3,6));

C = (0 1 0 ) select(A) (I forget the APL name)
    --> C = array (array (1), array (4));
    --> no simple equiv in PHP


-- 
Edit bug report at http://bugs.php.net/?id=34061&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34061&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34061&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34061&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34061&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34061&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34061&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34061&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34061&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34061&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34061&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34061&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34061&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34061&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34061&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34061&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34061&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34061&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34061&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34061&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34061&r=mysqlcfg

Reply via email to