develooper Front page | perl.perl6.internals | Postings from September 2002

RE: [netlabs #801] [PATCH] PerlArray in scalar context

Thread Previous | Thread Next
From:
Peter Haworth
Date:
September 5, 2002 05:59
Subject:
RE: [netlabs #801] [PATCH] PerlArray in scalar context
Message ID:
PGM.20020905125834.25085.2458@edison.ioppublishing.com
On Wed, 4 Sep 2002 22:51:53 -0700 (PDT), Sean O'Rourke wrote:
> On Wed, 4 Sep 2002, Brent Dax wrote:
> > Sean O'Rourke:
> > # On Wed, 4 Sep 2002, Brent Dax wrote:
> > # > What if (say) @b is a two-dimensional array?
> > #
> > # Then you get "interesting values of undef" :).  Seriously, I
> > # suspect one of the following:
> > #
> > # 1 - runtime error
> > # 2 - each row (or column) of @b numified to its length
> > # 3 - the first element of each row/col of @b
> > # 4 - the other arrays boosted to the highest dimension
> > #
> > # I like #2, because it is easy and keeps hyper-operation
> > # simple.  If those aren't just numeric operators, but some
> >
> > It's already been defined to be #4.

Where? I just re-skimmed A3 and E3, but didn't find that. All A3 says is
that scalars get promoted to arrays, which makes sense. Going any further
doesn't necessarily DWIM.

> Argh.  Then I need to whinge a bit -- what if it's a ragged array?  What
> if different elements have different dimensions themselves, e.g.
> "[1,[2,3]]"?  I think there's serious can-of-worms potential here, and by
> making hyping more "intelligent", we'll actually make it useful in fewer
> cases.

I defintely agree. Wouldn't it be simpler to just ignore the
extra-dimensionality? Especially when it's a user defined operator;
it could actually want one scalar and one array operand. Maybe we should
have multiple carets to denote hyper-hyper-operators if that's what the
user wants:

  @a = @b ^^* @c;

If hyperoperators get transformed into loops behind the scenes, this
shouldn't be too hard to implement.

-- 
	Peter Haworth	pmh@edison.ioppublishing.com
Override self destruct? (y/n@^%i@&$#
NO CARRIER

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