stevan/p5-mop — Issue #33: ‘Indirect’ and bareword method calls
Author: cpansprout
Created: 2011-12-14 05:27:48+00:00
State: open

How will indirect method call syntax work with classes?

There’s really nothing to stop someone from writing ‘method $obj’ with the new objects. It cannot be known at compile time whether $obj is a new-style or old-style object.

When it comes to classes, though, how should it work?

If class barewords are ‘just like’ subroutines, then `new Class` will be a syntax error.

If `Class->new` is to work before a class declaration (as in one of the examples in the docs; I brought this up in issue #30), then method calls on strings will have to work, in which case `new Class` will be permitted before the class declaration, but not afterward.

If class barewords are permitted as the invocants of indirect notation, then they won’t me ‘just like’ subroutines, yet I think everything would ‘just work’.

I suppose we can’t really decide on the above until we decide whether

```
Frog->new;
class Frog {}
```

should work, or whether it should be more like subroutines, in that it has to be declared first.

```
class Frog;
Frog->new;
class Frog {}
```

The problem with this, is that `Foo->new` is too easy to do before the class declaration. And then it would be a package method call, rather than a mop method call.