re: properties

2001-05-24 Thread Damian Conway

MJD just pointed out a minor thinko in the explanatory Perl6 code I posted:

sub gorkulator {
...
return $result is true if defined $result;
return undef is Because($borked);
}

# and later...

if ($res = gorkulator) {
...
}
else {
die $res.Reason;
}

Should, of course be:

die $res.Because

Damian



slices

2001-05-24 Thread Raul Miller

Caution: I'm not yet up to speed on everything perl6.  However, I've
dealt with stuff like slices in a variety of non-perl contexts, and
maybe I'll propose some questions which no one has brought up, yet.

First: @a[@(...)] looks plausible as a slice syntax.  Or -- if you
specify an array value as an index, shouldn't that be a slice?

Second: is there any fundamental difference between an array index and
a function parameter?  Both syntaxes imply taking some values doing
some processing and coming back with a result.  Sure, arrays are more
constrained than the general case -- they're fundamentally simple.
But is there anything wrong with treating (at the semantic layer) array
indexing as anything other than a certain kind of "function call"?

That leads into things like [] vs. () and maybe even [;;] vs. (,,) or
whatever and of course, Larry's dropped so many hints about this
that I'm mostly just rehashing his ideas.

Thanks,

-- 
Raul



Re: slices

2001-05-24 Thread James Mastros

From: "Raul Miller" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 24, 2001 7:49 PM
Subject: slices
> First: @a[@(...)] looks plausible as a slice syntax.  Or -- if you
> specify an array value as an index, shouldn't that be a slice?
I like your second choice better.  That is to say, all of these should
slice:
@foo[1..6]
@foo[@arrayvar]
@foo[list(func())]
@foo[list(1)]

(The last would give a single-element list, and thus probably be useless.)

But what about: @foo[(1,2,3)]?

Are those parens a list-maker, or are they a scalar expression using
the comma operator.  (Or did we get rid of the comma operator when
I wasn't paying attention?)  If we do have @foo[(stuff)] make stuff
be in list context, then that'd be a special case (I think).

-=- James Mastros




Re: slices

2001-05-24 Thread Raul Miller

First off, sorry about the noise -- I expect that Larry will have this
mostly worked out already.  [And, when I re-read Apocalypse 2, I saw
that I had almost literally stolen some of his sentences. *blush*]

On Thu, May 24, 2001 at 10:19:12PM -0400, James Mastros wrote:
> But what about: @foo[(1,2,3)]?
> 
> Are those parens a list-maker, or are they a scalar expression using
> the comma operator.  (Or did we get rid of the comma operator when
> I wasn't paying attention?)  If we do have @foo[(stuff)] make stuff
> be in list context, then that'd be a special case (I think).

It's tempting to say that you need an extra set of parens to make the
comma operator not work.

Then again, there's already a need for two kinds of array index contexts.
If you have 3 dimensional array, and you have a three element array
of indices: are you selecting three sub-arrays, or are you selecting
a single element?  Given that, maybe there's a need for an extra array
indexing context which supports the comma operator.

Then again, it's not very far from there to something like:

sub comma_operator (@args) { return @args[-1]; }

-- 
Raul