Re: new sigil

2005-10-25 Thread Luke Palmer
On 10/24/05, TSa [EMAIL PROTECTED] wrote:
 Does this capturing of the type into ¢T also involve runtime
 code template expansion? That is, if sametype(Int,Int) didn't
 exist it would be compiled on the fly for a call sametype(3,2)?

I think that's up to the implementation.  From the language
perspective, no, it behaves as though it was compiled once.  But an
implementation is free to instantiate the routine for various types
for optimization.

 Which brings up the question if ¢T will be allowed in multi defs?

Good question.  I believe the ordering multi algorithm can be extended
to handle it, but I'll have to think about what it means.

  So it's a type position thing if it can be.  Good.  (I wonder if,
  since it's allowed in term position, we will come up with ambiguities)
 
  How about this:
 
  sub foo(c|T $x) {
  my sub util (c|T $in) {...}
  util($x)
  }
 
  Is that c|T in util() a new, free type variable, or am I asserting
  that the type of util()'s argument must be the same type as $x?

 I would guess there are two distinct ¢foo::T and ¢foo::util::T free
 type variables.

Hmm, yeah, that makes sense, but it can also be annoying.  For
instance, in Haskell, I wrote this:

closure :: (Ord a) = (a - [a]) - [a] - [a]
clsoure f init = closure' Set.empty init
where
closure' :: (Ord a) = Set a - [a] - [a]
closure' set [] = []
closure' set (x:xs) = ...

This gives me a type error on closure', because the inner a is
different from the outer a.  Incidentally, there is no signautre
that closure' can possibly have.  So I was forced to leave off the
signature and let the type inferencer do the work.  In this case it
would have been nice to have the variable carry over to inner clauses.

But letting that happen also has problems.  You can't freely move code
around, because you depend on the type variables that were bound in
outer scopes.  However, if the number of type topicalizers (as it
were) is small, then maybe that's okay.

 In the call of util($x) the type reference is handed
 or rebound down the call chain just like value refs. BTW, will there
 be a topic type ¢_, grammar type ¢/ and the exception type ¢! as well?

The topic type ¢_ is discussed in theory.pod.  I don't see much use
for the others (there is no @/ or @!, for instance).

 What operations are available for type variables? E.g. ¢foo = ¢bar could
 be the subtype relation. But what would ¢foo + ¢bar mean?

Nothing.

Perhaps ¢foo (+) ¢bar is a union type, but I don't think it should be.
 Again, see theory.pod for formalisms of the difference between things
that are in type variables and the types you declare in the program. 
Essentially the things that are in type variables are only
instantiable, concrete types, whereas the types you declare in the
program are more like interfaces.   There is no concept of a subtype
in the concrete world; only in the interface world.  But theory.pod
isn't gospel (yet ;-).

 Is ¢foo - ¢bar the dispatch distance?

Especially not since that concept doesn't exist anymore.

 Is the compiler obliged to separate type variables from value variables? Or 
 does

$foo = \¢bar;

 produce a type reference? How would that be dereferenced then? Is the type
 inferencer in the compiler automatically calculating a supertype bound
 for every expression? If yes, how is that accessable?

Hmm, don't know about that.  Exactly how first-class are type variables?

Luke


$_ defaulting for mutating ops

2005-10-25 Thread Juerd
I think it'd be great if +=, ~=, +=, ++, etc, could all assume $_ on
their LHS when there is no obvious operand.

This clashes with prefix:=, but that's nothing a space cannot fix.
Same for lvalue subs called x or xx (or X or XX).

my $subject = foo foo foo;
given ($subject) {
s/foo/bar/;  # bar foo foo
++;  # bar foo fop
x= 2;# bar foo fopbar foo fop
~= !;  # bar foo fopbar foo fop!
}

Especially bare ++ would be useful, I think.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: Perl 6 fears

2005-10-25 Thread Michele Dondi

On Mon, 24 Oct 2005, H.Merijn Brand wrote:


FEAR: Perl6 will not be able to fix the stigma of just a scripting
language or line noise


perl5 has never been just a scripting language


But sadly enough it is often _perceived_ as such. And also like line 
noise, as the person you're answering to correctly states: an opinion we 
all beg to differ, I suppose, but a widespread one indeed...



Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling in clpmisc,
  perl bug File::Basename and Perl's nature


txt vs OO [was: Re: Proposal to make class method non-inheritable]

2005-10-25 Thread Michele Dondi

On Fri, 14 Oct 2005, Stevan Little wrote:

I think Perl 6's OO system has the potential to be to OO programming what 
Perl 5, etc was to text processing. This, I believe, is in large part due to


Sorry for replying so late. Thought it seems appropriate to post this in 
this time of Perl 6 fears and rants threads...


Well, the point is that it is interesting to note that text processing 
is an _application area_, whereas OO programming is a programming 
language paradigm.


Despite the intro above, this is not meant to be a rant or to express a 
fear. But it is intended to raise a meditation.


After all, being known for text processing capabilities may be somewhat 
restictive and not faithful of Perl's (including Perl 5) full 
potentiality, but OO programming is somewhat immaterial either, the 
only relevance being the suitability for big projects management.



Michele
--
Ira Kane: If I was a giant nasty alien bird in a department store, where
would I be?
Harry Block: Lingerie.
Ira Kane: Not you, the bird.
Harry Block: Lingerie.
- Evolution, Ivan Reitman


Re: $_ defaulting for mutating ops

2005-10-25 Thread Rob Kinyon
On 10/25/05, Juerd [EMAIL PROTECTED] wrote:
 I think it'd be great if +=, ~=, +=, ++, etc, could all assume $_ on
 their LHS when there is no obvious operand.

 This clashes with prefix:=, but that's nothing a space cannot fix.
 Same for lvalue subs called x or xx (or X or XX).

 my $subject = foo foo foo;
 given ($subject) {
 s/foo/bar/;  # bar foo foo
 ++;  # bar foo fop
 x= 2;# bar foo fopbar foo fop
 ~= !;  # bar foo fopbar foo fop!
 }

 Especially bare ++ would be useful, I think.

Did you post this specifically to anti-address the fear that P6 will
be more line-noise-ish than P5? :-p

Rob


Re: Perl 6 fears

2005-10-25 Thread Juerd
Joshua Gatcomb skribis 2005-10-25  8:30 (-0400):
 IIRC, Andy has taken up the Perl6 PR hat. I think Juerd should like be
 working with Andy on this one. The rebuttals to these fears needs to be well
 thought out and convincing because from my personal experience they are
 prevalent.

I'll work with anyone, but I do believe in collaborative editing. That's
why I put it in pugs' svn, so that everyone can help.

If this list of fears is ever used for more official purposes (not my
original intent), like putting it online as an article, of course PR
people must be involved.

For now, if Andy wants to change anything, he is free to do so, like
everyone else. If he thinks I shouldn't continue without his approval,
he knows where to find me.

So far, most of my subprojects have been undiscussed before they
started. It has all worked out well. If anyone objects, please do let me
know. But if you want me to discuss things beforehand, people better be
reachable and responding, because I generally lose interest if I don't
get started within a few days. That kind of thing has been a problem
with other projects, and I love how Perl 6 development is so open and
free, focussed on fun and a common goal, rather than bureaucracy and
people wearing very specifically coloured hats :)


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: $_ defaulting for mutating ops

2005-10-25 Thread Juerd
Rob Kinyon skribis 2005-10-25  8:37 (-0400):
 Did you post this specifically to anti-address the fear that P6 will
 be more line-noise-ish than P5? :-p

No. Leaving out $_ is one of the important features in *reducing* line
noise. We're all very used to seeing it, but to most people it is just
two more non-alphanumeric characters.

Reducing line noise isn't my goal, though. I feel that the implicit
defaulting to $_ makes Perl a more natural and elegant language, and
would like this principle being extended to these operators.

For comparison, here is the same code snippet again. First with, and
then without explicit $_.

With:

given ($subject) - $_ {
$_ ~~ s/foo/bar/;
$_++;
$_ x= 2;
$_ ~= !;
}

Without:

given ($subject) {
s/foo/bar/;
++;
x= 2;
~= !;
}

I think the latter is more elegant, without reducing legability or
maintainability. I also think that the code is immediately obvious, even
to people coming from Perl 5, who never read this thread.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: $_ defaulting for mutating ops

2005-10-25 Thread Michele Dondi

On Tue, 25 Oct 2005, Rob Kinyon wrote:


