use junction

1 view
Skip to first unread message

Juerd

unread,
Apr 25, 2005, 2:33:06 PM4/25/05
to perl6-l...@perl.org
I think it would be great to be able to use a junction with use:

use strict & warnings;

A disjunction could mean any of the listed modules suffices. This comes
in handy when you code something that will work with any of three XML
parsers. Although because ordering matters, the // operator is perhaps
better.

But "use strict & warnigs;" looks great and I wonder if it can work.


Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html

Juerd

unread,
May 3, 2005, 9:27:10 AM5/3/05
to perl6-l...@perl.org
Larry Wall skribis 2005-05-03 6:22 (-0700):
> sub foo (Int&Str &block) {...}
> sub foo (:(Int&Str) &block) {...}
> Alternately, we install a small heuristic and document it in the fine print.

I personally would not mind requiring whitespace around & in those
cases.

If parens are used for the grouping, then why is the colon required?

> The "use" ambiguity might easily be resolved by saying that "use"
> always parses using indirect object syntax, which would distinguish
> use strict & warnings;
> from
> use strict: &warnings;

I thought whitespace after the sigil was no longer allowed? That
certainly fits in the sigil-is-part-of-the-name-thing.

Larry Wall

unread,
May 3, 2005, 9:22:11 AM5/3/05
to perl6-l...@perl.org
On Mon, Apr 25, 2005 at 08:33:06PM +0200, Juerd wrote:
: I think it would be great to be able to use a junction with use:

:
: use strict & warnings;
:
: A disjunction could mean any of the listed modules suffices. This comes
: in handy when you code something that will work with any of three XML
: parsers. Although because ordering matters, the // operator is perhaps
: better.
:
: But "use strict & warnigs;" looks great and I wonder if it can work.

Well, there's a bit of a syntactic problem with & anywhere a term
might be expected after a term, since it will assume you want to
start a &foo. For another example

sub foo (Int&Str &block) {...}

is probably not going to parse right. Maybe that's a good place for

sub foo (:(Int&Str) &block) {...}

Alternately, we install a small heuristic and document it in the fine print.

By and large, we've managed to avoid such heuristics in Perl 6, but maybe
this is a good spot for an evil heuristic.

The "use" ambiguity might easily be resolved by saying that "use"
always parses using indirect object syntax, which would distinguish

use strict & warnings;

from

use strict: &warnings;

(Note: such a colon could possibly be used to distinguish Perl 6 from
Perl 5 in Main too, at least if the first "use" needs a colon.)

I don't know of any easy fix for the "type var" ambiguity though.

However, all that being said, please note that

use strict & warnings: @args;

is unlikely to be useful unless the two modules have a similar
interface. It'd be much more useful to be able to logically cascade
"use" statements as a whole.

Larry

Thomas Sandlaß

unread,
May 3, 2005, 10:55:03 AM5/3/05
to perl6-l...@perl.org
Juerd wrote:
> I personally would not mind requiring whitespace around & in those
> cases.

Same here. Actually the whitespace after & makes the destinction, or not?


> If parens are used for the grouping, then why is the colon required?

Because it escapes into type-space like ::() escapes into name-space :)
--
TSa (Thomas Sandlaß)

Reply all
Reply to author
Forward
0 new messages