develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: RFC 203 (v1) Arrays: Notation for declaring and creating arrays

Thread Previous | Thread Next
From:
c.soeller
Date:
September 8, 2000 23:23
Subject:
Re: RFC 203 (v1) Arrays: Notation for declaring and creating arrays
Message ID:
m13XeOZ-002IJxC@csnote.mph.auckland.ac.nz
Perl6 RFC Librarian wrote:

> The bounds of an array or list can be specified at run time, of course:
> 
>   my int @t1 :bounds(@dimList) = getFromSomeplace();

Hm, I think some clarification would be good. I'd imagine three cases:
(1) getFromSomeplace returns an untyped and unbounded LOL. In that case
I'd write

   my int @t1 : bounds = getFromSomeplace();

and the bounds should be automatically figured out from the returned
LOL. (2) getFromSomeplace returns already a typed bounded array:

   my @t1 = getFromSomeplace();

or (3) getFromSomeplace returns a normal perl list or LOL and I want it
to be reshaped (according to @dimList with clipping?) into my new bound
array:

   my int @t1 :bounds(@dimList) = getFromSomeplace();

> 
> Where the type and bounds of an array can be derived at run time, it is
> not necessary to specify them explicitly:
> 
>   my int @t1 :bounds(@dimList) = getFromSomeplace();
>   my int @t2 :bounds(@dimList) = getFromSomeplaceElse();
>   my @prod = @t1 * @t2;   # @prod magically has type (int) and :bounds (@dimlist)

What happens when pairing typed/untyped bounded/unbounded arrays in such
operations. The stricter one wins? I'd imagine the usual type
conversions happen automatically. Should there be an RFC detailing the
data types and conversions that one would want, e.g. a complex type,
etc?

> and its bounds can be locked in as well if required:
> 
>   my @some_LOL = ([1,2],
>                   [3,4]);
>   my int @array :bounds(@#some_LOL) = @some_LOL;
> 

Again, couldn't we just imply the bounding, i.e. 

    my int @array :bounds = @rvalue;

always meaning

    my int @array :bounds(@#rvalue) = @rvalue;

  Christian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About