On 10/25/05, Juerd [EMAIL PROTECTED] wrote:

I think it'd be great if +=, ~=, +=, ++, etc, could all assume $_ on
their LHS when there is no obvious operand.

[snip]

Especially bare ++ would be useful, I think.


Did you post this specifically to anti-address the fear that P6 will
be more line-noise-ish than P5? :-p


No, to address the fear that P6 won't be just as suitable for 
{obfuscation,golfing} as P5 is and that it would spoil those cultures.


Incidentally I think it'd be great too.


Michele
--
Free software, not just Linux, is a major problem for Microsoft.
It's a big mistake thinking they don't understand free software, or its mechanics. 
They understand it all too well, and they don't like it - not one little bit!

- Eddy Macnaghten


Re: txt vs OO [was: Re: Proposal to make class method non-inheritable]

2005-10-25 Thread Stevan Little


On Oct 25, 2005, at 6:31 AM, Michele Dondi wrote:

On Fri, 14 Oct 2005, Stevan Little wrote:
I think Perl 6's OO system has the potential to be to OO  
programming what Perl 5, etc was to text processing. This, I  
believe, is in large part due to


Sorry for replying so late. Thought it seems appropriate to post  
this in this time of Perl 6 fears and rants threads...


Well, the point is that it is interesting to note that text  
processing is an _application area_, whereas OO programming is a  
programming language paradigm.


Allow me to clarify.

Perl 5 (and below) are known by outsiders (non-perl users) as being a  
really good language for processing text. Ask any friend you know who  
has had little or no exposure to Perl and they will probably tell you  
this. Of course they will also tell you that it is all line noise,  
etc, etc etc. This is the most common perception of Perl by those  
people who have (for the most part) never encountered it.


I think that Perl 6 may become like that for OO. When people who have  
never used or encountered Perl 6 talk about it, they will say, I've  
never used it, but I hear it has lots of really cool OO features.  
Just as now they the same thing re: text-processing.


Sure, this means nothing to people who are actually using it, but  
this is mostly about outside perception. These kinds of things are  
sometimes what will bring people to the language initially, so they  
are not to be taken lightly.


Despite the intro above, this is not meant to be a rant or to  
express a fear. But it is intended to raise a meditation.


After all, being known for text processing capabilities may be  
somewhat restictive and not faithful of Perl's (including Perl 5)  
full potentiality,


Of course not, Perl is also used for CGI, but you can do that better  
with Java now (which is a real language cause it's compiled)


;)

People who are not familiar with a language tend to rely heavily on  
the common knowledge about that language. And also tend to hold  
tightly to the myths and pseudo-facts surrounding their own  
languages. The combination of these two things tends to lead to silly  
statements like the one above.


but OO programming is somewhat immaterial either, the only  
relevance being the suitability for big projects management.


The idea that OO is only relevant for big projects is just as silly  
as saying that Perl is only good for text processing.


Sure I would not use OO to write a small utility script, but the  
modules I access in the script would probably be written using OO.  
And those may be very small modules too, but their re-usability is  
greatly enhanced by various OO features (encapsulation, ability to  
compose-into or use within another class, etc etc etc). This kind of  
thing (IMHO) is why so many people are being drawn to Python and  
Ruby. Hopefully Perl 6 can draw them back.


Stevan









Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Michele Dondi

On Tue, 25 Oct 2005, Juerd wrote:


Reducing line noise isn't my goal, though. I feel that the implicit
defaulting to $_ makes Perl a more natural and elegant language, and
would like this principle being extended to these operators.


Indeed, both the implicit defaulting to $_ AND the availability of $_ 
itself. Which occasionally makes me desire even more pronouns. After all 
in a natural language like English we have 'it', 'them', 'we', etc... now 
it's obvious that


(i) we can't hope nor desire a full correspondence,
(ii) there _already_ are some analogues of _some_ of the above, but
 somewhat more limited in usefulness wrt $_.

Now, one that I've sometimes desired is a two level $_, i.e. a variable, 
say, $__ referring to the _second next_ enclosing lexical scope. I am 
aware that in this vein one may ask a third analogue and so on, but let's 
face it: $_ already covers 95% of cases, my hypothetical var would cover I 
guess a remaining 4.5% of cases, and who cares for the rest? E.g.:


for @vert {
  put_point $_, $__ for @horiz;
}

Note: I am aware that P6 will already provide other ways to do it, but 
this is not in contrast with Perl's TMTOWTDI-ness. I expect it to be 
useful enough in nested {map,grep}'s.



Michele
--
you look around what do you see?
I'll tell you what I see is a world belonging to me
- Pennywise, Living For Today.


Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Juerd
Michele Dondi skribis 2005-10-25 17:05 (+0200):
 Now, one that I've sometimes desired is a two level $_, i.e. a variable, 
 say, $__ referring to the _second next_ enclosing lexical scope. I am 
 aware that in this vein one may ask a third analogue and so on, but let's 
 face it: $_ already covers 95% of cases, my hypothetical var would cover I 
 guess a remaining 4.5% of cases, and who cares for the rest? E.g.:
 for @vert {
   put_point $_, $__ for @horiz;
 }

I find $__ confusing, and prefer $OUTER::_, which already exists.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Michele Dondi

On Tue, 25 Oct 2005, Juerd wrote:


Michele Dondi skribis 2005-10-25 17:05 (+0200):

Now, one that I've sometimes desired is a two level $_, i.e. a variable,
say, $__ referring to the _second next_ enclosing lexical scope. I am
aware that in this vein one may ask a third analogue and so on, but let's
face it: $_ already covers 95% of cases, my hypothetical var would cover I
guess a remaining 4.5% of cases, and who cares for the rest? E.g.:
for @vert {
  put_point $_, $__ for @horiz;
}


I find $__ confusing, and prefer $OUTER::_, which already exists.


Hmmm... maybe you're right that $__ is too huffmanized (and hence 
confusing) but $OUTER::_ is somewhat too few...



Michele
--

A question out of curiousity: who is this Green of Green's functions?
Is he the same person of Green's theorem? :)

Yes. He was also an early environmentalist; hence the current
phrases green this and green that...
- David C. Ullrich in sci.math, Re: Who is Green?


Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Mark Reed

On 2005-10-25 11:17 AM, Michele Dondi [EMAIL PROTECTED] wrote:
 I find $__ confusing, and prefer $OUTER::_, which already exists.
 
 Hmmm... maybe you're right that $__ is too huffmanized (and hence
 confusing) but $OUTER::_ is somewhat too few...

What's confusing about $__ is that it looks too much like $_.  In my font,
for instance, there's no gap - it's just a longer underline, which is far
too subtle a difference...





Re: txt vs OO [was: Re: Proposal to make class method non-inheritable]

2005-10-25 Thread Michele Dondi

On Tue, 25 Oct 2005, Stevan Little wrote:

 Well, the point is that it is interesting to note that text processing 
 is an _application area_, whereas OO programming is a programming 
 language paradigm.


Allow me to clarify.

Perl 5 (and below) are known by outsiders (non-perl users) as being a really 
good language for processing text. Ask any friend you know who has had little 
or no exposure to Perl and they will probably tell you this. Of course they 
will also tell you that it is all line noise, etc, etc etc. This is the most 
common perception of Perl by those people who have (for the most part) never 
encountered it.


ack!

I think that Perl 6 may become like that for OO. When people who have never 
used or encountered Perl 6 talk about it, they will say, I've never used it, 
but I hear it has lots of really cool OO features. Just as now they the same 
thing re: text-processing.


I see your point. And I admit I slightly misunderstood you. In any case 
people who don't know Perl and think it's great for text processing may be 
eventually become interested in it if they will have to do... ehm... text 
processing.


But even if Perl will gain a name for it's cool OO features, will it 
become an actual interest for someone if he/she has to do... OO stuff?!? 
The basic idea being that one is attracted by a language or another if its 
features are well suited for some specific application he/she has in mind. 
Not for its features as an abstract thing.


Also, Perl6 OO capabilities are already above the top of my head. But 
maybe that's just me. Whatever, I guess that the {casual,average} 
programmer may be scared by its richness and complexity.


 After all, being known for text processing capabilities may be somewhat 
 restictive and not faithful of Perl's (including Perl 5) full 
 potentiality,


