Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[RFC] Perl Operator List, TAKE 6

53 views
Skip to first unread message

Michael Lazzaro

unread,
Nov 1, 2002, 3:21:43 PM11/1/02
to perl6-l...@perl.org
Adjusted for the most recent notes: includes «op» as the preferred (and
possibly only) spelling of "vectorize". Everything but a few hyperop
issues appears to be close to final, by my count: if/when Larry sticks
a fork() in it, it's done.

hyperoperators:

«op» - When used with any unary or binary operator,
"vectorizes" the operator.
»op« - [maybe] same, but intersection instead of union.
^[op] - [maybe] synonym for «op»
- [maybe] synonym for »op«

unary (prefix) operators:

\ - reference to
* - list flattening
? - force to bool context
! - force to bool context, negate
not - force to bool context, negate
+ - force to numeric context
- - force to numeric context, negate
~ - force to string context
^ - complement, type-specific
. - method call on current topic
.= - method call on current topic, replaces topic

++ - preincrement
-- - predecrement

unary and other postfix operators:

These are used as postfix operators when encountered where
an operator is expected. No space is allowed between these
postfixes and the elements they are operating on.

++ - postincrement
-- - postdecrement

... - synonym for ..Inf

() - method call
[] - array access
{} - hash access


binary operators:

< > <= >= == != <=> - comparision (numeric)
lt gt le ge eq ne cmp - comparision (string)

+ - * / % ** - arithmetic
+= -= *= /= %= **=

~ ~= - string concat
x x= - string repetition
xx xx= - list replication

&& || ^^ // - boolean operations
&&= ||= ^^= //=
and or xor err

+& +| +^ << >> - bitwise (integer) operations
+&= +|= +^= <<= >>=

~& ~| ~^ - charwise (string) operations
~&= ~|= ~^=

?& ?| ?^ - C-like boolean operations
?&= ?|= ?^= - (result is always just 1 or 0)

& | ^ - superpositional operations
&= |= ^= - conjunctive, disjunctive, exclusive
all any one none - conj, disj, excl, dismissive

~~ !~ - smart match, smart non-match

=> - pair creator
, - list creator
; - "greater comma", list-of-lists creator
: - adverbial
. - method call

.. - range
^.. - [maybe] range, exclusive of endpoint(s)
..^
^..^

= - assignment
:= - runtime binding
::= - compiletime binding


trinary operator:

?? :: - if/else


parens, misc, and quotelike operators:

These may appear where a term is expected.

()
[]
{}

m// - shorthand, "matches"
s/// - shorthand, "substitute"
tr/// - shorthand, "transliterate"

'...' "..." `...` /.../
q qq qx rx qw [qm?]

<...> - iteration
(heredocs) - [exact format unknown; probably as perl5]


magical whitespace modifier:

_ - When used at the end of a line or between
statement elements, acts to "remove" whitespace
when interpreting the statement. (Allows
whitespace to appear without invoking any
special interpretations normally associated
with that whitespace.)


named unary (prefix) operators, terms, and other
important assorteds, identified when possible:

-X - [op] filetest operators

ref - [op]
exists - [op]
delete - [op]
defined - [op]
undef - [op]
undef - [term]
temp - [op]
let - [op]
but - [op] val properties

${ } - [deref] dereference scalarref
@{ } - [deref]
%{ } - [deref]
&{ } - [deref]

... - [term] yada**3
Inf - [term]
NaN - [term]

is - [declar] var properties
-> - [declar] like 'sub'
hash - [declar] force hash context


MikeL

David Wheeler

unread,
Nov 1, 2002, 3:35:29 PM11/1/02
to Michael Lazzaro, perl6-l...@perl.org
On Friday, November 1, 2002, at 12:21 PM, Michael Lazzaro wrote:

> ^[op] - [maybe] synonym for «op»
> - [maybe] synonym for »op«

I think that would be:

`<<op>> - synonym for «op»
`>>op<< - synonym for »op«

Unless I misunderstood Larry's post, in which case it might be:

`<<op>>` - synonym for «op»
`>>op<<` - synonym for »op«

Regards,

David
--
David Wheeler AIM: dwTheory
da...@wheeler.net ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: The...@jabber.org

Richard Proctor

unread,
Nov 1, 2002, 4:01:15 PM11/1/02
to Michael Lazzaro, perl6-l...@perl.org
On Fri 01 Nov, Michael Lazzaro wrote:
>
> (heredocs) - [exact format unknown; probably as perl5]
>

There are comments by Larry in Appo 2 wrt RFCs 111 and 162.

Appo 2:
=======

111 aaa Here Docs Terminators (Was Whitespace and Here Docs)
162 abb Heredoc Contents

