Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl6 headaches?

by wog (Curate)
on Nov 04, 2001 at 08:37 UTC ( #123133=note: print w/replies, xml ) Need Help??


in reply to Perl6 headaches?

By logical conclusion, this will mean that they are no longer valid in variable names

From the looks of the discussion right now this is not true. You will need to disambiguate that the _ is not part of a variable name with whitespace. So: my $baz = $foo_bar.$bar_foo becomes my $baz = $foo_bar _ $bar_foo. The whitespace on the left side of the _ is not optional.

update: s/around/on the left side of/

Replies are listed 'Best First'.
Re: Re: Perl6 headaches?
by mattg (Novice) on Nov 04, 2001 at 10:59 UTC
    I was hoping someone would have some good news, but I still don't see the point in changing Perl's syntax for the sake of (cheesy) dot syntax for method calls. I will assume that the powers that be that are working on Perl6 have good reasons, but as I stated, it just seems like an attempt to make Perl more friendly to java(script) programmers. From what I gleaned from the article (which obviously had some holes) underscores are replacing periods for concatenating and periods are replacing the arrow operator. So, again, to what end? Change and innovation is (almost) always good, but needless change???

    matt

      If we want to make Perl more attractive for people from OTHER languages, we need to compromise. Many other languages use the obj.method syntax, so why shouldn't Perl? The reason Perl doesn't is because we never had objects until recently, and we've had string concatenation for a long long time.

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

      A reply falls below the community's threshold of quality. You may see it by logging in.

      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
        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:??;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://123133]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2022-12-07 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?