Perl-Apollo / Corinna

Corinna - Bring Modern OO to the Core of Perl
Artistic License 2.0
156 stars 19 forks source link

RFC/Attributes: Too much magic in the "handles" example #51

Closed HaraldJoerg closed 2 years ago

HaraldJoerg commented 2 years ago

The example for :handles reads:

use DateTime;
slot $datetime :handles(now, today) = 'DateTime';

From what has been described so far, this initializes $datetime to the scalar string 'DateTime' which is not an object. now and today are class methods of the DateTime module, so it looks weird to wire them to an instance slot.

I don't think this is a good first example to illustrate the :handles() attribute. Even if it sorta works because 'DateTime'->now works, it should be documented as a special case where the presence of :handles() implies that the initializer is a class name.

Ovid commented 2 years ago

For now, I believe we've decided that :handles(...) will not be included in V1. This may be revisited in the future.