Of course not, Perl is also used for CGI, but you can do that better with 
Java now (which is a real language cause it's compiled)


Of Perl is IMHO even _too_ known for CGI.

 but OO programming is somewhat immaterial either, the only relevance 
 being the suitability for big projects management.


The idea that OO is only relevant for big projects is just as silly as saying 
that Perl is only good for text processing.


ack. I was oversimplifying.

Sure I would not use OO to write a small utility script, but the modules I 
access in the script would probably be written using OO. And those may be 
very small modules too, but their re-usability is greatly enhanced by various 
OO features (encapsulation, ability to compose-into or use within another 
class, etc etc etc). This kind of thing (IMHO) is why so many people are 
being drawn to Python and Ruby. Hopefully Perl 6 can draw them back.


Also, some methods will be very handy even for non-patently-OO blocks, 
e.g. the .pos() one which will replace the somewhat ad hoc pos() function 
or the .subst() one (or whatever it is called, I can't remember exactly) 
which hopefully will get rid of the why doesn't s/// work inside a map() 
question...



Michele
--
Have you ever stopped to consider that what is crashing
your Perl is sitting between the keyboard and chair?
- Sherm Pendley in clpmisc, Re: Perl IDE (edited)


Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Juerd
Michele Dondi skribis 2005-10-25 17:17 (+0200):
 Hmmm... maybe you're right that $__ is too huffmanized (and hence 
 confusing) but $OUTER::_ is somewhat too few...

for (1..9) - $n {  # ought to be more than enough
eval qq[
macro prefix:\$_$n { \${ OUTER:: x $n }_ }
];
}

And then you can use $_1 .. $_9. I think $_1 is much clearer than $__,
but I think neither is needed in the standard language.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Michele Dondi

On Tue, 25 Oct 2005, Juerd wrote:


   for (1..9) - $n {  # ought to be more than enough
   eval qq[
   macro prefix:\$_$n { \${ OUTER:: x $n }_ }
   ];
   }

And then you can use $_1 .. $_9. I think $_1 is much clearer than $__,
but I think neither is needed in the standard language.


Can I beg to differ any more? (Implicit answer: no, I can't!)


Michele
--
The trouble with engineers is that given the problem of knocking down
a stack of 100 bricks, they will start at the top, and work all
day removing them one at a time, while the mathematician will, after
a momemt's thought, remove the bottom brick and be done with it.
The trouble part, is having to brook the noise of the engineer
boasting about how much harder he worked while one is trying to
think about the next problem.
- Bart Goddard in sci.math


Re: $_ defaulting for mutating ops

2005-10-25 Thread Sebastian
 I think it'd be great if +=, ~=, +=, ++, etc, could all assume $_ on
 their LHS when there is no obvious operand.

It'd be nice to have these, but is it something that can wait? I
wouldn't mind if more effort was spent on other pieces if this can be
easily done in the future

- sebastian


Re: $_ defaulting for mutating ops

2005-10-25 Thread Juerd
Sebastian skribis 2005-10-25  9:17 (-0700):
  I think it'd be great if +=, ~=, +=, ++, etc, could all assume $_ on
  their LHS when there is no obvious operand.
 It'd be nice to have these, but is it something that can wait? I
 wouldn't mind if more effort was spent on other pieces if this can be
 easily done in the future

It can wait, in theory, but implementing this should be trivial for the
people doing implementation.

One problem with waiting until after the first release is that there
will very quickly be code that works with 6.0.1, but not with 6.0.0, if 
what you're waiting for is a small thing to implement...

Things that can wait are usually very non-trivial, and have little
impact on the rest of the language.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: new sigil

2005-10-25 Thread Larry Wall
On Sat, Oct 22, 2005 at 06:00:38AM -0400, Damian Conway wrote:
: Autrijus wrote:
: 
: Indeed.  Somehow I think this makes some sense:
: 
: sub Bool eqv (|T $x, |T $y) { ... }
: 
: Except that it prevents anyone from ever writing:
: 
: multi sub circumfix:| | (Num $x) { return abs $x }
: multi sub circumfix:| | (Vec $x) { return $x.mag }
: 
: which many mathematically inclined folks might find annoying.
: 
: (It also precludes intriguing possibilities like:
: 
: multi sub circumfix:«| » ($q) { return Quantum::State.new(val = $q) 
: }
: 
: which I personally would find irritating. ;-)

I considered | last week, but decided it was better to hold unary | in
reserve, especially since it's likely to be confusing with junctions.
And if we use | for type set notation, then unary | would preclude
the ability to stack types, and I've been treating an utterance like

my Mammal ¢T $fido where Bark :($a,$b,$c -- Wag)

as having at least five implicitly ANDed type specifications:

must do Mammal
must do Class
must do Scalar
must do Bark
must do Wag

plus there must be three components that are Scalar, plus whatever
extra type constraints Wag puts onto those three components.  Having
Mammal |T be ambiguous with Mammal|T would be bad, at least visually.

Anyway, having mulled over all this while off in Amsterdam and
Budapest, my current thinking is that the ascii shortcut for ¢T is
simply class T, so you could write any of:

sub Bool eqv (¢T $x, T $y)
sub Bool eqv (class ¢T $x, T $y)
sub Bool eqv (Any ¢T $x, T $y)
sub Bool eqv (Any class T $x, T $y)

and mean the same thing.

Basically, ¢T is a close analog of t, which is the variableish form
for sub t.  When used in a declaration, both of them introduce a
bare name as an alias into whatever scope the declaration is inserting
symbols, albeit with different syntactic slots.  So just as

my t := { ... }

introduces the possibility of

t 1,2,3

so also a

my ¢T := sometype();

introduces the possibility of

my T $x;

Use as an rvalue can be either T or ¢T without declaring a new type.
We're probably converging on a general rule that two or more
declarations of the same variable in the same scope refer to the
same entity:

my $x = 1;  # outer $x;
{
$x = 2; # bound to OUTER::$x
if my $x = foo() {...}  # new $x declared here
if my $x = bar() {...}  # same $x, my is optional
baz();  # baz sees single inner CALLER::$x.
}

So too these would mean the same thing:

sub Bool eqv (¢T $x, T $y) { my T $z; }
sub Bool eqv (¢T $x, ¢T $y) { my ¢T $z; }

Only the first declarative ¢ actually installs a new symbol T.
An inner scope would of course establish its own type space, but
the formal parameters to a block count as part of the block, which
is why the second form above applies the existing T to $z rather
than capturing the type of $z.  But it's a bit like writing foo()
when you could just say foo() instead.

Larry


Re: Avoid the Yen Sign [Was: Re: new sigil]

2005-10-25 Thread Larry Wall
On Sun, Oct 23, 2005 at 10:55:34PM +0900, Dan Kogai wrote:
: To make the matter worse, there are not just one yen sign in  
: Unicode. Take a look at this.
: 
: ¥ U+00A5 YEN SIGN
: ¥ U+FFE5 FULLWIDTH YEN SIGN
: 
: Tough they look and groks the same to human, computers handle them  
: differently.  This happened when Unicode Consortium decided to make  
: BMP round-trippable against legacy encodings.  They were distinct in  
: JIS standards, so happened Unicode.
: 
: Maybe we should avoid other symbols like this for sigils -- those not  
: in ASCII that have 'fullwidth' variations.  q($) and q(\) are okay  
: (or too late) because they are already in ASCII.  q(¥) should be  
: avoided because you can hardly tell the difference from q(¥) in the  
: display.
: 
: But this will also outlaw the cent sign.  I have attached a list of  
: those affected.  As you see, most are with ASCII equivalents but some  
: are not.

We'd have to outlaw A..Z as well.  :-)

I think a better plan might just be to say that we'll treat any fullwidth
character as equivalent to its narrow companion, at least when used as
an operator.  Canonicalizing identifiers may be another matter though.

On the other hand, certain of the double-width characters are likely to
be confused with two singles, such as 

=   FF1DFULLWIDTH EQUALS SIGN
_   FF3FFULLWIDTH LOW LINE

so maybe they should be equivalent to == and __, or outlawed.

And one could (un)reasonably argue that

~   FF5EFULLWIDTH TILDE

ought to mean ~~ rather than ~.  But in general we need to go slow
on such decisions.  For now just sticking our toe into Latin-1
is enough, as long as we're looking ahead for visual pitfalls.

As for the ¥ pitfall, so far we've intentionally been careful to use
it only where an operator is expected, whereas \ is legal only where a
term is expected.  So at least for Perl code, we can translate legacy
¥ to different codepoints.  (Whether the Japanese font distinguishes
them is another issue, of course.  I have a Unicode font on my
machine that prints backslash as ¥, which I find slightly irritating,
but doubtless will be par for the course in Japan for the foreseeable
future.  Maybe that's a good reason to allow the doublewith backslash
as an alias for normal backslash.  Maybe not.)

Anyway, I think people will be able to distinguish visually between
A ¥ B and ¥X as long as we keep the operator/term distinction.

Larry


Re: Avoid the Yen Sign [Was: Re: new sigil]

2005-10-25 Thread Larry Wall
: On 10/23/05, Autrijus Tang [EMAIL PROTECTED] wrote:
:  In addition to your handy table, the  and  french quotes, which are used
:  quite heavily in Perl 6 for both bracketing and hyper operators, also have
:  full width equivalents:
: 
:  300A;LEFT DOUBLE ANGLE BRACKET;Ps;0;ON;Y;OPENING DOUBLE ANGLE 
BRACKET
:  300B;RIGHT DOUBLE ANGLE BRACKET;Pe;0;ON;Y;CLOSING DOUBLE ANGLE 
BRACKET
: 
:  Half width: «»
:  Full width: 《》

I think we actually speculated about that identity in the Apocalypse.

:  One way to approach it is to make Perl 6 accept both full- and
:  half-width variants.
: 
:  Another way would be to use ASCII fallbacks exclusively in real programs, 
and
:  reserve unicode variants for pretty-printing, the same way that PLT Scheme 
and
:  Haskell recognizes λ in literatures, but actually write lambda and
:  \ respectively
:  in everyday coding.

I think we should enable both approaches.  Restricting Unicode characters
to literature is wrong, but so is forcing Unicode on someone prematurely.

On Sun, Oct 23, 2005 at 07:07:33PM -0400, Rob Kinyon wrote:
: Isn't this starting to be the question of why we have the Unicode
: operators instead of just functions? Would it be possible to have a
: function be infix?

At which precedence level?

Larry


Re: Perl 6 fears

2005-10-25 Thread Luke Palmer
On 10/24/05, H.Merijn Brand [EMAIL PROTECTED] wrote:
 On Mon, 24 Oct 2005 11:49:51 -0400, Joshua Gatcomb [EMAIL PROTECTED]
 wrote:
  FEAR: Perl6 internals will be just as inaccessable as p5

 paradox. Many people don't find perl5 inaccessible at all

Who?  Do you know anybody who hacks the regex engine?

  FEAR: Perl6 will not be able to fix the stigma of just a scripting
  language or line noise

 perl5 has never been just a scripting language

Yeah, but he's talking about the cultural stigma, which is definitely
present.  However, given the increasing number of high-level design
constructus, I think that this fear will never realize itself.  The
only way it could is from the name Perl, and once anybody uses it,
it will go away.

 My only current fear is that I won't live long enough to be able to use and
 understand the full richness of what perl6 is going to offer me.

 (Oh, and that perl6 will never be able to upgrade my scripts that use
 'format', but I'm aware of the plan to make that `obsolete' as in: the
 perl526 translator will dump core on those)

I wonder how hard it would be to actually convert perl 5 formats to
Perl6::Form.  Having never used the former myself, I wouldn't really
know the order of magnitude of this problem.

Luke


Re: new sigil

2005-10-25 Thread Rob Kinyon
 Basically, ¢T is a close analog of t, which is the variableish form
 for sub t.  When used in a declaration, both of them introduce a
 bare name as an alias into whatever scope the declaration is inserting
 symbols, albeit with different syntactic slots.  So just as

 my t := { ... }

 introduces the possibility of

 t 1,2,3

 so also a

 my ¢T := sometype();

 introduces the possibility of

 my T $x;

I'm assuming that when you allow

my ¢T := sometype();

you're also allowing

my class T := sometype();

So, what happens when stupid me names a class class through
symbol-table craziness?

Rob


Re: Perl 6 fears

2005-10-25 Thread Rob Kinyon
On 10/25/05, Luke Palmer [EMAIL PROTECTED] wrote:
 On 10/24/05, H.Merijn Brand [EMAIL PROTECTED] wrote:
  On Mon, 24 Oct 2005 11:49:51 -0400, Joshua Gatcomb [EMAIL PROTECTED]
  wrote:
   FEAR: Perl6 internals will be just as inaccessable as p5
 
  paradox. Many people don't find perl5 inaccessible at all

 Who?  Do you know anybody who hacks the regex engine?

japhy. Though, granted, he's on a whole new level of insanity.

Rob


Re: Perl 6 fears

2005-10-25 Thread Nicholas Clark
On Tue, Oct 25, 2005 at 11:57:10AM -0600, Luke Palmer wrote:
 On 10/24/05, H.Merijn Brand [EMAIL PROTECTED] wrote:
  On Mon, 24 Oct 2005 11:49:51 -0400, Joshua Gatcomb [EMAIL PROTECTED]
  wrote:
   FEAR: Perl6 internals will be just as inaccessable as p5
 
  paradox. Many people don't find perl5 inaccessible at all
 
 Who?  Do you know anybody who hacks the regex engine?

It happens that Merijn does, partly as a side effect of being an active Perl
5 committer. But assuming that you're questioning his use of many, then
I agree with you. Few people find perl5 accessible. Mostly as a side effect
of banging their heads at it until it starts to change from inaccessible to
accessible.

And inaccessibility is something that both perl6 and parrot should actively
strive to avoid. Having looked at src/hash.c today, I fear that currently
parrot is showing signs of failing in this.

 I wonder how hard it would be to actually convert perl 5 formats to
 Perl6::Form.  Having never used the former myself, I wouldn't really
 know the order of magnitude of this problem.

It's probably easier to implement strict perl5 formats as a compatibility
module, using the exiting Perl 5 source and parrot's NCI.

Nicholas Clark


Re: new sigil

2005-10-25 Thread Luke Palmer
On 10/25/05, Larry Wall [EMAIL PROTECTED] wrote:
 We're probably converging on a general rule that two or more
 declarations of the same variable in the same scope refer to the
 same entity:

 my $x = 1;  # outer $x;
 {
 $x = 2; # bound to OUTER::$x
 if my $x = foo() {...}  # new $x declared here
 if my $x = bar() {...}  # same $x, my is optional
 baz();  # baz sees single inner CALLER::$x.
 }

...

...

Cool!

 So too these would mean the same thing:

 sub Bool eqv (¢T $x, T $y) { my T $z; }
 sub Bool eqv (¢T $x, ¢T $y) { my ¢T $z; }

I like that symmetry between foo and ¢foo.  So to get the behavior
that an outer type variable applies to an inner sub, could I do this:

# a complicated identity function :-)
sub foo (¢T $x -- ¢T) {
my sub bar (T $z -- T) {
$z;
}
bar $x;
}

Because omitting the ¢ would not bind T.  Whereas if I wrote:

sub foo (¢T $x -- ¢T) {
my sub bar (¢T $z -- T) {
$z;
}
bar $x;
}

It would be a totally new variable in both spots in the inner sub, and
if I wrote:

sub foo (¢T $x -- ¢T) {
my sub bar (T $z -- ¢T) {
$z;
}
bar $x;
}

It would be equivalent to:

sub foo (¢T $x -- ¢T) {
my sub bar (T $z -- ¢U) {
$z;
}
bar $z;
}

(Thus causing a signature too general type error)

Right?  Totally off?

Luke


Re: new sigil

2005-10-25 Thread Larry Wall
On Tue, Oct 25, 2005 at 01:57:52PM -0400, Rob Kinyon wrote:
: I'm assuming that when you allow
: 
: my ¢T := sometype();
: 
: you're also allowing
: 
: my class T := sometype();

Yes, that's the idea.

: So, what happens when stupid me names a class class through
: symbol-table craziness?

How much class could a class class class if a class class could class class?

What happens is either that you have to say class class or ¢class
or you redefine the class keyword to something else like frobnitz.
I think class and sub are keywords in the, er, class of things
that trump mere symbol table entries.  Either that, or class is merely
the name of the metaclass, and you'll get a class collision when
you try to redefine it.  But I expect class is really a declarator
of the same status as sub, at least syntactically.

Larry


Re: new sigil

2005-10-25 Thread Jonathan Scott Duff
On Tue, Oct 25, 2005 at 12:18:41PM -0600, Luke Palmer wrote:
 I like that symmetry between foo and ¢foo.  So to get the behavior
 that an outer type variable applies to an inner sub, could I do this:
 
 # a complicated identity function :-)
 sub foo (¢T $x -- ¢T) {
 my sub bar (T $z -- T) {
 $z;
 }
 bar $x;
 }
 
 Because omitting the ¢ would not bind T.  

You can even do 

 sub foo (¢T $x -- T) {
 my sub bar (T $z -- T) {
$z;
}
bar $x;
}

I do believe.

 Whereas if I wrote:
 
 sub foo (¢T $x -- ¢T) {
 my sub bar (¢T $z -- T) {
 $z;
 }
 bar $x;
 }

It would be semantically the same as above. (just like Cmy $x; my $x
would only declare one C$x, so too C¢T $x ... ¢T $y should only
bind one type to T (or ¢T) for the duration of the scope.

 It would be a totally new variable in both spots in the inner sub, and
 if I wrote:

 sub foo (¢T $x -- ¢T) {
 my sub bar (T $z -- ¢T) {
 $z;
 }
 bar $x;
 }

 It would be equivalent to:

 sub foo (¢T $x -- ¢T) {
 my sub bar (T $z -- ¢U) {
 $z;
 }
 bar $x;
 }

I don't think so. In the first example all the T (or ¢T) are the same
type after the first ¢T (where the type is bound). In the second one
you'd get two separate types ¢T and ¢U. But ¢U would probably get bound
to the same type as ¢T as that's the type of thing that it returns
(assuming perl can figure that out).

That's if I understand Larry correctly.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]


Re: new sigil

2005-10-25 Thread Benjamin Smith
On Tue, Oct 25, 2005 at 02:02:58PM -0500, Jonathan Scott Duff wrote:
 On Tue, Oct 25, 2005 at 12:18:41PM -0600, Luke Palmer wrote:

snip examples from luqui of type variables being used multiple times
with and without sigils

 I don't think so. In the first example all the T (or ¢T) are the same
 type after the first ¢T (where the type is bound). In the second one
 you'd get two separate types ¢T and ¢U. But ¢U would probably get bound
 to the same type as ¢T as that's the type of thing that it returns
 (assuming perl can figure that out).

We have (or have had?) parameterised classes where you can specify
parameters to the class enclosed in [].

eg. class Foo[...] { ... }

So couldn't the same be used for functions?  This way you wouldn't need
a special sigil for classes declared in such a way.

sub foo[Bar] (Bar $tab) { ... }

Since perl6 isn't really a static language, I don't think you need to be
allowed to have non-type variables in the [] (dependent-typing, or where
you can use primitive types like int in template parameters in C++),
since being parameters in [] means only that they're types, and not that
they are always bound at compile time.

(apologies for breaking the unicode)

-- 
Benjamin Smith [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
Christ's College - Mathematics Part 1B
IRC: integral on irc.perl.org, and irc.freenode.net (channel: #perl)


Re: Pronouns [Re: $_ defaulting for mutating ops]

2005-10-25 Thread Larry Wall
On Tue, Oct 25, 2005 at 05:26:32PM +0200, Juerd wrote:
: Michele Dondi skribis 2005-10-25 17:17 (+0200):
:  Hmmm... maybe you're right that $__ is too huffmanized (and hence 
:  confusing) but $OUTER::_ is somewhat too few...
: 
: for (1..9) - $n {  # ought to be more than enough
: eval qq[
: macro prefix:\$_$n { \${ OUTER:: x $n }_ }
: ];
: }

That can't work as is.  A macro's syntactic effect is always limited to
a particular lexical scope, which is by default the lexical scope
of the declaration.  You'll need to find some way of installing it
into the currently compiling lexical scope, which is going to resemble
something more like:


BEGIN {
for (1..9) - $n {  # ought to be more than enough
COMPILING::{term:\$_$n} := macro { \${ OUTER:: x $n }_ };
}
}

Also, $_ has to be a term, not a prefix, or the next thing will
be expected to be a term rather than an operator.  But probably
it shouldn't be a macro anyway, since you could just alias $_1 to
$OUTER::_ etc. directly:

BEGIN {
for (1..9) - $n {  # ought to be more than enough
COMPILING::{\$_$n} := COMPILING::(OUTER:: x $n)::$_;
}
}

maybe with something to catch the case of too many OUTERs.

Larry


Re: S04 default { } bug?

2005-10-25 Thread Larry Wall
On Mon, Oct 24, 2005 at 07:39:23AM +0300, Ilmari Vacklin wrote:
: Hi,
: 
: S04 says thus:
: 
: The default case:
: 
: default {...}
: 
: is exactly equivalent to
: 
: when true {...}
: 
: However, that parses to:
: 
: if $_ ~~ bool::true { ...; leave }
: 
: Which is not executed if $_ is false, unless ~~ bool::true does
: something special.

It did do something special at the time the Apocalypse was written,
but it was probably a bad idea.  Smart match was going to recognize
obviously boolean expressions and just ignore the other argument.
The problem is that it's not always obvious what's obvious.

Larry


Re: Ways to add behavior

2005-10-25 Thread Larry Wall
On Mon, Oct 24, 2005 at 06:33:20AM -0700, Ashley Winters wrote:
: # behavior through prototype -- guessing realistic syntax
: Base.meta.add_method(
: do_it = method ($arg) {
: say doing $arg!;
: });
: 
: 
: # or, just add it to a single instance
: $x.meta.add_method(
: do_it = method ($arg) {
: say doing $arg!;
: });

I don't have a comment on your actual question, but I'd like to use
this opportunity to point out the symmetry of Base and $x at this
point, and the fact that .meta can't simply call .add_method in the
metaclass, or it would lose track of the original invocant, which is
needed to convey both class and instance information.  I'm not sure
it's even possible to say

$m = $x.meta;
$m.addmethod($arg);

The only way that can work is if $x.meta returns a shadow class that
is prebound only to $x.  (Though that might explain how .addmethod
knows it's only adding a method to the object.)

In the absence of that, what's going on seems more like

$x.META::addmethod($arg);

where META:: is smart enough to dispatch to the proper metaclass without
throwing away the invocant, and then the metaclass decides what to do
based on the instancehood of $x.

Larry


Re: Zip more than two arrays?

2005-10-25 Thread Larry Wall
On Fri, Oct 21, 2005 at 04:04:25PM -0600, Luke Palmer wrote:
: However, if I get my wish of having zip return tuples, then it can be
: left-associative.  But since it interleaves instead, making it left-
: or right-associative gives strange, incorrect results.

I expect zip ought to bundle up into tuples of some sort.  But then
maybe zip is not what we want for typical loops.  I'm thinking that
for wants to be a little more incestuous with - anyway, so that
the optionality of the - arguments can tell for how to deal with
short lists.  And now that we have general multidimensional slices,
it'd be nice if for were one of the operators that is aware of that.
Then you might be able to say things like:

for (@foo; 1...) - $val, $i {...}

for @foo == 1... - $val, $i {...}

1... ==
for @foo - $val, $i {...}

1... == ###v
@foo == #v v
for () - $val, $i {...}

all of which should in theory be equivalent, and none of which use zip.
(With a bit of handwaving about how == binds to the list before
a final - block.)

With a clever enough parser, we even get back to the A4 formulation of

for @foo; 1... - $val, $i {...}

But that's relying on the notion that a statement can function as a
funny kind of bracketing device that can shield that semicolon from
thinking it's supposed to terminate the statement.  That's probably
not too far off from what it does now when it knows it wants a final
block, so that a bare block where an operator is expected pops back
up to the statement level.

I know that, with tuple matching signatures, zip can be made to work
even as a tuple constructor, but it seems like a waste to constuct
tuples only to throw them away immediately.  And if we're going to
build surreal lists into the language, we should probably use them.

Larry


Re: Ways to add behavior

2005-10-25 Thread Stevan Little

Larry,

On Oct 25, 2005, at 4:37 PM, Larry Wall wrote:

On Mon, Oct 24, 2005 at 06:33:20AM -0700, Ashley Winters wrote:
: # behavior through prototype -- guessing realistic syntax
: Base.meta.add_method(
: do_it = method ($arg) {
: say doing $arg!;
: });
:
:
: # or, just add it to a single instance
: $x.meta.add_method(
: do_it = method ($arg) {
: say doing $arg!;
: });

I don't have a comment on your actual question, but I'd like to use
this opportunity to point out the symmetry of Base and $x at this
point, and the fact that .meta can't simply call .add_method in the
metaclass, or it would lose track of the original invocant, which is
needed to convey both class and instance information.  I'm not sure
it's even possible to say

$m = $x.meta;
$m.addmethod($arg);

The only way that can work is if $x.meta returns a shadow class that
is prebound only to $x.  (Though that might explain how .addmethod
knows it's only adding a method to the object.)


This is actually the principe behind the Ruby style singleton methods  
(the shadow class), it basically creates an anon-class which inherits  
from $x's original class, then it rebinds/blesses $x into the anon- 
class. It is very simple really :)


As for if this is/should be accessible through .meta, i am not sure  
that is a good idea. The reason being is that .meta brings with it  
the idea of metaclasses, which then relates to classes, and so now  
the user is thinking they are accessing the metaclass of the class of  
which $x is an instance.


I would suggest instead that we have a method, which is found in  
Object which allows instances to add methods to themselves (and only  
themselves). In Ruby this is called 'add_singleton_method' or  
something like that. I use that same name in the metamodel prototype  
too.



In the absence of that, what's going on seems more like

$x.META::addmethod($arg);

where META:: is smart enough to dispatch to the proper metaclass  
without

throwing away the invocant, and then the metaclass decides what to do
based on the instancehood of $x.


I am not sure I like this for 2 reasons.

1) META:: smells like ::SUPER, and that feels like re-dispatching to  
me, which is not really what we need to be doing.


2) there is not need to send this back to the metaclass level. The  
whole thing could be accomplished as an instance method of Object.  
Here is how it could be done.


class ShadowClass does Class {}

class Object is reopened {
method add_singleton_method (Str $label, Method $method) {
if ($?SELF.class.class != ShadowClass) {
my $shadow = ShadowClass.new();
$shadow.meta.superclasses([ $shadow ]);
$?SELF.class = $shadow;
}
$?SELF.class.meta.add_method($label, $method);
}
}

Stevan





Re: new sigil

2005-10-25 Thread Larry Wall
On Thu, Oct 20, 2005 at 11:18:14AM -0600, Eric wrote:
: Actualy i think ^ might be my favorite so far.
: 
: sub sametype (^T $x, ^T $y) {...}

I thought that, too, until I realized it wouldn't work as an rvalue:

^T.count# 1's complement of number of T instances

On top of which, if it did work, it should be a placeholder variable,
not something you see in a signature.

Larry


Re: new sigil

2005-10-25 Thread Larry Wall
On Thu, Oct 20, 2005 at 09:59:49AM -0600, Luke Palmer wrote:
: How about this:
: 
: sub foo(c|T $x) {
: my sub util (c|T $in) {...}
: util($x)
: }
: 
: Is that c|T in util() a new, free type variable, or am I asserting
: that the type of util()'s argument must be the same type as $x?

It's a new T according to the current thinking.  Just use T if you
want the same one.  (But that does force util to be recloned on every
entry to foo, I expect.)

Larry


Re: new sigil

2005-10-25 Thread Larry Wall
On Tue, Oct 25, 2005 at 11:44:35PM +0200, Juerd wrote:
: Larry Wall skribis 2005-10-25 14:35 (-0700):
:  On Thu, Oct 20, 2005 at 11:18:14AM -0600, Eric wrote:
:  : Actualy i think ^ might be my favorite so far.
:  : sub sametype (^T $x, ^T $y) {...}
:  I thought that, too, until I realized it wouldn't work as an rvalue:
:  ^T.count# 1's complement of number of T instances
: 
: Ehm, isn't that +^, ~^ (and ?^, perhaps) nowadays?

Er.  It's, um, uh...a generic 1's complement operator!  Yeah, that's
the ticket...

But leaving aside my tendencies toward senility, ^T would still have
to be a placeholder variable.  And it might conflict with infix ^
if we ever allow xor'ed types, since declarations contain lots of
things that look like juxtaposed terms.

Larry


Re: new sigil

2005-10-25 Thread Juerd
Larry Wall skribis 2005-10-25 15:51 (-0700):
 ^T would still have to be a placeholder variable.

Which it is, in a way.

Still, I don't think ^ as a sigil needs to mean the same thing as ^ as a
twigil. Visually similar pairs are also not related:

?foo$?foo
*foo$*foo
+foo$+foo
=foo$=foo
foo ...   $foo

I think that it would help, and in different ways, even, to see ¢ as a
prefix operator with special syntax, instead of as a sigil. It doesn't
fit well in the list of sub, hash, array, scalar. 

Making it a prefix op would allow whitespace after it, which would make
the class keyword not seem so desperato. (I think it's a bad keyword
for this, and picking ^ instead would render it unnecessary, but more
about why I think class is bad for this in a later post.)

 And it might conflict with infix ^ if we ever allow xor'ed types,
 since declarations contain lots of things that look like juxtaposed
 terms.

Is this the same conflict that occurs in %foo % %bar? 

(I cannot imagine needing a one() junction for types, by the way. If
someone can come up with a good real-life example, please do so.)


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


RE: Avoid the Yen Sign [Was: Re: new sigil]

2005-10-25 Thread Jan Dubois
On Tue, 25 Oct 2005, Larry Wall wrote:
 As for the ¥ pitfall, so far we've intentionally been careful to use
 it only where an operator is expected, whereas \ is legal only where a
 term is expected.  So at least for Perl code, we can translate legacy
 ¥ to different codepoints.  (Whether the Japanese font distinguishes
 them is another issue, of course.  I have a Unicode font on my
 machine that prints backslash as ¥, which I find slightly irritating,
 but doubtless will be par for the course in Japan for the foreseeable
 future.  Maybe that's a good reason to allow the doublewith backslash
 as an alias for normal backslash.  Maybe not.)

BTW, the exact same thing happens with the Won sign ₩ on Korean Windows
systems; it is also mapped to 0x5c in the default codepage, and paths
are displayed with the Won sign instead of the backslash as separators.
Just something to keep in mind in case you are tempted to use the Won
sign as a sigil or operator in the future.

Cheers,
-Jan




Re: Avoid the Yen Sign [Was: Re: new sigil]

2005-10-25 Thread Juerd
Jan Dubois skribis 2005-10-25 12:33 (-0700):
 Just something to keep in mind in case you are tempted to use the Won
 sign as a sigil or operator in the future.

I don't know what stitch() will do, but this will have to be its infix
operator :)

zip ¥   Y
stitch  Won   w


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Perl 6 Summary for 2005-10-10 through 2005-10-24

2005-10-25 Thread Matt Fowles
=head1 Perl 6 Summary for 2005-10-10 through 2005-10-18

All~

Welcome to another Perl 6 Summary.  Sadly, this week's summary is not
brought to you by cookies as I already finished them.  Sadder still,
it is also brought to you a week late.  On the plus side, Mike
Doughty's Haughty Melodic is quite good.

=head2 Perl 6 Compilers

This was a shockingly high volume fortnight for p6c with 5 different
threads on it!

=head3 Feather:  A Retrospective

Juerd thought that now would be a good time to evaluate the usefulness
of feather to the community.  Warnock applies, but he probably found
answers off list...

http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/f14d8337b681d4a9/c95fc3fdf6d46f5b#c95fc3fdf6d46f5b
Google Groups : perl.perl6.compiler

=head3 PGE Better, Stronger, Faster

Patrick announced significant internal updates to PGE.  It looks
like things are coming along very nicely.  Yay, Patrick!

http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/10bff9a3100902a5/7135f5627205f9ca#7135f5627205f9ca
Google Groups : perl.perl6.compiler

=head3 PGE Now With Better Balance

Patrick also announced the subrule CPGE::Text::bracketed which is
similar to CText::Balanced from Perl 5.  Now where, did I put my
darn push-down automata.

http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/b52eb566b1b74920/19e4709aa8d2ecd6#19e4709aa8d2ecd6
Google Groups : perl.perl6.compiler

=head3 Object Space Thoughts

Stevan Little posted some of his thoughts about how the meta-model can
be built up from run time primitives.  It is pretty neat.

http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/e97984486b61828b/f34b165f8a919dcf#f34b165f8a919dcf
Google Groups : perl.perl6.compiler

=head3 Parrot PMCs within Pugs

Christian Renz wondered how to get at Parrot's PMCs from Pugs. 
Autrijus admitted that that feature was not currently available, but
offered a commit bit and suggested that adding tests would be a good
start.

http://groups.google.com/group/perl.perl6.compiler/browse_frm/thread/2f09e7c0503ea02f/d200cbd33f975d1d#d200cbd33f975d1d
Google Groups : perl.perl6.compiler

=head2 Parrot

=head3 README.win32

Michael Cartmel fixed a few spelling errors in README.win32.  Joshua
Hoblitt applied the patch.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/38ef8ca32b5fab74/f5fdce20a19d50a9#f5fdce20a19d50a9
Google Groups : perl.perl6.internals

=head3 parrot-config.imc Documentation

Roger Browne offered a patch fixing documentation in
parrot-config.imc.  Warnock applies.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/2d86e5015608cb9e/43969cc2f25a0f7b#43969cc2f25a0f7b
Google Groups : perl.perl6.internals

=head3 Train Parrot to Flex

In the RT clean up, an old ticket has resurfaced.  Parrot needs to be
updated to use flex 2.5.31, which is incompatible with 2.5.4.  Patches
welcome.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/8dc8adf441fa6805/f24be3c94a3dfba7#f24be3c94a3dfba7
Google Groups : perl.perl6.internals

=head3 Dynamism Defeats Static Analysis

Patrick and I had a brief back and forth about detecting PGE
recursion.  The short answer is that it is possible in the static
case, but not in the face of changing rules.  Stupid halting problem,
where did I put my PDA.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/b08ed4ac97e3090c/d934e5866bdc9a43#d934e5866bdc9a43
Google Groups : perl.perl6.internals

=head3 void function return

Will Coleda is tired of special casing void functions and wants C() =
function() to be legal in PIR.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/c7e54dc1d2b887a9/74dcbe2b279de204#74dcbe2b279de204
Google Groups : perl.perl6.internals

=head3 Bison = 1.75c

Joshua Hoblitt noticed that the newer Bisons have slightly different
error messages than older ones.  He felt that we should either
standardize on the newer bison or explicitly declare error messages. 
No official ruling on which...

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/79e9151802ec9185/c9d1a7dd3236d16b#c9d1a7dd3236d16b
Google Groups : perl.perl6.internals

=head3 __set_pmc_keyed_*

Patrick needed a way to distinguish C__set_pmc_keyed_int from
C__set_pmc_keyed.  Leo gave it to him.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/e8f0cf140b05669a/9a125b4a7524b9f2#9a125b4a7524b9f2
Google Groups : perl.perl6.internals

=head3 HLL type mappings

Roger Browne wondered how he could set HLL type mappings from PIR. 
Leo said it was not yet implemented or speced.  Roger suggested adding
a few opcodes.

http://groups.google.com/group/perl.perl6.internals/browse_frm/thread/5f6e488e14b5b859/39be8e39b16b9d71#39be8e39b16b9d71
Google Groups : perl.perl6.internals

=head3 s/\@(directive)/:$1/g

Jonathan Scott Duff submitted a patch which swapped @directives to
:directives everywhere.  Leo applied most of it in several smaller

Re: Perl 6 Summary for 2005-10-10 through 2005-10-24

2005-10-25 Thread Jonathan Worthington

Matt Fowles [EMAIL PROTECTED] wrote:

=head3 Obsolete Win32 Exports

Michael Walter found and removed some obsolete Win32 Exports.
Jonathan Worthington applied the patch.  Weren't we planning on auto
generating these?


The Plan is to mark functions that are to be exported with something that
we'll #define to be the export directive on Win32, thus rendering the .def
file as un-needed.  However, before that's done we should really decide on
what functions Parrot extension writers should be allowed access to, e.g. as
part of the extension API.  That's a design decision.  I popped it in the
ROADMAP, so it will be decided at some point.


=head3 Leaky Parrot

Alberto Simões is having trouble with Parrot leaking memory and a bad
free.  Warnock applies.


The bad free was fixed by the patch I provided Alberto to try out (see
below), though there are still lots of memory leaks that would be good to
fix up.


=head3 Fighting with a Tiger

Alberto Simões was having troubles with Tiger.  Jonathan Worthington
provided a little C wizardry, and Alberto was happy.  He asked to have
the patch applied, but Warnock did instead.


I did apply it. I thought I'd posted to the list that I'd applied it.  I may
be incapable of using an email client too.  ;-)


=head3 Debug Segments

Jonathan Worthington announced that he was making progress on his
debug segment work, but would soon half to dive into IMCC.  As a
slight corollary all existing PBCs were invalidated.


I dived into IMCC.  I'm survived the experience and did what was needed in
there, though I think maybe my post about that was missed in the summary.
I've got just a couple of small things to clear up now, but otherwise the
PASM/PIR debug seg stuff is about done.  Next up: HLL debug segs.

Thanks for the summary,

Jonathan



Re: $_ defaulting for mutating ops

2005-10-25 Thread Larry Wall
On Tue, Oct 25, 2005 at 02:51:35PM +0200, Juerd wrote:
: For comparison, here is the same code snippet again. First with, and
: then without explicit $_.
: 
: With:
: 
: given ($subject) - $_ {
: $_ ~~ s/foo/bar/;
: $_++;
: $_ x= 2;
: $_ ~= !;
: }
: 
: Without:
: 
: given ($subject) {
: s/foo/bar/;

Already the default.

: ++;

Can already use .++ there.  That's because you can already use . on
any postfix operator, and since any . form defaults to $_, you get
.++ for free.  I'll let you have .-- as well.  And .! if you define
factorial.  :-)

It would be possible to extend . to allow any infix plus its right argument
to be treated as a postfix, presuming there wasn't already a postfix of
that name.  However...

: x= 2;

That might validly parse as assignment to an lvalue sub: x() = 2;
Unfortunately .x= 2 doesn't work either, since we also have lvalue
methods.  Actually, x=2 should parse as x(=2), since a list operator
always expects a term next.  Yes, we *could* throw all the infix
operators into the prefix pot and match them under longest-token, but
the basic problem with the proposal is rampant term/operator confusion.
What should the lexer do when it sees a statement starting with

/=digit*/
%=PODSynopsis.say
*=$*IN
+=

Those could get away with

./= 2
.%= 2
.*= 2
.+= 22

But then you're only saving a character (and maybe a space) over $_.

: ~= !;

That would validly parse as

~(=!)

: I think the latter is more elegant, without reducing legability or
: maintainability. I also think that the code is immediately obvious, even
: to people coming from Perl 5, who never read this thread.

I think you're relying on those people using whitespace to dwym,
but unfortunately people chunk things differently from computers.
And most people will be uncomfortable if the computer uses whitespace
to guess, more so because it's doing lookahead to find that whitespace.
And are you ready to disallow patterns that start with '='?

And basically I don't think people want to mutate $_ with math operators
all that often--and if they do want to, they probably don't.  :-)

Larry


Re: new sigil

2005-10-25 Thread Larry Wall
On Wed, Oct 26, 2005 at 01:17:10AM +0200, Juerd wrote:
: Larry Wall skribis 2005-10-25 15:51 (-0700):
:  ^T would still have to be a placeholder variable.
: 
: Which it is, in a way.

Though we don't currently allow placeholders in ordinary sigs, or even
in conjunction with ordinary sigs.

: Still, I don't think ^ as a sigil needs to mean the same thing as ^ as a
: twigil. Visually similar pairs are also not related:
: 
: ?foo$?foo
: *foo$*foo
: +foo$+foo
: =foo$=foo
: foo ...   $foo

True, though it would be the first time we used the same character as
both a sigil and a twigil.  ^^T would certainly be a placeholder
in that case, but that might be confusing.

: I think that it would help, and in different ways, even, to see ¢ as a
: prefix operator with special syntax, instead of as a sigil. It doesn't
: fit well in the list of sub, hash, array, scalar. 

But then you can't have ¢*T, ¢+T, ¢^T, ¢?T, ¢.T, etc.

By the way, the meaning of the + twigil just changed.  Last week it
meant The $? of the currently compiling unit.  That's been taken
over by the COMPILING::$?foo notation, partly because I wanted to
steal $+ for generalized environment variables, that is, dynamically
visible lexicals, such as $_.  See

http://svn.perl.org/perl6/doc/trunk/design/syn/S02.pod

I've also checked in various changes to

http://svn.perl.org/perl6/doc/trunk/design/syn/S06.pod

[Everyone please remember to start new threads for unrelated topics.]

: Making it a prefix op would allow whitespace after it, which would make
: the class keyword not seem so desperato. (I think it's a bad keyword
: for this, and picking ^ instead would render it unnecessary, but more
: about why I think class is bad for this in a later post.)

Let's delete sub too while we're at it.  :-)

