Re: what's new continued

2002-07-08 Thread Iain Truskett

* Damian Conway ([EMAIL PROTECTED]) [08 Jul 2002 10:27]:

[...]
> > given my Doberman $sis is female = .dog[0] but pregnant -> $mother {
> > for my Doberman @puppies = new Doberman x $mother.littersize

> I'd have thought you'd need:

>   for my Doberman @puppies = (new Doberman) x $mother.littersize

Is it just my reading or would that return the same Doberman as each
puppy? i.e. Doberman.new is only called once and then duplicated?


cheers,
-- 
Iain 'Spoon' Truskett. 



Re: what's new continued

2002-07-07 Thread Ashley Winters

On Sunday 07 July 2002 05:33 pm, Ashley Winters wrote:
> my($foo, $bar) = for { $_ = new Stuff }

Err, the parser would die if I did that, never mind. Can I have each, perhaps?

*@foo = each { undef }

I shouldn't be programming on Sunday,
Ashley Winters



Re: what's new continued

2002-07-07 Thread Ashley Winters

On Sunday 07 July 2002 04:10 pm, Ashley Winters wrote:
>
> given my Doberman $sis is female = .dog[0] but pregnant -> $mother {
> for my Doberman @puppies = new Doberman x $mother.littersize

In hindsight, I probably meant
for my Doberman @puppies = ^new Doberman x $mother.littersize

It's hard to come up with working code when there's no compiler for it.
Then again, that just makes it harder for people to disagree with you.

As for the 'bad' semantics of C, can I borrow 
C with no iterator for that? After all, C with no argument 
already does what C with no iterator would otherwise do. I think.

my($foo, $bar) = for { $_ = new Stuff }

It could also work in subs...

my($foo, $bar) = read_lines($*STDIN);

sub read_lines ($it) {
for { $_ = <$it> // last }   # last unshifts $_ from the wanted list
return;# any return-value is after the final for{} value read
}

Well, I can wait for whatever apocalypse is going to specify how to return the 
'wanted' number of values. I'm just spinning my wheels. :)

Ashley Winters



Re: what's new continued

2002-07-07 Thread Damian Conway

Ashley Winters wrote:


> >   $_ = new Doberman for $spot, $rover;
> 
> Hmm, I thought the for topic was made ro at some point. Odd.

Not the standard $_ topic. Only named topics default to read-only.


> However, I still expect to be able to use my() in a loop condition/iterator
> and have it visible to the outer scope!

I too expect it will work.


> given my Doberman $sis is female = .dog[0] but pregnant -> $mother {
> for my Doberman @puppies = new Doberman x $mother.littersize

I'd have thought you'd need:

  for my Doberman @puppies = (new Doberman) x $mother.littersize

Both for precedence, and to get the list semantics of C.

 
> -> Doberman $puppy is cute {
> my @colors := Doberman.colors;
> $puppy.color = @colors[rand(@colors.end)];
> }
> 
> $mother.labor($_) for @puppies;
> }
> 
> $sis.feed();
> 
> I gave way too much thought to that. I need to go, now...

"Once you start down the Perl 6 path, forever will it dominate 
 your coding; consume you it will!"

;-)

Damian



Re: what's new continued

2002-07-07 Thread Damian Conway

> will perl6 still support the indirect object syntax? i thought it was
> going away and that would be:
> 
> Doberman.new

That works too, but the indirect object syntax isn't going away.
TMTOWTDI, after all.


> also is $_ an lvalue alias (topic) for $spot and $rover?

Yep. Only *named* topics default to read-only.


> why not use map:
> 
> my Dog ( $spot, $rover ) = map Doberman.new, 1 .. 2 ;

Because the meaningless constants make it longer than:

  $_ = Doberman.new for my Dog ($spot, $rover);


> i think it is clearer as to what is happening, we are creating 2 new Dog
> objects. 

To each his own, I guess.


> now there is no need for the rw property on $_

Not that there ever was... ;-)


> also if that is working code, then my head is getting twisted in the
> right direction. :)

Looks like. :-)


Damian



Re: what's new continued

2002-07-07 Thread Ashley Winters

On Sunday 07 July 2002 03:05 pm, Damian Conway wrote:
> Ashley Winters wrote:
> > How about:
> >
> > $_ = new Doberman for my Dog ($spot, $rover) is rw;
>
>  I don't think so.
>
> In Perl 6 you'd just need:
>
>   $_ = new Doberman for $spot, $rover;

Hmm, I thought the for topic was made ro at some point. Odd.

However, I still expect to be able to use my() in a loop condition/iterator 
and have it visible to the outer scope!

given my Doberman $sis is female = .dog[0] but pregnant -> $mother {
for my Doberman @puppies = new Doberman x $mother.littersize 
-> Doberman $puppy is cute {
my @colors := Doberman.colors;
$puppy.color = @colors[rand(@colors.end)];
}

$mother.labor($_) for @puppies;
}

