in reply to Re: Re: Perl6 headaches?
in thread Perl6 headaches?

The dot operator

I used to think that replacing -> with . sucked big time, until I read Piers Cawley's article about Perl 6. Now I have learned to stop worrying and love the dot. It's sort of like Visual Basic's with block. Instead of

$self->{foo} = $self->bar ? 10 : $self->rat * 10;

one instead writes

$.foo = .bar ? 10 : .rat * 10;

Although IIRC, that should be ?? and :: for the ternary conditional operator. Such considerations aside, the succinctness of the dot approach far outweighs the arrow approach (which, it should be remembered, was itself a vast improvement over the apostrophe operator). Your surely agree with me when I say

$->foo = ->bar ? 10 : ->rat * 10;

looks... odd. That's reason enough for me to go with the dot approach.

The underscore operator

I do think that requiring whitespace around the underscore operator is a bit of a design wart caused by exhaustion of the ASCII character set. Which means that there's not a lot you can do about it.

In a Unicode environment, I imagine it would be preferable to define a specific operator that doesn't require whitespace disambiguation. I think a small ring character like on a Swedish A would be pretty cool. But if you're not Unicode pure then I guess you're out of luck.

--
g r i n d e r

Replies are listed 'Best First'.
Re: Rex3: Perl6 headaches?
by japhy (Canon) on Nov 05, 2001 at 03:49 UTC
    The case of the underscore operator is not the first time Perl has been dependent on whitespace, by the way. And I like it, too -- you should notice that the underscore acts like a line connecting its two operands. Connecting... concatenating... something like that.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      Oh, I can live with the underscore operator, as I am believe in drenching my code with whitespace, and yes, I had seen the connector metaphor in the character.

      That said, sometimes, for a higher purpose, you have to scrunch code up. Concatenating is a pretty heavily used operator (at least for me), so it's bound to run into this constraint more sooner than later. And that bothers me a bit. Not much. I'll just probably change my style and interpolate into strings more.

      --
      g r i n d e r