Simon Cozens [EMAIL PROTECTED] writes:
Luke Palmer:
So modules that introduce new concepts into the language can add new
syntax for them without working with (ugh) a source filter. And some of
these new syntaxes in the core language will actually be in standard
modules, if they're not
Piers Cawley writes:
Simon Cozens [EMAIL PROTECTED] writes:
But it isn't, and I don't know why it isn't, and so we end up
spending loads of time discussing things that can be punted out to
modules. Designing Perl 6 is hard enough; let's not try to fill
CP6AN at the same time.
But the
On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote:
No. gather{} is a generator (assuming nothing about its name or
existance whatsoever). It runs some code, gathering up each pick()
(same assumption) into a list, and returning that.
Thanks for the post Luke. I'd seen what Larry
On Thu, Nov 20, 2003 at 07:27:56PM -0600, Jonathan Scott Duff wrote:
: On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote:
: One wonders what the return value of a loop will be:
:
: my $what = do {
: while $cond {...}
: }
:
: I would expect it to be the value of the
Jonathan Lang writes:
Larry Wall wrote:
So far we've only allowed is parsed on the macro itself, not on
individual arguments. Still, that's an interesting idea.
Forgive me if this has already been addressed, but this could have some
useful applications:
So far, everything I've read
Larry Wall writes:
And nested modifiers are still quite illegal in Standard Perl 6.
Right.
Anybody else get the feeling we should write that down somewhere, so we
don't have to have this conversation again in a few months?
Smylers
Larry Wall writes:
On Wed, Nov 19, 2003 at 08:08:49AM +1100, Damian Conway wrote:
: Michael Lazzaro wrote:
:
: return if $a { $a }
:
: Means:
:
:if ($a) { return $a } else { return undef }
No, it's a syntax error. You must write
return do { if $a { $a } }
to
On Wed, Nov 19, 2003 at 12:49:21PM -0800, Larry Wall wrote:
Sorry, I wasn't being very clear. It wouldn't be logically attached to
the outside of the for, but to the inside of the confer, or whatever:
@foo = gather {
for @a - $x { pick $x if mumble($x) }
DEFAULT { @results
Smylers [EMAIL PROTECTED] writes:
Larry Wall writes:
And nested modifiers are still quite illegal in Standard Perl 6.
Right.
Anybody else get the feeling we should write that down somewhere, so we
don't have to have this conversation again in a few months?
It'll be in the summary.
On Tuesday, November 18, 2003, at 12:15 PM, Luke Palmer wrote:
Oh, and if you really want to do that return thing without using a
Cgiven, you can just:
sub blah {
return $a || goto CONT;
CONT:
...
}
I don't see what's wrong with that. :-p
Umm... refresh my/our memory.
Larry Wall [EMAIL PROTECTED] wrote:
Also, since multi is orthogonal to naming ...
So I'm wondering what the correct syntax is to grab a reference to a group
of multi-somethings. Example:
multi sub foo(Int $a:) {...};
multi sub foo(String $a:) {...};
my $ref = multi foo;
$ref(hello); # calls
On Thu, 20 Nov 2003, Dave Whipp wrote:
Larry Wall [EMAIL PROTECTED] wrote:
Also, since multi is orthogonal to naming ...
So I'm wondering what the correct syntax is to grab a reference to a group
of multi-somethings.
While Larry will probably weigh in on this, I'd rather you not actually
Jonathan Scott Duff writes:
On Wed, Nov 19, 2003 at 12:49:21PM -0800, Larry Wall wrote:
Sorry, I wasn't being very clear. It wouldn't be logically attached to
the outside of the for, but to the inside of the confer, or whatever:
@foo = gather {
for @a - $x { pick $x if
On Tue, Nov 18, 2003 at 11:05:57AM -0800, Michael Lazzaro wrote:
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
Given that we've introduced the concept of if having a return status:
my $result = if ($a) { $a } else { $b };
Would that then imply that
sub blah {
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 2:06 PM
To: [EMAIL PROTECTED]
Subject: Re: Control flow variables
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
Given that we've introduced the concept of if having a
return status:
my $result
Michael Lazzaro writes:
[EMAIL PROTECTED] (Dan Sugalski) writes:
Luke Palmer:
That's illegal anyway. Can't chain statement modifiers :-)
Will be able to.
I was under the strong impression that Larry had decided that
syntactic ambiguities prevented this from happening.
I also
On Tue, Nov 18, 2003 at 11:37:22PM +0100, Seiler Thomas wrote:
So... lets call a function instead:
my $is_ok = 1;
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
$is_ok = 0;
last;
}
}
if $is_ok {
yada() # has
Austin Hastings wrote:
I'm way not sure about how the vector context result of iteration
structures
will work. Specifically, what happens when a loop forks a thread, or
passes
to a parallelized coroutine? There may not actually BE a result. (Of
course,
in a right-thinking system this will be
Damian Conway wrote:
push @moves, [$i, $j];
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
pop @moves;
last;
}
}
Thomas Seiler writes:
my $is_ok = 1;
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
$is_ok = 0;
last;
}
Austin Hastings wrote:
I'm way not sure about how the vector context result of iteration
structures
will work. Specifically, what happens when a loop forks a thread, or
passes
to a parallelized coroutine? There may not actually BE a result. (Of
course,
in a right-thinking system this
Smylers == Smylers [EMAIL PROTECTED] writes:
Smylers I also was under the strong impression that Larry had decreed
Smylers that we wouldn't have chained statement modifiers ... but I
Smylers thought it was because Larry had decided they would be a bad
Smylers thing to have rather than because
-Original Message-
From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 19, 2003 9:46 AM
To: [EMAIL PROTECTED]
Subject: Re: Control flow variables
Smylers == Smylers [EMAIL PROTECTED] writes:
Smylers I also was under the strong impression that Larry
Randal == Randal L Schwartz [EMAIL PROTECTED] writes:
Randal I actually consider that an annoying statement. I have to back up
Randal three times to figure out what it means.
And before someone whips out the Schwartzian Transform to undermine
my statement... please note that in Perl6, you'll
Piers Cawley writes:
All of which means you can wrap it up in a macro and prove Simon's
point about what's syntax and what's CP6AN:
macro unless_all( Block test is parsed /perl.expression/,
Block consequence, [EMAIL PROTECTED] )
{ my $guard = Object.new;
On Wed, Nov 19, 2003 at 08:08:49AM +1100, Damian Conway wrote:
: Michael Lazzaro wrote:
:
: So, just to make sure, these two lines are both valid, but do completely
: different things:
:
: return if $a;
:
: Means:
:
: if ($a) { return }
:
:
: return if $a { $a }
:
: Means:
:
:
On Wed, Nov 19, 2003 at 09:30:15AM -0700, Luke Palmer wrote:
: Piers Cawley writes:
: All of which means you can wrap it up in a macro and prove Simon's
: point about what's syntax and what's CP6AN:
:
: macro unless_all( Block test is parsed /perl.expression/,
: Block
Larry Wall wrote:
On Tue, Nov 18, 2003 at 06:28:59PM -0500, Gordon Henriksen wrote:
my @b = for @a - $_ {
...
}
That will be a syntax error. Generators are too mind-stretching to
inflict on novices [...]
I making the point that within the context of this
Gordon Henriksen writes:
Larry Wall wrote:
On Tue, Nov 18, 2003 at 06:28:59PM -0500, Gordon Henriksen wrote:
my @b = for @a - $_ {
...
}
That will be a syntax error. Generators are too mind-stretching to
inflict on novices [...]
I making the point that
On Wed, Nov 19, 2003 at 09:12:01AM -0600, Jonathan Scott Duff wrote:
: On Tue, Nov 18, 2003 at 09:36:31PM -0800, Larry Wall wrote:
: As for the original question that started this whole silly thread,
: control structures that return values should probably be considered
: some kind of generator,
-Original Message-
From: Larry Wall [mailto:[EMAIL PROTECTED]
On the other hand, putting the default up front is clearer if the
block is long. Could even be something like:
@foo = gather is default(@results) {
for @a - $x { pick $x if mumble($x) }
}
And Cgather is
[EMAIL PROTECTED] (Austin Hastings) writes:
What does Cscatter do?
That's the operator that's used to assign values to C$^x and
friends in closures. In all its glory, you give it a set of values,
and it assigns them to a block's undefined variables, quieting those
annoying warnings:
@x =
Larry Wall wrote:
So far we've only allowed is parsed on the macro itself, not on
individual arguments. Still, that's an interesting idea.
Forgive me if this has already been addressed, but this could have some
useful applications:
So far, everything I've read about macro parsing concentrates
I was reading the most recent article on perl.com, and a code segment
reminded me of something I see rather often in code that I don't like.
Here's the code, Perl6ized:
... ;
my $is_ok = 1;
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
$is_ok = 0;
[EMAIL PROTECTED] (Luke Palmer) writes:
I was reading the most recent article on perl.com, and a code segment
reminded me of something I see rather often in code that I don't like.
The code in question got me thinking too; I wanted to find a cleaner
way to write it, but didn't see one.
So, in
Simon Cozens writes:
[EMAIL PROTECTED] (Luke Palmer) writes:
I was reading the most recent article on perl.com, and a code segment
reminded me of something I see rather often in code that I don't like.
The code in question got me thinking too; I wanted to find a cleaner
way to write it,
Luke Palmer:
Well... it is and isn't. At first sight, it makes the language look
huge, the parser complex, a lot of syntax to master, etc. It also seems
to me that there is little discrimination when adding new syntax.
Correct.
But I've come to look at it another way. Perl 6 is doing
On Tue, 18 Nov 2003, Simon Cozens wrote:
Luke Palmer:
That's illegal anyway. Can't chain statement modifiers :-)
Bah, should be able to!
Will be able to.
Dan
--it's like this---
Dan Sugalski
[EMAIL PROTECTED] (Dan Sugalski) writes:
Luke Palmer:
That's illegal anyway. Can't chain statement modifiers :-)
Will be able to.
I thought as much; Perl 6 will only be finally finished when the biotech
is sufficiently advanced to massively clone Larry...
--
quidity Sometimes it's better
-Original Message-
From: Luke Palmer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 9:21 AM
To: Language List
Subject: Control flow variables
I was reading the most recent article on perl.com, and a code segment
reminded me of something I see rather often in code
Austin Hastings writes:
Luke Palmer wrote:
I was reading the most recent article on perl.com, and a code segment
reminded me of something I see rather often in code that I don't like.
Here's the code, Perl6ized:
... ;
my $is_ok = 1;
for 0..6 - $t {
if
On Tue, 18 Nov 2003, Simon Cozens wrote:
[EMAIL PROTECTED] (Dan Sugalski) writes:
Luke Palmer:
That's illegal anyway. Can't chain statement modifiers :-)
Will be able to.
I thought as much; Perl 6 will only be finally finished when the biotech
is sufficiently advanced to massively
[EMAIL PROTECTED] (Austin Hastings) writes:
This is what I was talking about when I mentioned being able to do:
cleanup .= { push @moves: [$i, $j]; }
This reminds me of something I thought the other day might be useful:
$cleanup = bless {}, class {
method DESTROY { ... }
};
On Tue, 18 Nov 2003, Simon Cozens wrote:
[EMAIL PROTECTED] (Austin Hastings) writes:
This is what I was talking about when I mentioned being able to do:
cleanup .= { push @moves: [$i, $j]; }
This reminds me of something I thought the other day might be useful:
$cleanup = bless {},
-Original Message-
From: Luke Palmer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 10:49 AM
To: Austin Hastings
Cc: Language List
Subject: Re: Control flow variables
Austin Hastings writes:
Luke Palmer wrote:
I was reading the most recent article on perl.com
OOPS, totally miss-read your code, ignore my first part of my last
message.
--
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Luke Palmer wrote:
I was reading the most recent article on perl.com, and a code segment
reminded me of something I see rather often in code that I don't like.
Here's the code, Perl6ized:
... ;
my $is_ok = 1;
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
Given that we've introduced the concept of if having a return status:
my $result = if ($a) { $a } else { $b };
Would that then imply that
sub blah {
... # 1
return if $a;# 2
...
-Original Message-
From: Michael Lazzaro [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 2:06 PM
To: [EMAIL PROTECTED]
Subject: Re: Control flow variables
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
Given that we've introduced the concept
Austin Hastings writes:
-Original Message-
From: Michael Lazzaro [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 2:06 PM
To: [EMAIL PROTECTED]
Subject: Re: Control flow variables
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
Given
Austin Hastings writes:
-Original Message-
From: Michael Lazzaro [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 2:06 PM
To: [EMAIL PROTECTED]
Subject: Re: Control flow variables
On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
Given
Would that then imply that
sub blah {
... # 1
return if $a;# 2
... # 3
}
...would return $a if $a was true, and fall through to (3) if it was
false?
It sure should, provided there were a correct context waiting, which
would
quite
Luke Palmer started a discussion:
I see this idiom a lot in code. You loop through some values on a
condition, and do something only if the condition was never true.
$is_ok is a control flow variable, something I like to minimize. Now,
there are other ways to do this:
if (0..6 == grep - $t
Michael Lazzaro wrote:
So, just to make sure, these two lines are both valid, but do completely
different things:
return if $a;
Means:
if ($a) { return }
return if $a { $a }
Means:
if ($a) { return $a } else { return undef }
Damian
-Original Message-
From: Damian Conway [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 4:02 PM
To: Language List
Subject: Re: Control flow variables
Luke Palmer started a discussion:
I see this idiom a lot in code. You loop through some values on a
condition
-Original Message-
From: Luke Palmer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 3:11 PM
To: Austin Hastings
Cc: Michael Lazzaro; [EMAIL PROTECTED]
Subject: Re: Control flow variables
Austin Hastings writes:
-Original Message-
From: Michael
On Tue, 18 Nov 2003, Austin Hastings wrote:
This seems excessive, but easily discarded during optimization. On the other
hand, I don't trust the last statement evaluated behavior for loops, since
the optimizer could very well do surprising things to loop statements.
(Likewise, however, for
Austin Hastings writes:
From: Luke Palmer [mailto:[EMAIL PROTECTED]
Austin Hastings writes:
From: Michael Lazzaro [mailto:[EMAIL PROTECTED]
Would that then imply that
sub blah {
... # 1
return if $a;# 2
...
Luke Palmer wrote:
My Cif/Cunless typo may
have misled you, but the original example pushed only if *none* of them
passed the condition.
Ah, sorry, I misunderstood.
So you want:
push @moves, [$i, $j];
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
pop @moves;
-Original Message-
From: Dan Sugalski [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 4:34 PM
To: Language List
Subject: RE: Control flow variables
On Tue, 18 Nov 2003, Austin Hastings wrote:
This seems excessive, but easily discarded during optimization
Damian Conway wrote:
push @moves, [$i, $j];
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
pop @moves;
last;
}
}
Indeed, an elegant way around the problem.
So... lets call a function instead:
my $is_ok = 1;
for 0..6
Seiler Thomas wrote:
So... lets call a function instead:
my $is_ok = 1;
for 0..6 - $t {
if abs(@new[$t] - @new[$t+1]) 3 {
$is_ok = 0;
last;
}
}
if $is_ok {
yada() # has sideeffects...
}
That's just:
for 0..6, 'ok' - $t
Joseph Ryan wrote:
Not to be a jerk, but how about:
my $is_ok = 1;
for @array_of_random_values_and_types - $t {
if not some_sort_of_test($t) {
$is_ok = 0;
last;
}
}
if $is_ok {
yada() # has sideeffects...
}
That's just:
given
On Tuesday, November 18, 2003, at 06:11 PM, Joseph Ryan wrote:
Not to be a jerk, but how about:
my $is_ok = 1;
for @array_of_random_values_and_types - $t {
if not some_sort_of_test($t) {
$is_ok = 0;
last;
}
}
if $is_ok {
yada() # has
David Wheeler wrote:
On Tuesday, November 18, 2003, at 06:11 PM, Joseph Ryan wrote:
Not to be a jerk, but how about:
my $is_ok = 1;
for @array_of_random_values_and_types - $t {
if not some_sort_of_test($t) {
$is_ok = 0;
last;
}
}
if $is_ok {
David Wheeler wrote:
Isn't that just:
for @array_of_random_values_and_types, 'ok' - $t {
when 'ok' { yada(); last }
last unless some_sort_of_test($t);
}
IOW, the topic is only 'ok' when all of the items in the array have been
processed
Unless, of course, the string 'ok'
On Tuesday, November 18, 2003, at 06:44 PM, Joseph Ryan wrote:
And also if @array_of_random_values contains 'ok'.
D'oh! See Damian's solution, then. ;-)
David
--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
66 matches
Mail list logo