$sis.feed();

I gave way too much thought to that. I need to go, now...

Ashley Winters



Re: what's new continued

2002-07-07 Thread Uri Guttman

> "DC" == Damian Conway <[EMAIL PROTECTED]> writes:

  DC> Ashley Winters wrote:
  >> How about:
  >> 
  >> $_ = new Doberman for my Dog ($spot, $rover) is rw;

  DC>  I don't think so.

  DC> In Perl 6 you'd just need:

  DC>   $_ = new Doberman for $spot, $rover;

will perl6 still support the indirect object syntax? i thought it was
going away and that would be:

Doberman.new

also is $_ an lvalue alias (topic) for $spot and $rover?

why not use map:

my Dog ( $spot, $rover ) = map Doberman.new, 1 .. 2 ;

i think it is clearer as to what is happening, we are creating 2 new Dog
objects. now there is no need for the rw property on $_

also if that is working code, then my head is getting twisted in the
right direction. :)

uri

-- 
Uri Guttman  --  [EMAIL PROTECTED]   http://www.stemsystems.com
- Damian Conway Perl Classes -- July 1-3 -- http://stemsystems.com/class/ ---
- Stem and Perl Development, Systems Architecture, Design and Coding 
Search or Offer Perl Jobs    http://jobs.perl.org



Re: what's new continued

2002-07-07 Thread Damian Conway

Ashley Winters wrote:

> How about:
> 
> $_ = new Doberman for my Dog ($spot, $rover) is rw;

 I don't think so.

In Perl 6 you'd just need:

$_ = new Doberman for $spot, $rover;

Or, if you really did want that strong type-checking:

for $spot, $rover -> Dog $dog is rw { $dog = new Doberman }


> Err, whatever.

That works too:

for $spot, $rover{ $_ = new Doberman err whatever() }

 

Damian



Re: what's new continued

2002-07-07 Thread Ashley Winters

On Sunday 07 July 2002 02:19 pm, Damian Conway wrote:
> Ashley Winters asked:
> > > It *might* possibly work to hyper the constructor:
> > >
> > > my ($a, $b) = ^new Foo
> >
> > Would prefix ^ always return 'wanted' number of repetitions? Like a
> > smart C?
>
> This does bother me about the above proposed syntax/semantics.
> Hyperoperations take their "magnitude" from that of their operand(s).
> I would have expected the above example needed to be:
>
>my ($a, $b) = ^new (Foo,Foo);

How about:

$_ = new Doberman for my Dog ($spot, $rover) is rw;

Err, whatever.

Ashley Winters



Re: what's new continued

2002-07-07 Thread Damian Conway

Ashley Winters asked:

> > It *might* possibly work to hyper the constructor:
> >
> > my ($a, $b) = ^new Foo
> 
> Would prefix ^ always return 'wanted' number of repetitions? Like a
> smart C?


This does bother me about the above proposed syntax/semantics. Hyperoperations
take their "magnitude" from that of their operand(s).
I would have expected the above example needed to be:

 my ($a, $b) = ^new (Foo,Foo);

or maybe:

 my ($a, $b) = ^new Foo x 2;

Damian



Re: what's new continued

2002-07-04 Thread raptor





|Comments (otherwise you have things pretty much right):
]- that is good :")
|
|> Every subrotine or variable or method or object can have a "notes" (out of bound 
|data)
|out-of-band data
]- yep

|> we can even have hyper-assignment :
|> 
|> my ($a, $b) ^= new Foo;
|
|This is unlikely to do what you wanted. It creates a new Foo object and then
|assigns a reference to that one object to both $a and $b. It doesn't create two
|Foo objects. (But maybe one object referenced twice is what you wanted).

]- i've got it from here :

For historical reasons, the assignment in

 my ($a, $b) = new Foo;

will not distribute automatically over $a and $b. If you want that, use the ^= 
hyperassignment instead, maybe.


But probably i havent understood it !

|
|> Let's someone of the anti-perl camp tell me that this "upper-cap noise" makes the 
|code hard to read and I will smash him with a hammer in the head :") and leave him to 
|type "from here to tommorow loop after loop after loop after loop" :"). Gees those 
|perl designers with LW in the head are mad-scientists .
|
|Do you really need to say this?

]- no just kidding :")

|
|> 7.) Quantum superpositions ===
|> 
|> case2 - hyperoperator :
|> 
|> my $result = 0;
|> for ($a,$b,$c)  {
|>if ($x == $_) { $result =1; last}
|> }
|
|Not correct. The second case is the same as:
|
|   ($x == $a, $x == $b, $x == $c)
|
|which reduces in effect to:
|
|   $x == $c

]- i see now...  so if ',' works the Perl5 way, then all are ecaluated but the result 
]is the result of the last comparison, but in superposition if for some comparision we 
]have true the rest are not evaluated..

