Re: Surprise in array concatenation



Thierry Pirot <thierrypirot@xxxxxxxxx> writes:

> Robert A Duff writes:
>
> > It breaks the abstraction called "subprogram". As I showed in my
> > example, a procedure is handed an integer value (X'First), which is an
> > offset from the beginning of some object it knows nothing about, and
> > should know nothing about.
> >
> Do you mean :
> the calling subprogram knows about that object (of which a slice is passed) and
> the called subprogram doesn't and shouldn't ?

Yes, that's exactly what I mean.

> I tend to agree, however, if I got it right, I wonder :
> what about a recursive subprogram ?
> It is both the called and calling program.

Good point. And what about the case where there's no recursion,
but the callee _should_ know about that array which was sliced?
The answer must be some sort of a "subarray" abstraction, which
carries with it the original array (or a reference to it).
I haven't thought this through...

> (This may indeed be a bit sophistic,
> actually I have found Ada's passing of slice bounds quite elegant
> within recursive subprograms
> --- wherein a string is conveniently rendered a recursive object by
> Ada's slices, i.e. strings include slices which are (sub)strings).

Yes, in rare cases, including the recursive case you mention, I have
found some use for slices that remember their bounds within the original
array. But in _most_ cases, I've found it an error-prone annoyance.

> Take it Easy Don't worry Be Happy

Good advice. :-)

- Bob
.



Relevant Pages

  • Re: memory-efficient circshift mex?
    ... Separately store only the slices that must be circulated to the bottom of the array, ... the native circhsift.m naively allocates an additional array of sizeregardless of N. This is of course difficult for me given the size of X. ... // Circular shift a 3-dimensional or higher matrix in the last dimension. ... mwSize ndim, numel, k, slicenumel, slicebytes, kshift; ...
    (comp.soft-sys.matlab)
  • Re: memory-efficient circshift mex?
    ... Separately store only the slices that must be circulated to the bottom of the array, ... the native circhsift.m naively allocates an additional array of sizeregardless of N. This is of course difficult for me given the size of X. ... // Circular shift a 3-dimensional or higher matrix in the last dimension. ... mwSize ndim, numel, k, slicenumel, slicebytes, kshift; ...
    (comp.soft-sys.matlab)
  • Re: Numerical Python question
    ... you're now looping over ten slices of tens of thousands. ... >> original array. ... loop in Python. ...
    (comp.lang.python)
  • Re: Newbie Looking for Advice/Comments on Script
    ... > array, then write out the array in a specific order. ... Please check the Perl FAQ *before* posting: ... Google Groups to do so. ... or, preferred, don't interpolate the slices. ...
    (comp.lang.perl.misc)