Exegesis 3 Posted

pudge on 2001-10-05T21:15:33

Trey writes "For all those wanting to see Apocalypse 3 in action, Damian has written Exegesis 3."

Excellent. Now if I can only finish reading Apocalypse 3 ... DARN YOU SPACE-TIME CONTINUUM! DARN YOU TO HECK!


When?

mshiltonj on 2001-10-06T00:09:13

When all is said and done, when I we going to see a working beta of perl6? Is this 6 months away, 2 years away... any timeframe at all? If you had to guess?

Re:When?

Damian on 2001-10-06T00:48:11

When all is said and done, when I we going to see a working beta of perl6?

You mean: apart from the one in my head that I use to write the Exegeses? ;-)

My best guess would be about 12 months from now, though there might well be alphas for parts of the language within six months.

Damian

tuple context?

pixel on 2001-10-06T15:43:01

Is the
my ($name, $vers, $status, $costs) = ;
ability to return only 4 scalars available for normal functions?
eg wantarray returning 4 ?

Re:tuple context?

pixel on 2001-10-06T15:46:00

booh, "Plain Old Text" ate the end, it should of course be:

my ($name, $vers, $status, $costs) = <$fh>;

Re:tuple context?

Damian on 2001-10-07T01:34:17

Assuming Larry accepts the gist of RFC 21, then yes. Using , any subroutine will be able to determine how many values it's expected to return.

Want

robin on 2001-10-07T16:10:51

You can already do that in Perl 5, if you install my Want module.

Question on adverb syntax

Trey on 2001-10-08T04:30:08

Damian gives the example code
  sub mean (*@values : $type //= 'arithmetic') {
                given ($type) {
                        when 'arithmetic': { return sum(@values) / @values; }
                        when 'geometric': { return product(@values) ** (1/@values) }
                        when 'harmonic': { return @values / sum( @values ^** -1 ) }
                        when 'quadratic': { return (sum(@values ^** 2) / @values) ** 0.5 }
                }
                croak "Unknown type of mean: '$type'";
        }
and I'm wondering about the calling syntax.

Would you be able to write
mean arithmetic:@vals
or would you have to write
mean 'arithmetic':@vals?
Is quoting defaulted to, like with the old => operator?

Re:Question on adverb syntax

Damian on 2001-10-08T07:11:13

Would you be able to write
mean arithmetic:@vals
or would you have to write
mean 'arithmetic':@vals?


Neither, I'm afraid. Since the @values parameter is on the left and the $type parameter is on the right, you'd write:

mean @values : 'arithmetic'

And, no, there's no autoquoting, unless you explicitly specify it:

sub mean (*@values : $type is stringified //= 'arithmetic') {

(and Larry hasn't signed of on such a parameter trait yet either)

Re:Question on adverb syntax

Trey on 2001-10-08T13:04:03

Ah, then clearly more than meets the eye is going on with your print examples. Can one put an adverb anywhere in the parameter list when declaring a subroutine, or only at the end? I notice that the empty adverb list is used in

        print : ($x * $y) * $z;

in order to effect the old print +(...), ...; behavior.

Or I think I do.... Surely the filehandle (empty in this case) is an initial adverb and the direct objects are the parameters. But if adverbs are only permitted at the end, then I guess print could take any number of adverbs but only a single, optional, filehandle parameter. That seems weird. So what does print's signature look like? Can one declare several adverbs in a sub declaration?

Re:Question on adverb syntax

Damian on 2001-10-09T06:57:19

...clearly more than meets the eye is going on with your print examples... So what does print's signature look like?

It has two (that's going to be common in Perl 6).

One is colonic:

print ( $filehandle //= $*OUT : *@list )

The other is not:

print ( *@list )

So, in the colonic version (we have to find a better adjective!), it's the values to be printed that are conceptually the adverbs.

Like I've said elsewhere though: the use of post-colonic parameters as adverbs is merely a way of thinking about them. All that matters is that the parameter list of any suitably defined subroutine/function can be divided into two sections by a colon. Which of those sections you consider adverbial is entirely up to you.

Re:Question on adverb syntax

Trey on 2001-10-09T15:45:46

Like I've said elsewhere though: the use of post-colonic parameters as adverbs is merely a way of thinking about them.

I got it. Thanks!

[print] has two (that's going to be common in Perl 6).

One is colonic:

              print ( $filehandle //= $*OUT : *@list )

The other is not:

              print ( *@list )


How would I refer to these? Is 100% of the signature required, or just some disambiguating portion?

      temp &myprint := &print( $filehandle //= $*OUT: *@list )

would work, I assume (can I omit that space before the colon?), but would

      temp &myprint := &print( $filehandle : *@list)

or

      temp &myprint := &print ( $foobar : *@baz )

or

      temp &myprint := &print ( $filehandle : @list)

or even

      temp &myprint := &print ( $ : *@ )?

Re:Question on adverb syntax

Damian on 2001-10-10T02:40:05

How would I refer to these? Is 100% of the signature required, or just some disambiguating portion?

Probably just the type-and-number components of the signature, with the parameter names optional (and ignored). So any of:

        temp &myprint := &print($filehandle : *@list);
        temp &myprint := &print($foobar : *@baz);
        temp &myprint := &print($:*@);

unary * thingy

da5id on 2001-10-08T21:35:49

Shouldn't my ($name, $vers, $status, $costs, @and_the_rest) = <$fh>;
be written as my ($name, $vers, $status, $costs, *@and_the_rest) = <$fh>;

Or am I totally off ?? - Just wondering...

Re:unary * thingy

Damian on 2001-10-09T06:48:56

Or am I totally off ??

You're totally off. ;-)

The slurpative asterisk is only needed in parameter lists or the lvalues of a := binding operation.

Plain ol' assignment in Perl6 remains exactly the same as plain ol' assignment in Perl 5.