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.
The example for :handles reads:
From what has been described so far, this initializes
$datetime
to the scalar string'DateTime'
which is not an object.now
andtoday
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.