On Wednesday, November 26, 2003, at 12:13 PM, chromatic wrote:


On Wed, 2003-11-26 at 11:39, Michael Lazzaro wrote:

I think we also need to be skeptical of the false economy of putting
such sugar into CP6AN, if a sizable portion of the community is going
to download it anyway.

A more interesting question is *when* to put something into the core language or libraries.

Consider Perl 5, where File::Find is a core module. While the interface
may have been nice in 1995 (though I doubt even that), it's been widely
regarded as awful for at least three years. It's likely never to be
removed from the core. File::Find::Rule is immensely nicer.

Agreed, but I hope I made it clear I was talking about a different level of beast -- a bit of pure syntactic/semantic sugar that rests solely upon other core things, not a bit of extended functionality. File::Find is an excellent example of something that wouldn't belong in core because it does not represent the Only Good Way To Do It. You can think of plenty of valid interfaces to something as complex as a File::Find-like module, and each would have vigorous supporters.


I'm talking about things on the level of, for example, C<unless>. I can say:

        foo() if not $a;
or
        foo() unless $a;

The presence of C<unless> in the language, functionality-wise, is utterly meaningless; it adds nothing aside from a very slight but useful linguistic nuance. I wager most of us regularly use both C<if not> and C<unless> now, interspersed liberally, depending on what precisely we are trying to convey. We could be trained to always say C<if not>, however, and eliminating it from P6 would save a keyword.

But it would be a hollow savings; nobody would realistically then use a func/method/op/whatever called 'unless' in their code -- and if they did use it, it would almost certainly be to produce a behavior identical to the existing functionality.


Similarly, the much-needed new C<//> operator:


        my $c = $a // $b;
or
        my $c = (defined($a) ? $a : $b);

Again, a functionally meaningless bit of fluff which exists solely to provide a simpler visual reading of a ridiculously common construct. It could be eliminated easily; to do so would be an overall loss. Ditto ==>, or even C<map>/C<grep>.

When I use the term 'sugar', it is things of this level of primitiveness that I mean to convey.

MikeL



Reply via email to