|> and all they (except CATCH) are in fact proprietes of the block
|
|So is CATCH.

]- i see, i havent read it well :

There is, however, no catch property to go with the CATCH block.


thanx






Re: what's new continued

2002-07-03 Thread Ariel Scolnicov

Ariel Scolnicov <[EMAIL PROTECTED]> writes:

[...]

> will apply to any method?  To any sub?  Can I call a sub 17 times by
> saying
> 
> (undef) x 17 = foo(1,2,3);

That should be

(undef) x 17 = ^foo(1,2,3);

of course.  Sorry.

[...]

-- 
Ariel Scolnicov|http://3w.compugen.co.il/~ariels
Compugen Ltd.  |[EMAIL PROTECTED]"Sometimes people write an
72 Pinhas Rosen St.|Tel: +972-3-7658117   accidental haiku.  Damn!
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555   It just happened!"




Re: what's new continued

2002-07-03 Thread Ariel Scolnicov

Larry Wall <[EMAIL PROTECTED]> writes:

> On Wed, 3 Jul 2002, Damian Conway wrote:
> : Date: Wed, 03 Jul 2002 19:33:33 -0400
> : From: Damian Conway <[EMAIL PROTECTED]>
> : To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> : Subject: Re: what's new continued
> : 
> : Comments (otherwise you have things pretty much right):
> 
> I didn't see the original here.
> 
> : > we can even have hyper-assignment :
> : > 
> : > my ($a, $b) ^= new Foo;
> : 
> : This is unlikely to do what you wanted. It creates a new Foo object and then
> : assigns a reference to that one object to both $a and $b. It doesn't create two
> : Foo objects. (But maybe one object referenced twice is what you wanted).
> 
> It *might* possibly work to hyper the constructor:
> 
> my ($a, $b) = ^new Foo

Given that, like in Perl 5, there's nothing sacred about the name of
the constructor (right??), does this mean that (nullary?) "hyping"
will apply to any method?  To any sub?  Can I call a sub 17 times by
saying

(undef) x 17 = foo(1,2,3);

?

> : > 7.) Quantum superpositions ===
> : 
> : >  if ($x == any($a, $b, $c) { ...  }
> 
> The wave function of QS has not yet collapsed in Perl 6.
> It's still in the same state(s) as the cat.

I believe you will find that it is impossible to copy a quantum wave
function.

-- 
Ariel Scolnicov|http://3w.compugen.co.il/~ariels
Compugen Ltd.  |[EMAIL PROTECTED]"Sometimes people write an
72 Pinhas Rosen St.|Tel: +972-3-7658117   accidental haiku.  Damn!
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555   It just happened!"




Re: what's new continued

2002-07-03 Thread Ashley Winters

On Wednesday 03 July 2002 06:39 pm, Larry Wall wrote:
> On Wed, 3 Jul 2002, Damian Conway wrote:
> : Date: Wed, 03 Jul 2002 19:33:33 -0400
> : From: Damian Conway <[EMAIL PROTECTED]>
> : To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> : Subject: Re: what's new continued
> :
> : Comments (otherwise you have things pretty much right):
>
> I didn't see the original here.
>
> : > we can even have hyper-assignment :
> : >
> : > my ($a, $b) ^= new Foo;
> :
> : This is unlikely to do what you wanted. It creates a new Foo object and
> : then assigns a reference to that one object to both $a and $b. It doesn't
> : create two Foo objects. (But maybe one object referenced twice is what
> : you wanted).
>
> It *might* possibly work to hyper the constructor:
>
> my ($a, $b) = ^new Foo

Would prefix ^ always return 'wanted' number of repetitions? Like a smart
C?

@x = qw(foo bar baz); @y = (one);
for @x, ^"unseen"; @y, ^"too high" -> $x; $y {
# foo, one
# bar, too high
# baz, too high
}

Ashley Winters



Re: what's new continued

2002-07-03 Thread Damian Conway

> : > we can even have hyper-assignment :
> : >
> : > my ($a, $b) ^= new Foo;
> :
> : This is unlikely to do what you wanted. It creates a new Foo object and then
> : assigns a reference to that one object to both $a and $b. It doesn't create two
> : Foo objects. (But maybe one object referenced twice is what you wanted).
> 
> It *might* possibly work to hyper the constructor:
> 
> my ($a, $b) = ^new Foo

How would this know how may times to hype? By the count of its list context?

And would that also work in dot notation:

my ($a, $b) = Foo.^new();

???

If so, will people be able to grok the subtle difference between C<.^> and C<^.>?



> : > 7.) Quantum superpositions ===
> :
> : >  if ($x == any($a, $b, $c) { ...  }
> 
> The wave function of QS has not yet collapsed in Perl 6.
> It's still in the same state(s) as the cat.



Damian



Re: what's new continued

2002-07-03 Thread Larry Wall

On Wed, 3 Jul 2002, Damian Conway wrote:
: Date: Wed, 03 Jul 2002 19:33:33 -0400
: From: Damian Conway <[EMAIL PROTECTED]>
: To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
: Subject: Re: what's new continued
: 
: Comments (otherwise you have things pretty much right):

I didn't see the original here.

: > we can even have hyper-assignment :
: > 
: > my ($a, $b) ^= new Foo;
: 
: This is unlikely to do what you wanted. It creates a new Foo object and then
: assigns a reference to that one object to both $a and $b. It doesn't create two
: Foo objects. (But maybe one object referenced twice is what you wanted).

It *might* possibly work to hyper the constructor:

my ($a, $b) = ^new Foo

: > 7.) Quantum superpositions ===
: 
: >  if ($x == any($a, $b, $c) { ...  }

The wave function of QS has not yet collapsed in Perl 6.
It's still in the same state(s) as the cat.

Larry




Re: what's new continued

2002-07-03 Thread Luke Palmer

> > case2 - hyperoperator :
> > 
> > my $result = 0;
> > for ($a,$b,$c)  {
> >if ($x == $_) { $result =1; last}
> > }
> 
> Not correct. The second case is the same as:
> 
>   ($x == $a, $x == $b, $x == $c)
> 
> which reduces in effect to:
> 
>   $x == $c

Hold on---something's awry here. I thought C comma was going away, and 
being replaced with an always-listifying comma.  So wouldn't it in effect 
reduce to

3

or.. that's just for arrays.  But I'm sure I read that there's no more C 
comma. 

Luke





Re: what's new continued

2002-07-03 Thread Damian Conway

Comments (otherwise you have things pretty much right):


> Every subrotine or variable or method or object can have a "notes" (out of bound 
>data)

out-of-band data


> we can even have hyper-assignment :
> 
> my ($a, $b) ^= new Foo;

This is unlikely to do what you wanted. It creates a new Foo object and then
assigns a reference to that one object to both $a and $b. It doesn't create two
Foo objects. (But maybe one object referenced twice is what you wanted).


> Let's someone of the anti-perl camp tell me that this "upper-cap noise" makes the 
>code hard to read and I will smash him with a hammer in the head :") and leave him to 
>type "from here to tommorow loop after loop after loop after loop" :"). Gees those 
>perl designers with LW in the head are mad-scientists .

Do you really need to say this?



> 7.) Quantum superpositions ===

