[% setvar title Method calls should not suffer from the action on a distance %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/

TITLE

Method calls should not suffer from the action on a distance

VERSION

  Maintainer: Ilya Zakharevich <ilya@math.ohio-state.edu>
  Date: 15 Sep 2000
  Mailing List: perl6-language@perl.org
  Number: 244
  Version: 1
  Status: Developing

ABSTRACT

This RFC proposes to remove indirect object syntax, and modify the semantic of the -> operator.

DESCRIPTION

->

Currently,

  foo->bar($baz)

can be parsed either as <'foo'-bar($baz)>>, or as <foo()-bar($baz)>> depending on how the symbol foo was used on other places. The proposal is to always choose the first meaning: make -> autoquote the bareword on the left.

This interpretation is more desirable on esthetical ground, since

  'foo'->bar($baz)

looks visually clattered, but <foo()-bar($baz)>> looks as if it expresses its meaning. The default choice is done so that if you need other choice, your code does not look artificial.

Parentheses

  foo->bar($baz, $coon)

should be made synonymous with

  foo->bar $baz, $coon

I can see no ambiguity in this call, but it not always works with Perl5.

Indirect object syntax

Currently,

  bar foo $baz

can be parsed either as <'foo'-bar($baz)>>, or as &bar(&foo($baz)), depending on how the symbols foo and bar were used on other places.

There only way to avoid the action at a distance is to prohibit one of these interpretations. Since the other way <foo-bar $baz>> to write this method call is as convenient as the indirect object syntax, the proposal is to prohibit the indirect object method calls altogether.

Make the above syntax be interpreted as &bar(&foo($baz)).

MIGRATION ISSUES

Translate Perl5 code as specified above.

IMPLEMENTATION

Remove the DWIM logic from the parser.

REFERENCES

None.