Re: what's new continued

2002-07-04 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-04 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: Ruby iterators and blocks (was: Perl 6 Summary)

2002-07-04 Thread Erik Bågfors

On Thu, 2002-07-04 at 11:19, Andy Wardley wrote:
 On Tue, Jul 02, 2002 at 03:20:35PM -0500, Dan Sugalski wrote:
  I'm pretty sure the iterators they build are just closures with named 
  arguments, and behave as any other closure would behave. 
 
 Not quite.  Ruby iterators expect a block.  This is very much like a closure
 except that block parameters are local to the scope in which the block is 
 defined, not lexically scoped within the block.
 
 Or in other words, any existing variable of the same name as a block parameter
 will be updated when the block is called.
 
 An example:
 
   n = 10
 
   def twice
 yield 1
 yield 2
   end
 
   twice { |n| puts Hello World #{n} }
 
   puts n is now #{n}
 
 The result of this is:
 
   Hello World 1
   Hello World 2
   n is now 2
 
 I personally believe this approach is flawed, especially considering the fact 
 that there is no way (that I know of) to force block parameters to be truly
 lexically scoped or temporary (i.e. 'my' or 'local' in Perlspeak).  Much too 
 easy to mangle existing variables like this.
 

Most people agree. In the future there will be a way of doing that. 
Matz himself has said so.

/Erik

-- 
Erik Bågfors   | [EMAIL PROTECTED]
Supporter of free software | GSM +46 733 279 273
fingerprint:  A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32



Re: Reflection...

2002-07-04 Thread Sean O'Rourke

On 4 Jul 2002 [EMAIL PROTECTED] wrote:

 Dan Sugalski [EMAIL PROTECTED] writes:

  At 8:32 AM +0100 7/3/02, [EMAIL PROTECTED] wrote:
  
  For true scariness, consider:
  
   $sub.current_continuation($new_continuation);
  
  Some days you really, really scare me Piers...

 Heh. Scary can be good.

  This would be an interesting thing to do, though. I don't see why it
  couldn't be done.

 You know, the more I think about it, I'm not sure it *is* a good
 idea. Once you have continuations in play you could have multiple
 'live' continuations associated with a single sub, so how would you
 decide *which* continuation was the important one.

All of them!  I don't see how the getter/setter mentioned above would
automatically lead down this path to madness, but it's madness I kind of
like.  If I'm not confused, the insane version lets you do threading:

$current_block.push_continuation($some_continuation)

or quantum shenanigans:

$current_block.push_continuation(any(*@some_ccs))

And the sane one allows dynamically-joined blocks:

$block1 = { ... }
$block2 = { ... }
$block1.continuation($block2.as_continuation);
$block1($something);# evaluate block1 then block2, then keep going

Sick.  Anyways, I think it seems like a more natural way to do things than
traditional call/cc.  $block.continuation reads as where do I go after
$block?; $block.continuation($foo) as after executing $block, proceed
on to $foo; (call/cc func) as call func with a single argument being
the 'rest of the current computation'.  This last definition makes Scheme
and Lisp people happy, but (at least for me) the first two are much easier
to grasp, as they refer to what's going on more concretely.

/s




Re: greedy/non-greedy regex assertions

2002-07-04 Thread Ashley Winters

On Thursday 04 July 2002 10:47 am, Larry Wall wrote:
 On Thu, 4 Jul 2002, Ashley Winters wrote:
 So I'd guess that we just don't talk about :-1, but rather say that

 *$min..$max

 is naturally greedy, and as with any quantifier you write

 *$min..$max?

 to get minimal matching.

I would expect /a*1..2?/ to mean /[a*1..2]?/ just looking at it. How can ? 
ever mean non-greedy unless it follows a metachar [*+?]?

 But sigh, it would fix so many novice bugs to make minimal matching
 the default...

I agree wholeheartedly. *sigh*

Ashley Winters




Re: Reflection...

2002-07-04 Thread dan

At 8:29 AM -0700 7/4/02, Sean O'Rourke wrote:
Sick.  Anyways, I think it seems like a more natural way to do things than
traditional call/cc.  $block.continuation reads as where do I go after
$block?; $block.continuation($foo) as after executing $block, proceed
on to $foo; (call/cc func) as call func with a single argument being
the 'rest of the current computation'.  This last definition makes Scheme
and Lisp people happy, but (at least for me) the first two are much easier
to grasp, as they refer to what's going on more concretely.

If you want really sick, consider that we are *not* limited to the 
standard call/cc functionality. Continuations can reasonably be taken 
at any statement boundary. (They don't work well if taken from within 
an expression. Or, if they do, it hurts my brain enough that I'd 
rather you didn't...) You also should be able to invoke them 
anywhere, including within expressions.

You're not obligated to pass the continuation for the call/cc into 
call/cc (you could pass another one in if you chose), nor, I suppose, 
are you obligated to not keep it around for later use.
-- 
 Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
   teddy bears get drunk



Re: greedy/non-greedy regex assertions

2002-07-04 Thread Ashley Winters

On Thursday 04 July 2002 11:07 am, Ashley Winters wrote:

 I would expect /a*1..2?/ to mean /[a*1..2]?/ just looking at it. How
 can ? ever mean non-greedy unless it follows a metachar [*+?]?

Perhaps I can respond to my own question. In /.+?/ . is an assertion, + is an 
assertion, and ? is a modifier. Therefore, it means /.1,Inf:m/ or 
something close, where :m is mnemonic for minimal.

Did apoc 5 ever say . means .?

Ashley Winters



Re: greedy/non-greedy regex assertions

2002-07-04 Thread Larry Wall

On Thu, 4 Jul 2002, Ashley Winters wrote:
: On Thursday 04 July 2002 10:47 am, Larry Wall wrote:
:  On Thu, 4 Jul 2002, Ashley Winters wrote:
:  So I'd guess that we just don't talk about :-1, but rather say that
: 
:  *$min..$max
: 
:  is naturally greedy, and as with any quantifier you write
: 
:  *$min..$max?
: 
:  to get minimal matching.
: 
: I would expect /a*1..2?/ to mean /[a*1..2]?/ just looking at it. How can ? 
: ever mean non-greedy unless it follows a metachar [*+?]?

Well, that's exactly how {1,2}? works in Perl 5, and {1,2} isn't a metacharacter.
It is, however, a quantifier.

In general, it makes no sense to put the quantifier ? after a zero-width
assertion.  It'd mean Check this assertion but I don't care if it matches.

:  But sigh, it would fix so many novice bugs to make minimal matching
:  the default...
: 
: I agree wholeheartedly. *sigh*

I wasn't seriously proposing it, of course, since it would instead
inspire a whole new set of novice bugs:

Gee, how come this:

my ($num) = /(\d*)/

always sets $num to zero?

We'll stick with greedy matching by default, and take our current
set of lumps...

Larry




Re: Ruby iterators and blocks (was: Perl 6 Summary)

2002-07-04 Thread Larry Wall

On 4 Jul 2002, Erik [ISO-8859-1] Bågfors wrote:
: On Thu, 2002-07-04 at 11:19, Andy Wardley wrote:
:  I personally believe this approach is flawed, especially considering the fact 
:  that there is no way (that I know of) to force block parameters to be truly
:  lexically scoped or temporary (i.e. 'my' or 'local' in Perlspeak).  Much too 
:  easy to mangle existing variables like this.
: 
: Most people agree. In the future there will be a way of doing that. 
: Matz himself has said so.

Indeed, Ruby is the main reason I decided to keep my explicit in Perl 6.  :-)

Larry