Branch: Tag:

2008-03-31

2008-03-31 15:07:39 by Martin Stjernholm <mast@lysator.liu.se>

Kludges to avoid type warnings on correctly typed strict_types code
that uses sort_arrays et al.

Rev: lib/modules/Array.pmod:1.109

151:   //! Applies the function @[sum] columnwise on the elements in the   //! provided arrays. E.g. @expr{sum_array(`+,a,b,c)@} does the same   //! as @expr{`+(a[*],b[*],c[*])@}. - array sum_arrays(function(mixed ...:mixed) sum, array ... args) + array sum_arrays(function(int(0..0) ...:mixed) sum, array ... args)   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    array ret = allocate(sizeof(args[0]));    for(int e=0; e<sizeof(args[0]); e++)    ret[e] = sum( @column(args, e) );
175:   //! @[map()], @[sort()], @[`>()], @[dwim_sort_func], @[lyskom_sort_func],   //! @[oid_sort_func]   //! - array sort_array(array arr, function(mixed,mixed,mixed ...:int)|void cmp, + array sort_array(array arr, function(int(0..0),int(0..0),mixed ...:int)|void cmp,    mixed ... args)   { -  +  // FIXME: The two int(0..0) in the function prototype above are +  // kludges to avoid strict_type warnings on correctly typed cmp +  // functions. The correct way to fix it would be to infer the real +  // type from the array elements in arr. +     array bar,tmp;    int len,start;    int length;
730:   //! Array.all( ({ 2, 4, 6, 8 }), `<, 17 )   //! @seealso   //! @[any], @[has_value] - int(0..1) all( array a, function(mixed, mixed ...:mixed) predicate, + int(0..1) all( array a, function(int(0..0), mixed ...:mixed) predicate,    mixed ... extra_args )   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    foreach( a, mixed elem ) -  if( !predicate( elem, @extra_args ) ) +  if( !predicate( [int(0..0)] elem, @extra_args ) )    return 0;    return 1;   }
747:   //! Array.any( ({ 2, 4, 6, 8 }), `>, 5 )   //! @seealso   //! @[all], @[has_value] - int(0..1) any( array a, function(mixed, mixed ...:mixed) predicate, + int(0..1) any( array a, function(int(0..0), mixed ...:mixed) predicate,    mixed ... extra_args )   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    foreach( a, mixed elem ) -  if( predicate( elem, @extra_args ) ) +  if( predicate( [int(0..0)] elem, @extra_args ) )    return 1;    return 0;   }
766:   //! > ({ ({ 4, 5, 6 }), ({ 0, 1, 2, 3, 7, 8 }) })   //! @seealso   //! @[filter], @[`/], @[`%] - array(array) partition( array a, function(mixed, mixed ...:mixed) arbiter, + array(array) partition( array a, function(int(0..0), mixed ...:mixed) arbiter,    mixed ... extra_args )   { -  +  // FIXME: int(0..0) in the function prototype above is a kludge. +  // See the FIXME in sort_array.    array first = ({}), second = ({});    foreach( a, mixed elem ) -  if( arbiter( elem, @extra_args ) ) +  if( arbiter( [int(0..0)] elem, @extra_args ) )    first += ({ elem });    else    second += ({ elem });