I'm not stuck on class as the ASCII workaround.  It's not quite the
same as sub since we don't allow sub X everywhere we allow X.

:  And it might conflict with infix ^ if we ever allow xor'ed types,
:  since declarations contain lots of things that look like juxtaposed
:  terms.
: 
: Is this the same conflict that occurs in %foo % %bar? 

Nope.  Normal expressions always know whether they're expecting a term
or operator.  I'm talking about in signatures where (it seems to me)
terms are juxtaposed to mean and, and the available operators
can only be ones that can't be confused with a term prefix or zone
marker.  We actually had that problem back when we had junctional
types:

T1T2

Is that a sub T2 returning a T1?

T1 T2

Or is a type constraint that must match both types?

T1  T2

Currently we've said that such junctions should be down in a where
clause, but it would be nice to leave the door open for

Int|Str

type constraints.  But it's somewhat problematic to have a junctional
return type, so maybe that will never happen, and the most complicated
thing we'll see (in the absence of where clauses and subsignatures),
is

sub foo (Mammal ¢T $fido)

In that case ^ or | could be forced to work.  But I'd still rather use
something that doesn't shout operator, especially if the notation can
sneak into rvalue code.  And I'd prefer to leave the ASCII characters
available for real operators and metaoperators later.

: (I cannot imagine needing a one() junction for types, by the way. If
: someone can come up with a good real-life example, please do so.)

