On Tue, Apr 05, 2005 at 09:36:18AM +0300, wolverian wrote:
: (Replying to p6l instead of p6c as requested.)
: 
: On Mon, Apr 04, 2005 at 10:39:16AM -0700, Larry Wall wrote:
: > (Now that builtins are just functions out in * space, we can probably
: > afford to throw a few more convenience functions out there for common
: > operations like word splitting and whitespace trimming.  (Specific
: > proposals to p6l please.))
: 
: Shouldn't these be just methods? 

Depends on whether part of the "convenience" consists of coercing
the argument to a string in the first place.  In all likelihood these
would be multimethods with a single definition, so that if you did
add other definitions of words() or trim(), it would use MMD to try
to figure out which way you probably wanted it coerced.

Plus you really don't want to clutter the Str type with every little
thing you might want to do with a string.  "foo".open() will probably
work, but only because it doesn't find a Str.open and fails over to
MMD dispatch, which ends up finding a filehandle constructor.

But suppose words() were a singular multimethod.  If you said

    words(@array)

it would call &words<Str>, which would (I hope, since arrays know
about string context) coerce @array to a string with ' ' between the
elements, and then split that string into words.  But some people might
prefer that to fail, and force people to use

    words([EMAIL PROTECTED])
    words("@array")

Maybe there's a pragma that lets you control how much coercion happens.

Larry

Reply via email to