On Fri, 26 Nov 2004 09:33:49 -0800, Larry Wall <[EMAIL PROTECTED]> wrote:

On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote:
: I notice that in Perl6 thoose funny  and  could be much more common
: than other paired brackets. And some people likes how they look, but
: nobody likes the fact that there's no (and won't!) be a consistent way to > : type them in different applications, wether it's hard or easy.
...
: We also have another ascii pair, < and > . maybe they could be better : than  and  ?:) i'm not that farseeing, but isn't problem of : distinguishing < as a bracket and < as an comparison operator no harder
: than distinguishing << as bracket and as part of heredoc?..
It would get very confusing visually, even if the computer could sort it out:


    @a >= @b
    @a >=< @b

But there are some things that would be completely ambiguous:

    %hash<foo><bar>
    %hash<foo><baz()

I not meant to replace it everywhere. But problem still exists.

I know about only four uses of  and Â. Tell me if there's more?

1) hyperoperators;

  @a = @b Â*Â @c         @aÂ.method
  @a = @b >>*<< @c       @a>>.method

(and, of course, mentioned in the past supercool 7-chars >>=:=<< operator!)
hm.. IMO, hyperoperations are fat enough to be fat even in code. I wonder only if whitespace allowed there:
@a = @b >> * << @c @a >>.method



2) qw//-like construct;

  @array = Âfoo bar bazÂ
  @array = <<foo bar baz>>
  @array = qw<foo bar baz>

once again, there's nothing wrong. Although, using just <foo bar baz> would confuse Perl6 no more than <globs> and <filehandles> confuses Perl5. "want an operator/want a term" rule applies here.

3) pair(adverb) value quoting;

   myfunc :fooÂbar :barÂbazÂ
   myfunc :arrayÂvalue1 value2 value3Â

   myfunc :foo<<bar>> :bar<<baz>>   # this certainly suck
   myfunc :foo("bar") :bar("baz")   # I'm going to use that if it works(?).

   # still this suck less:
   myfunc :array<< value1 value2 value3 >>
   # ..than:
   myfunc :array("value1", "value2", "value3")

but replacement of << >> with plain < > here is a no-problem:

   myfunc :foo<bar> :bar<baz> :array<value1 value2 value3>

after you type :foo<bar> only three times, you'll acquire internal alarm on constructs like

  myfunc :foo<bar> :bar<10;

which are rather obfuscating already.
IMHO, mandatory whitespace between :bar and <10 here won't make anybody sick.
I wonder how many people would like to write it
myfunc:foo<bar>:bar<10;


4) hash subscripting;

that's a real pain.

rather cute
   $varÂkey1ÂÂkey2Â[3]Âkey3Â

suddenly becomes an ugly monster:

   $var<<key1>><<key2>>[3]<<key3>>

of course we could write:
   $var{'key1'}{'key2'}[3]{'key3'}

and I would prefer this one to previous variant..
but it adds noise too. and it prevent us to logicaly recognize 'key1' and 'key2' not as strings but as something more like struct elements, like we got used in perl5


When I look at this
   $var<key1><key2>[3]<key3>

then I think that it's a *very* cute, nice, and clean syntax... I really like it!
(and I would sacrifice something for that to happen, if I would be Larry :) )
but there's a problem for people and parser too. < is a comparison *operator* and hash subscript is *operator* too, and there's no way to distinguish them at all. "Term rule" won't help here.


+< and +> for comparison is plain sickness, of course. But we have some whitespace rules already. One of them is that subscripts shouldn't have whitespace to the left of them. We could add one more - to always PUT whitespace before < comparison. so

  $a<foo.. is a start of subscript and
  $a <foo.. is always a comparison.

Personally I'm not lazy to put spaces because of my little Forth experience.
but I don't want to be lynched by mad horde of programmers in white robes, who will discover that
while $a<$b {...}
for qw<a b c> {...}


and even
  foo()<bar()...
do something completelly wrong, and parser just unable to catch this..
(hm.. bad examples.. maybe it could be made able to?)

*sigh.. I'll write my own grammar:) I only afraid that it would take a half of all my remaining lifetime (because of addiction)

But I'll return to topic.
I've seen proposal by Juerd, somewhere it this thread, to use `` for autoquoting subscripting.


but proposed
%hash`foo`bar`$foo`0`$bar=0
not going to work
delimiters should have corresponding closing character, so it should be something like


  %hash`foo``bar`{$foo}[0]{$bar}=0

or it would be *much* worse for parser than <>.

actually, (countrary to [] and {} which could have arbitrary complex nested expressions in it) "autoquoting" subscript shouldn't neccessarily be a paired string. Any character could be used for it without any ambiguity. Even perl4 style ' or even "
Same with :pairs


 %hash"key""anotherkey"[1]=0
 %hash'key''anotherkey'[1]=0
 :key"value"
 :key'value'

ah, using " here would cause difficulties to interpolation of "hello, $world"
so what about ' or ` (or whatever you could imagine)?


P.S. I also considered "shorcuts" like
$var<<key1><key2><key3>>[1] # but that not going to remove MUCH of linenoise.
or
$var.<key1><key2>[1].<key3> # yikes, but still better than <<>><<>>
...

Reply via email to