Re: Differential Subscripts

2008-08-10 Thread TSa (Thomas Sandlaß)
On Saturday, 9. August 2008 04:41:46 John M. Dlugosz wrote:
> Is this magic known to the parser at a low level, or is it possible to
> define your own postcircumfix operators that interact with the
> interpretation of the argument?

My interpretation is that there is a Whatever type that
most of the time behaves like Int. So to handle it, you
define postcircumfix:<[ ]>:(Whatever $slice) or so. The
interesting question is what plain * returns because that
is destined to mean the full slice. IMHO, this should be
written ^*, which if the array becomes known becomes
[EMAIL PROTECTED]


> Is it possible to write:
>   @i = (1, 3, *-1);
>   say @data[$i];
> and get the same meaning as
>   say @data[1, 3, *-1]?

I hope so. The type of the slice is Seq[Int,Int,Whatever].


Regards, TSa.
-- 
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


Re: Some details of function return captures

2008-08-10 Thread TSa (Thomas Sandlaß)
HaloO,

On Saturday, 9. August 2008 01:32:35 John M. Dlugosz wrote:
> TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote:
> > If such a ReturnCapture could also be
> > preliminary of some kind, then lvalue subs could be lazily resumed when
> > the rvalue comes in.
>
> Can you elaborate on that?  I don't follow.

The fundamental problem with lvalue methods is that some
of them want to have control *after* they returned
their value. One ugly way to achieve this is how it is
usually done in C++ or Java: the rvalue is a parameter
of the method. So instead of

$obj.foo(1,2) = 3; #1

one writes

$obj.foo(1,2,3); #2

which doesn't look like an lvalue method at all. And you can't
use it in rvalue context as the former:

my $x = $obj.foo(1,2); #3

Here the ReturnCapture collapses right away. But in #1 it could
be resumed with rvalue 3. That is the invocation of .foo(1,2)
resumes after the statement that produced the ReturnCapture.
In the assignable mutators thread I proposed to call that
statement 'yield'. To the function it behaves like the declaration
of a variable that receives the value that is assigned later.
To the outside it is the preliminary rvalue. If no assignment
takes place no resumption is made. The new thing here is that
one needs to write

my $x = |$obj.foo(1,2); #4

to keep the ReturnCapture, and call it later either explicitly

$x.resume(3);

or implicitly

$x = 3;


Hope that helps, TSa.
-- 
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


Allowing '-' in identifiers: what's the motivation?

2008-08-10 Thread John M. Dlugosz

E.g. see  :

sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
  return  rand(50);
  }
if (foo - bar != foo-bar) {
  print "Haha!\n";
}


Re: Allowing '-' in identifiers: what's the motivation?

2008-08-10 Thread Austin Hastings
At a minimum, there are more multi-word identifiers than there are 
statements involving subtraction. Further, '-' is basic, while all of 
[_A-Z] are not.


Ergo, a multi-word-identifier is easier to type than a 
multi_word_identifier or a multiWordIdentifier.


The older I get, the more I like Cobol, and now *ML, for getting this 
stuff right.


=Austin

John M. Dlugosz wrote:

E.g. see  :

sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
  return  rand(50);
  }
if (foo - bar != foo-bar) {
  print "Haha!\n";
}





Re: Some details of function return captures

2008-08-10 Thread John M. Dlugosz

TSa (Thomas Sandlaß) thomas-at-sandlass.de |Perl 6| wrote:

...
my $x = |$obj.foo(1,2); #4

to keep the ReturnCapture, and call it later either explicitly

$x.resume(3);

or implicitly

$x = 3;


Hope that helps, TSa.
  


Interesting idea, as an alternative to get/set methods like Microsoft 
languages.  Do you have a pointer to the thread, or collected notes I 
could read?


Is there anything in Perl 6 as it stands now that really uses 
continuations like this?


I don't like the default lvalue subs as the exist now because I might 
want to do more than assign to the value located with the access.  Even 
if that's fine now, how do I add an "clear_cache; tell_subscribers;" 
after the value is changed?  It means adding the ugly C++ form and then 
changing all existing uses. 

But, I realized that the ability to return a tied scalar as a proxy 
object gives us this.  You can specify an accessor that returns an 
object that has the getter/setter installed in the FETCH/STORE 
routines.  A class can be written for the purpose, that takes blocks 
(anonomous methods) in the constructor, and a macro gives reasonable 
syntactic sugar for writing separate get/set methods right by the attribute.


I'm not sure about returning things other than a scalar.

But the point is, since it _can_ be done in a module, I'm punting on 
that and not lobbying for it for 6.0 when there is so much else that 
needs doing.


--John



Re: Allowing '-' in identifiers: what's the motivation?

2008-08-10 Thread John M. Dlugosz

Austin Hastings Austin_Hastings-at-Yahoo.com |Perl 6| wrote:
At a minimum, there are more multi-word identifiers than there are 
statements involving subtraction. Further, '-' is basic, while all of 
[_A-Z] are not.


Ergo, a multi-word-identifier is easier to type than a 
multi_word_identifier or a multiWordIdentifier.


The older I get, the more I like Cobol, and now *ML, for getting this 
stuff right.


I do agree that it may be better for multi-word identifiers than camel 
case or underscores, as seen in many other languages that the great 
unwashed masses have never heard of.  I tried it in my writings the same 
day.


--John


Class attribute declaration question : our $!var

2008-08-10 Thread John M. Dlugosz

our $.var — class attribute, accessor, inheritable.
our $!var — class attribute, no accessor, inheritable.



If the second form has no accessor, how can it be inheritable?


class member declaration catalog

2008-08-10 Thread John M. Dlugosz
I just put together  as 
part of my analysis and documentation effort.  I'll link the "meanings" to more 
extensive treatments.


Did I miss any *possible* combination?

--John