RFC 111: Here Docs Terminators (Was Whitespace and Here Docs)
Fine.

RFC 162: Heredoc contents
I think I like option (e) the best: remove whitespace equivalent to the
terminator.

By default, if it has to dwim, it should dwim assuming that hard tabs
are 8 spaces wide. This should not generally pose a problem, since
most of the time the tabbing will be consistent throughout anyway, and
no dwimming will be necessary. This puts the onus on people using
nonstandard tabs to make sure they're consistent so that Perl doesn't
have to guess.

Any additional mangling can easily be accomplished by a user-defined
operator.

RFC111:
=======

Perl6 should ignore any whitespace before the terminator of a heredoc on any
line. Further it should ignore any whitespace ";"s (and comments) that
follow the terminator. Perl should also ignore whitespace between the << and
the terminator.

Discussion took place on allowing statements following the terminator, but
generally these where thought of as a bad idea. So only ";" and comments
should occour on the same line.

All of these should work:

print <<EOL;
EOL
print << EOL;
EOL
print << EOL;
EOL;
print << EOL
EOL;
print <<EOL ;
EOL # this is the end of the here doc
print <<EOL
EOL; # this is the end of the here doc
print <<EOL ;
EOL; # this is the end of the here doc

But this should be an error:

print <<EOL
EOL; $i++;


RFC162:
=======
e) Remove whitespace equialent to the terminator - a realistic option. This
takes the whitespace off the content equivalent to that on the terminator and
removes that amount of whitespace from the content.

Though this behaviour might be associated with an enhanced Heredoc '<<<'
both had been proposed in the RFC, even though I edited the RFC I am not
sure quite what was agreed.

Richard

--
Personal Ric...@waveney.org http://www.waveney.org
Telecoms Ric...@WaveneyConsulting.com http://www.WaveneyConsulting.com
Web services Ric...@wavwebs.com http://www.wavwebs.com
Independent Telecomms Specialist, ATM expert, Web Analyst & Services

John Williams

unread,
Nov 1, 2002, 4:13:31 PM11/1/02
to Michael Lazzaro, perl6-l...@perl.org
On Fri, 1 Nov 2002, Michael Lazzaro wrote:

> ... - synonym for ..Inf

Did I miss the report of the bistable ... operator's death?
I've looked around, but I can't seem to find it.

~ John Williams


Garrett Goebel

unread,
Nov 1, 2002, 5:03:52 PM11/1/02
to David Wheeler, Michael Lazzaro, perl6-l...@perl.org
David Wheeler wrote:
> On Friday, November 1, 2002, at 12:21 PM, Michael Lazzaro wrote:
>
> > ^[op] - [maybe] synonym for «op»
> > - [maybe] synonym for »op«
>
> I think that would be:
>
> `<<op>> - synonym for «op»
> `>>op<< - synonym for »op«
>
> Unless I misunderstood Larry's post, in which case it might be:
>
> `<<op>>` - synonym for «op»
> `>>op<<` - synonym for »op«

I think that was:

`<<op`>> - synonym for «op»
`>>op`<< - synonym for »op«

Larry wrote:
> I could see using backtick as the "escape" code for things
> like `<< or `>> which would turn into what some benighted
> soul called "girly" angles.

--
Garrett Goebel
IS Development Specialist

ScriptPro Direct: 913.403.5261
5828 Reeds Road Main: 913.384.1008
Mission, KS 66202 Fax: 913.384.2180
www.scriptpro.com gar...@scriptpro.com

fear...@figaro.weizmann.ac.il

unread,
Nov 1, 2002, 6:15:05 PM11/1/02
to Michael Lazzaro, perl6-l...@perl.org
Michael Lazzaro writes:

> magical whitespace modifier:
>
> _ - When used at the end of a line or between
> statement elements, acts to "remove" whitespace
> when interpreting the statement. (Allows
> whitespace to appear without invoking any
> special interpretations normally associated
> with that whitespace.)
>

my understanding from the discussions was that
"free" ( separated by spases ) _ is still placeholder . and it
becomes "spaceeater" only when "attached" to operator . And a special
rule for block ending curly "}_" .

_ - "spaceeater" modifier
Generally , no space is allowed between term and postfix
operator. to relax that rule use the "spaceeater"-prefixed form
_op of the operator. e.g. @a[1] is same as @a _[1] . Binary
operator is allowed to have no space before it if there is no
postfix operator of the same name. Terms like {code} , {hash} ,
[array] have to have space before them if stand after term.


or


Any postfix operator op can be used in the form _op. that allows
whitespace to appear between term and operator without invoking


any special interpretations normally associated with that
whitespace.

