Re: how to write literals of some Perl 6 types?

2008-12-03 Thread TSa
HaloO, Darren Duncan wrote: But some significant ones I don't know and really want to know: Bit Here we could get away with defining two new enums, e.g. Bit::High and Bit::Low. And I want to pose the question if we really need two types Bool and Bit. Blob Set Bag Mapping

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread TSa
HaloO, [EMAIL PROTECTED] wrote: The literals for Bit are just 0 and 1. I doubt that this works. I assume that there are integer calculations that give the result 1 as an Int. Then comparing these with === to the literal 1 should fail because the types mismatch: my Int $x = 7 - 6; #

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread Darren Duncan
TSa wrote: Here we could get away with defining two new enums, e.g. Bit::High and Bit::Low. I like that approach. Go the same way as Bool and Order value literals. Don't know why I didn't think of it before. And I want to pose the question if we really need two types Bool and Bit. I

Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Aristotle Pagaltzis
Hi all, I occasionally find myself annoyed at having to do something like this (I use Perl 5 vernacular, but it actually crops up in every single language I have ever used): my $i; @stuff = grep !$_-valid, @stuff; while ( @stuff ) { $_-do_something( ++$i ) for @stuff;

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Bruce Gray
On Dec 3, 2008, at 7:14 AM, Aristotle Pagaltzis wrote: --snip-- Does Perl 6 have some mechanism so I could write it along the following obvious lines? my $i; while ( @stuff ) { $_-do_something( ++$i ) for @stuff; } # plus some way of attaching this fix-up just once

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread TSa
HaloO, Darren Duncan wrote: Strong typing in Perl means that Perl is conveniently and reliably keeping track of this user-intended interpretation of the data, so it is easy for any piece of code to act on it in a reasonable way. Strong typing lets user code be clean and understandable as it

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Aristotle Pagaltzis
* Bruce Gray [EMAIL PROTECTED] [2008-12-03 18:20]: In Perl 5 or Perl 6, why not move the grep() into the while()? Because it’s only a figurative example and you’re supposed to consider the general problem, not nitpick the specific example… Regards, -- Aristotle Pagaltzis //

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Jon Lang
Aristotle Pagaltzis wrote: * Bruce Gray [EMAIL PROTECTED] [2008-12-03 18:20]: In Perl 5 or Perl 6, why not move the grep() into the while()? Because it's only a figurative example and you're supposed to consider the general problem, not nitpick the specific example… But how is that not a

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Mark J. Reed
OK, so let's look at the general problem. The structure is this: doSomething(); while (someCondition()) { doSomethingElse(); doSomething(); } ...and you want to factor out the doSomething() call so that it only has to be specified once. Is that correct, Aristotle? The gotcha is that

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Mark J. Reed
On Wed, Dec 3, 2008 at 2:26 PM, Mark J. Reed [EMAIL PROTECTED] wrote: Overall, the goal is to ensure that by the end of the loop the program is in the state of having just called doSomething(), whether the loop runs or not - while also ensuring that the program is in that state at the top

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Patrick R. Michaud
On Wed, Dec 03, 2008 at 02:26:57PM -0500, Mark J. Reed wrote: OK, so let's look at the general problem. The structure is this: doSomething(); while (someCondition()) { doSomethingElse(); doSomething(); } ...and you want to factor out the doSomething() call so that it only has

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Mark J. Reed
On Wed, Dec 3, 2008 at 3:05 PM, Patrick R. Michaud [EMAIL PROTECTED] wrote: It does seem like a closure trait sort of thing, but I don't think it's currently provided by the p6 spec. Perhaps PRE ... ? Isn't PRE { blah; } just short for ENTER { die unless blah; } ? It still has the problem

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread mark . a . biggar
oops make that last if !someCondition(); -- Mark Biggar [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] -- Original message -- From: [EMAIL PROTECTED] loop { doSomething(); next if someCondition(); doSomethingElse(); } -- Mark Biggar

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Mark J. Reed
On Wed, Dec 3, 2008 at 3:42 PM, [EMAIL PROTECTED] wrote: loop { doSomething(); next if someCondition(); doSomethingElse(); } That loops forever, doesn't it? But I think this works: loop { doSomething(); last unless someCondition(); doSomethingElse(); } -- Mark J. Reed

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Mark J. Reed
On Wed, Dec 3, 2008 at 3:44 PM, Mark J. Reed [EMAIL PROTECTED] wrote: On Wed, Dec 3, 2008 at 3:42 PM, [EMAIL PROTECTED] wrote: loop { doSomething(); next if someCondition(); doSomethingElse(); } That loops forever, doesn't it? But I think this works: loop { doSomething();

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Jon Lang
Mark J. Reed wrote: Mark J. Reed wrote: loop { doSomething(); last unless someCondition(); doSomethingElse(); } That is, of course, merely the while(1) version from Aristotle's original message rewritten with Perl 6's loop keyword. As I said, I'm OK with that, personally, but

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread David Green
On 2008-Dec-3, at 10:18 am, TSa wrote: Darren Duncan wrote: Strong typing in Perl means that Perl is conveniently and reliably keeping track of this user-intended interpretation of the data, so it is easy for any piece of code to act on it in a reasonable way. Strong typing lets user code

Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-03 Thread Eirik Berg Hanssen
Mark J. Reed [EMAIL PROTECTED] writes: OK, so let's look at the general problem. The structure is this: doSomething(); while (someCondition()) { doSomethingElse(); doSomething(); } ...and you want to factor out the doSomething() call so that it only has to be specified once.

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread Jon Lang
Darren Duncan wrote: Now, with some basic types, I know how to do it, examples: Bool # Bool::True Please forgive my ignorance; but are there any cases where 'Bool::True' can be spelled more concisely as 'True'? Otherwise, this approach seems awfully cluttered. -- Jonathan Dataweaver

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread Patrick R. Michaud
On Wed, Dec 03, 2008 at 02:50:23PM -0800, Jon Lang wrote: Darren Duncan wrote: Now, with some basic types, I know how to do it, examples: Bool # Bool::True Please forgive my ignorance; but are there any cases where 'Bool::True' can be spelled more concisely as 'True'? Otherwise,

Re: how to write literals of some Perl 6 types?

2008-12-03 Thread Darren Duncan
TSa wrote: Darren Duncan wrote: Strong typing in Perl means that Perl is conveniently and reliably keeping track of this user-intended interpretation of the data, so it is easy for any piece of code to act on it in a reasonable way. Strong typing lets user code be clean and understandable as