develooper Front page | perl.perl6.language | Postings from November 2004

Re: Angle quotes and pointy brackets

Thread Previous | Thread Next
From:
Alexey Trofimenko
Date:
November 30, 2004 03:34
Subject:
Re: Angle quotes and pointy brackets
Message ID:
opsh9zrgn6sspxk8@s
On Tue, 30 Nov 2004 10:43:10 +0100, Juerd <juerd@convolution.nl> wrote:

> Alexey Trofimenko skribis 2004-11-30  9:09 (+0300):
>> delimiters should have corresponding closing character, so it should be
>> something like
>
> Please, stop seeing ` as a circumfix operator in this context. What you
> do is like saying that after . you expect a capital letter. It's a
> programming language, and the only definition useful is the language
> itself, disregarding other languages, like Perl 5 and English.
>
> In current Perl, :: is also known as '. And that's not a quoting
> character in that context. In an early Apocalypse, Larry said not to
> make the same "mistake" again because it would be hard to syntax-colour.
> But that doesn't quite count, as matching for editors will have to be
> rewritten anyway to support things like "$foo{"bar"}".

I have several editors even on windows, and not even specially written for  
perl, which do color ' as :: correctly. Personally, I liked that syntax,  
it has some similarities to Ireland surnames:) $O'Hara{Scarlett}

but it puts big restrictions on what can be part of the name (actually,  
thoose which match to <ident> only), so $package'$varname won't work.
I meant only that your ` can't be replacement to « » because latter allows  
MUCH more freedom in key names. Actually, only space has special meaning  
here.

so, could you be more explicit, what rules your syntax have?

$a`$b+$c`$d, is it equivalent of
$a[$b+$c][$d] or
$a[$b]+$c[$d] ?

and I think, polymorphic treating of ` as either {} or [] adds some  
overhead.. and unstability of your code. Especially in cases like $a`$b,  
when compiler just can't see in compiler time, what could be contained in  
$b - number or string.
only one variant of that syntax looks for me useful:

   $var`Only`Ident`Compatible{$strings}`Here123

as replacement for
   $var{'Only'}{'Ident'}{'Compatible'}{$strings}{'Here123'}

so ` works here exactly as Java(ECMA)Script .
no spaces allowed, no expressions, and it is always a HASH subscript.

doesn't lua have that prefix `Quoting behavior already? ( 'text' eq `text  
) or it was some other language? If to mimic it, than
   $var`Only`Ident`Compatible{$strings}`Here123
could be automatiaclly transformed into
   $var'Only''Ident''Compatible'{$strings}'Here123'

Macro definition for it could be very simple, like
  macro postfix:«`» is parsed {<ident>} {return "'$0'"} or something like.

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

> This is just making parens/curlies optional for more operators than
> <<>>.

but :key'value' is the same as :key<<value>>.. distinction shown only on  
occasional spaces in ''.

>
>>    $var.<key1><key2>[1].<key3>  # yikes, but still better than <<>><<>>
>
> Still hard to type. Simply put, repeated circumfix operators suck,
> regardless of whether they are <>, <<>>, "", '', [], {}.

hm, I thought something like this long time ago, when I come to perl and  
some other languages from pascal, where you could address a 3dimensional  
array with a[1,2,3] instead of a[1][2][3]; but there was no problem at  
all, it's a matter of habit. now I consider latter more readable and  
flexible.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About