Oh, that's easy, for some definition of real.  In real life, cats and
dogs don't overlap, so if you say Cat|Dog, you really mean Cat^Dog.
But these junctional types are only good for constraints.  A given
object may only have a set of types, not a junction of types.

Larry


Re: new sigil

2005-10-25 Thread Eric
On 10/25/05, Larry Wall [EMAIL PROTECTED] wrote:
 On Wed, Oct 26, 2005 at 01:17:10AM +0200, Juerd wrote:
 : Larry Wall skribis 2005-10-25 15:51 (-0700):
 :  ^T would still have to be a placeholder variable.
 :
 : Which it is, in a way.

 Though we don't currently allow placeholders in ordinary sigs, or even
 in conjunction with ordinary sigs.

 : Still, I don't think ^ as a sigil needs to mean the same thing as ^ as a
 : twigil. Visually similar pairs are also not related:
 :
 : ?foo$?foo
 : *foo$*foo
 : +foo$+foo
 : =foo$=foo
 : foo ...   $foo

 True, though it would be the first time we used the same character as
 both a sigil and a twigil.  ^^T would certainly be a placeholder
 in that case, but that might be confusing.

 : I think that it would help, and in different ways, even, to see ¢ as a
 : prefix operator with special syntax, instead of as a sigil. It doesn't
 : fit well in the list of sub, hash, array, scalar.

 But then you can't have ¢*T, ¢+T, ¢^T, ¢?T, ¢.T, etc.

 By the way, the meaning of the + twigil just changed.  Last week it
 meant The $? of the currently compiling unit.  That's been taken
 over by the COMPILING::$?foo notation, partly because I wanted to
 steal $+ for generalized environment variables, that is, dynamically
 visible lexicals, such as $_.  See

 http://svn.perl.org/perl6/doc/trunk/design/syn/S02.pod

 I've also checked in various changes to

 http://svn.perl.org/perl6/doc/trunk/design/syn/S06.pod

 [Everyone please remember to start new threads for unrelated topics.]

 : Making it a prefix op would allow whitespace after it, which would make
 : the class keyword not seem so desperato. (I think it's a bad keyword
 : for this, and picking ^ instead would render it unnecessary, but more
 : about why I think class is bad for this in a later post.)

 Let's delete sub too while we're at it.  :-)

 I'm not stuck on class as the ASCII workaround.  It's not quite the
 same as sub since we don't allow sub X everywhere we allow X.

 :  And it might conflict with infix ^ if we ever allow xor'ed types,
 :  since declarations contain lots of things that look like juxtaposed
 :  terms.
 :
 : Is this the same conflict that occurs in %foo % %bar?

 Nope.  Normal expressions always know whether they're expecting a term
 or operator.  I'm talking about in signatures where (it seems to me)
 terms are juxtaposed to mean and, and the available operators
 can only be ones that can't be confused with a term prefix or zone
 marker.  We actually had that problem back when we had junctional
 types:

 T1T2

 Is that a sub T2 returning a T1?

 T1 T2

 Or is a type constraint that must match both types?

 T1  T2

 Currently we've said that such junctions should be down in a where
 clause, but it would be nice to leave the door open for

 Int|Str

 type constraints.  But it's somewhat problematic to have a junctional
 return type, so maybe that will never happen, and the most complicated
 thing we'll see (in the absence of where clauses and subsignatures),
 is

 sub foo (Mammal ¢T $fido)

 In that case ^ or | could be forced to work.  But I'd still rather use
 something that doesn't shout operator, especially if the notation can
 sneak into rvalue code.  And I'd prefer to leave the ASCII characters
 available for real operators and metaoperators later.

 : (I cannot imagine needing a one() junction for types, by the way. If
 : someone can come up with a good real-life example, please do so.)

 Oh, that's easy, for some definition of real.  In real life, cats and
 dogs don't overlap, so if you say Cat|Dog, you really mean Cat^Dog.
 But these junctional types are only good for constraints.  A given
 object may only have a set of types, not a junction of types.

 Larry