arcadi

Andrew Wilson

unread,
Nov 1, 2002, 6:55:26 PM11/1/02
to perl6-l...@perl.org
On Fri, Nov 01, 2002 at 12:21:43PM -0800, Michael Lazzaro wrote:
> +& +| +^ << >> - bitwise (integer) operations
> +&= +|= +^= <<= >>=

I might have missed this, but if + introduces bitwise operations,
why aren't we using it in the shift operations?

+& +| +^ +< +> - bitwise (integer) operations
+&= +|= +^= +<= +>=

Would seem to be more consistent and frees up << and >> for something
else.

andrew
--
Virgo: (Aug. 23 - Sept. 22)
It's been almost three decades, but you think you're finally beginning
to recover from the long, national nightmare of Vietnam movies.

Uri Guttman

unread,
Nov 1, 2002, 7:20:27 PM11/1/02
to Michael Lazzaro, perl6-l...@perl.org
>>>>> "ML" == Michael Lazzaro <mlaz...@cognitivity.com> writes:

ML> +& +| +^ << >> - bitwise (integer) operations
ML> +&= +|= +^= <<= >>=

ML> ~& ~| ~^ - charwise (string) operations
ML> ~&= ~|= ~^=

i think those descriptions need to be a little better. i would say
'bitwise operations on (integer|string) value.

uri

--
Uri Guttman ------ u...@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org

Luke Palmer

unread,
Nov 2, 2002, 7:54:37 AM11/2/02
to fear...@figaro.weizmann.ac.il, mlaz...@cognitivity.com, perl6-l...@perl.org
> Mailing-List: contact perl6-lan...@perl.org; run by ezmlm
> Date: Sat, 2 Nov 2002 01:15:05 +0200
> From: <fear...@figaro.weizmann.ac.il>
> Cc: perl6-l...@perl.org
> X-SMTPD: qpsmtpd/0.12, http://develooper.com/code/qpsmtpd/

>
> Michael Lazzaro writes:
>
> > magical whitespace modifier:
> >
> > _ - When used at the end of a line or between
> > statement elements, acts to "remove" whitespace
> > when interpreting the statement. (Allows
> > whitespace to appear without invoking any
> > special interpretations normally associated
> > with that whitespace.)
> >
>
> my understanding from the discussions was that
> "free" ( separated by spases ) _ is still placeholder . and it
> becomes "spaceeater" only when "attached" to operator . And a special
> rule for block ending curly "}_" .

What _are_ you talking about. IIRC, there were never any plans for
such a "placeholder." There were the placeholder _variables_, $^x et
al., but the underscore was never used for such a thing. That could
be why I've been so confused by some of your examples.

Luke

fear...@figaro.weizmann.ac.il

unread,
Nov 2, 2002, 11:59:24 AM11/2/02
to Luke Palmer, fear...@figaro.weizmann.ac.il, mlaz...@cognitivity.com, perl6-l...@perl.org
Luke Palmer writes:
>
> What _are_ you talking about. IIRC, there were never any plans for
> such a "placeholder." There were the placeholder _variables_, $^x et
> al., but the underscore was never used for such a thing. That could
> be why I've been so confused by some of your examples.
>

i am sorry , you are right , somehow i had an impressionthat _ + _ is
a valid syntax , butthis is different language

aracdi

Dennis Haney

unread,
Nov 5, 2002, 2:18:18 PM11/5/02
to Michael Lazzaro, perl6-l...@perl.org
Michael Lazzaro wrote:

> ~ - force to string context

> ~ ~= - string concat

ARG. When did this get chosen?
~ has to be absolutly the most difficult letter to type on the intire
keyboard along with ^ and ", because they are also used as a prefix to
make û, ü, õ, ã, ñ etc.
Thus a standalone ~ must be made with a AltGr+^ followed by a space.

Larry Wall

unread,
Nov 6, 2002, 2:13:36 PM11/6/02
to Dennis Haney, Michael Lazzaro, perl6-l...@perl.org

Bummer. Oh well. You're not supposed to use string concatenation
all that often anyway...

Larry

John Adams

unread,
Nov 6, 2002, 2:22:13 PM11/6/02
to Larry Wall, Dennis Haney, Michael Lazzaro, perl6-l...@perl.org
On Wed, 6 Nov 2002 11:13:36 -0800 Larry Wall <la...@wall.org> wrote:

> You're not supposed to use string concatenation
> all that often anyway...

I'm not supposed (for some value of supposed) to use Perl at my job, but I do,
and I suspect I use string concatenation in about one script in five, so
should I vote Scylla or Charybdis?

Thanks,

John A
see me fulminate at http://www.jzip.org/

0 new messages