in reply to Noble DOT vs the Allmighty ARROW

My background is C, where the dot refers to an object attribute (or for non-OO folks, a structure element). Hmm. Let me explain better.
typedef struct foo { int iNumberOfHands; char *pszPlayerName; } PLAYER, *PTR_PLAYER; PLAYER astrScoundrels[]; PTR_PLAYER pstrThisPlayer;
This code defines a structure in C with two elements, and also defines types for an instance of the structure (PLAYER) and a pointer to a structure (PTR_PLAYER).

The type definitions are used to created an array of players and a pointer to a player. After all that, you use pstrThisPlayer->iNumberOfHands to get to a structure element using a pointer, and astrPlayer[2].iNumberOfHands to get to the same structure element using the structure itself.

Currently in Perl (there, you knew it was coming eventually), we use the arrow to refer to an object's attributes or members like

$Query = new CGI; $Value = $Query->param('foo'); # method call
In reality, $Query is an object and not a pointer to an object, so we should be using the dot syntax. Therefore, in Perl 6, we will be writing
$Query = new CGI; $Value = $Query.param('foo'); # method call
This is what C used all along, so going to the dot syntax is more othogonal. Or better. :)

--t. alex

"Nyahhh (munch, munch) What's up, Doc?" --Bugs Bunny

ps Good question.

Replies are listed 'Best First'.
Re: Re: Noble DOT vs the Allmighty ARROW
by demerphq (Chancellor) on May 08, 2002 at 14:23 UTC
    A quick thought but the dot is hardly unique to C. I wouldnt be suprised to discover it actually comes from ALGOL which (iirc) is higher up in both C and PASCAL's family trees.

    Even if it isnt, it certainly has been part of PASCAL, Modula-2, C, C++, JAVA, VB and a whole host of other languages.

    OTOH, I dont think ill like doing

    my $s=sub{}; $s.();
    Hmm, come to think of it what will be the syntax for dereferencing a CODE ref? The above cant be right can it?

    Yves / DeMerphq
    ---
    Writing a good benchmark isnt as easy as it might look.

      Hmm, come to think of it what will be the syntax for dereferencing a CODE ref?
      According to a recent article in the TPJ Magazine by TheDamian it will look something like this
      my $anonsub = sub { ... }; $anonsub(@args);

      HTH

      _________
      broquaint