I would just like to mention that 'class' is confusing because you
don't realy mean class there.  The whole conversation is about types
so why not have it be 'type'?  On the whole i think ^ makes good sense
and looks pretty good.  It also meets the needs of being a single
letter, not already being a sigil, etc.  'class ' is no longer a
twigil and leads to the confusing reasoning you had about where it
needs class and where it doesn't\

sub test (^T $x) {
my ^T $y = $x + 5;
}

Is pretty easy and straight forward.  With class i can't figure and
obvious DWIM.

sub test (class T $x) {
my class T $y = $x + 5;
}

That doesn't look right because you have 'my class' so you would think
the type is 'class' except the type isn't class, its T.  If you
bareword T then it might overlap (collide) with a real class named T.

In the following case it is not clear wether Dog is defined in the
signature, or a realy seperate class.

sub test (class Dog $x) {
my Dog $y = $x + 5;
}

The same example with ^ becomes much clearer to me.
sub test (^Dog $x) {
my ^Dog $y = $x + 5;
}

The ^ clearly states the meaning while bareword Dog and 'class Dog'
would both cause 

Re: new sigil

2005-10-25 Thread Luke Palmer
On 10/25/05, Eric [EMAIL PROTECTED] wrote:
 I would just like to mention that 'class' is confusing because you
 don't realy mean class there.  The whole conversation is about types
 so why not have it be 'type'?

