On Jul 16, 2004, at 4:35 PM, John Siracusa wrote:

As for this:

    $obj->start_date(format => '%B %d %Y at %T')

being nothing more than syntactic sugar for this:

$obj->start_date->strftime('%B %d %Y at %T')

Yes, that's my argument against it. And it's why dates are such a PITA in Bricolage.

the first one gives me a bit more flexibility if, say, I decide to add new
format specifiers. As it turns out, that's just what I did, and I didn't
end up with a mix of "old style" $obj->start_date->strftime(...) calls and
"new style" $obj->start_date(format => ...) calls when I did it.

I would have subclasses DateTime to add the new format specifiers.

But honestly, 99.9% of my get/set methods don't take any args in the "get"
case. I really, really like the cleanliness of using the same method name
for both. The only thing that bothers me at all is the runtime overhead of
arg checking, but as I mentioned before, even that will go away when
efficient multimethod dispatch arrives in Perl 6.

Yes, this is the thing. Two methods are actually a lighter weight at run time than one. But I too like having a single method, as it fees much more like I'm using an attribute than a method.

In the "date" get/set case in Perl 6, I'd have 3 methods with the same name
but three different signatures: "no args", "named args", and "a single
string arg") Sorry if I can't recall the Perl 6 signature syntax off the
top of my head... ;)

Mmmm...multimethods. :-)

David

Attachment: smime.p7s
Description: S/MIME cryptographic signature



Reply via email to