>  if ($x == any($a, $b, $c) { ...  }
> 
>  if any of the variables equals $x then the code will be executed. Probably we will 
>be able to say :
> 
>  $x ^== ($a,$b,$c)
> 
>  too. The difference as I understand it in that particular case is [?? correct me if 
>i'm wrong ??]
 :
>  case1 - superposition :
> 
>  if ($x == $a || $x == $b || $x == $c) { ...  }

Correct.

> 
> case2 - hyperoperator :
> 
> my $result = 0;
> for ($a,$b,$c)  {
>if ($x == $_) { $result =1; last}
> }

Not correct. The second case is the same as:

($x == $a, $x == $b, $x == $c)

which reduces in effect to:

$x == $c


> while ($nextval < all(@thresholds) { ... }
> 
> This time all() binds the @threshold with && not with || as it was with any().

It's equivalent to:

while ($nextval < @thresholds[0] && $nextval < @thresholds[1] && ...) { ... }


> $max = any(@value) < all(@values);

That's:

$max = any(@values) >= all(@values);



> and all they (except CATCH) are in fact proprietes of the block

So is CATCH.


> [?? the apo4 uses undo instead of keep, 'm I right ??]

It uses both, because they have different effects.
undo(...) is only invoked if the block "fails",
keep(...) is only invoked if the block "succeeds".


> CATCH {
>   when Error::DB {};
>   when Error::XX {};
> }
> 
> is :
> 
> CATCH $! {
>   when $!.isa(Error::DB) {};
>   when $!.isa(Error::XX) {};
>   default die;#!! not sure
> }

No, it's equivalent to:

switch $! {
when .isa(Error::DB) {}
when .isa(Error::XX) {}
default { die; }
}



> try { ... }
> 
> is equivalent to:
> 
> try { ... CATCH { default { } } }

Except it also returns C.



> for @a; @b; @c -> $x { ... }
> 
> One at a time across all arrays sequentally i.e. @a[0],@a[1],...@b[0], @b[1], ..., 
>@c[0], @c[1], ... .

No. This one pulls one from each array in turn. i.e. @a[0], @b[0], @c[0], @a[1], 
@b[1], @c[1], @a[2], @b[2], @c[2],...


Damian