If you read the introduction to theory.pod[1], you'll find that we are
actually talking about classes.  First, let me define what I mean:

class: A concrete, instantiable type.  Each value has exactly one of these.
type: A behavioral interface.  Each value probably has more than
one of these.

One of the big ideas behind theories is that you can never write the
name of a class in your program... ever.  The only way you can talk
about classes is through variables with constraints.  So, when I say:

sub foo(Int $bar) { $bar + 1 }

I actually mean:

sub foo(¢T $bar where ¢T (in) Int) { $bar + 1 }

(Which is pseudosyntax)

That is, foo accepts any *class* which obeys the Int *type*.  That's
the most specific you can get.


 BTW didn't you contradict your own real world usage of type1^type2 ?
 Even if we use ^ as a sigil why would it get confused on that?  I
 don't think type1 ^type2 could have any realy meaning so it should be
 easy for the parser to know the difference.

Yeah, I didn't really follow his argument on that one.  I, too, think
that the one() junction in general is silly, especially for types.

When you say Dog^Cat, you're saying I want something that either
conforms to the Dog interface or the Cat interface, but *definitely
not both*!  Why the heck would you care about that?  Does there
really arise a situation in which your code will be erroneous when the
variable conforms to both interfaces?

And in fact, its very existence defies another implicit principle of
mine, that is, the principle of partial definition:  Defining a new
type or instance can only break a previously typechecking program by
making it ambiguous.  The idea behind that is that at some time you
may realize that oen of your types already obeys another type, and
declare that it conforms to that interface.  But you don't go the
other way around, undeclaring that an interface holds, without your
program having been erroneous in the first place.  Declaring that a
new interface holds (so long as it actually does) shouldn't break
anything that was already correct.

The principle also has strong implications with library code: 
including a new library but doing nothing with it shouldn't start
randomly breaking stuff.  (Unless, of course, it breaks the rules and
does crazy stuff, in which case anything goes)

Luke

[1] I'm still thinking in terms of this proposal.  If it turns out to
be wrong, disregard my comments.