Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: •Re: Why get() and set() accessor methods are evil

by sth (Priest)
on Nov 26, 2003 at 19:00 UTC ( #310350=note: print w/ replies, xml ) Need Help??


in reply to Re: •Re: Why get() and set() accessor methods are evil
in thread Why get() and set() accessor methods are evil

...but not as nice as a->set_b(12). :-)
...I know, I know arrow notaion is going away in Perl6. :-(


Comment on Re: Re: •Re: Why get() and set() accessor methods are evil
Replies are listed 'Best First'.
Re(4): Arrow Notation, structs and Perl 6 (Why get() and set() ...)
by Ovid (Cardinal) on Nov 26, 2003 at 19:16 UTC

    You seem disappointed that the arrow notation is going away. Personally, I think this is a Good Thing. Aside from the fact that it will mean less typing for common things, it's a holdover from the old days of C. In C, a struct's members could be accessed with dot notation:

    typedef struct { double x double y; } POINT; POINT some_point; /* and later in the code */ some_point.x = 1.02;

    However, if you later had passed a pointer to a struct, you would access the struct members with arrow notation:

      some_point->x = 1.02

    Since Perl was largely designed to be familiar to C programmers, having an arrow to dereference things seemed fine. However, Perl 6 seemingly is intended to be familiar to a larger audience (in some ways), it makes sense to drop the C style arrow notation in favor of the dot notation that popular languages use.

    And just to keep things topical, by using the arrow notation, we may be encouraging C programmers to use objects like structs and that's just silly. Which is kind of the point of much of this thread :)

    Cheers,
    Ovid

    New address of my CGI Course.

      Perl 6 seemingly is intended to be familiar to a larger audience (in some ways)

      Agreed, but I will still miss them. I prefer the -> over the . notation in C as well. Much of the C code I work with pass around lots of structures, between that and hash refs I am so used to typing -> I don't mind it. I understand why they are changing, it will still be a hard habbit to break. :-)

Re: Re: Re: •Re: Why get() and set() accessor methods are evil
by Elian (Parson) on Nov 26, 2003 at 19:12 UTC
    Nah. a[insert method call punctuation here]set_b(foo) is just nasty. If it's supposed to be an assignment it should look like an assignment, and setting a property or attribute is an assignment no matter how it's mediated under the hood.

    One of the few places (well, OK, the only place so far, but I won't rule out others existing) that I like lvalue methods or subs.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2015-07-29 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls