Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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?
[Discipulus]: ;=)
[Discipulus]: you are rigth: 2018 had less bad days than 2017, until now!
[Discipulus]: if i had to go to psycho i need to ask why i always end with over complex datastructure: now i have an HoHoAoH in my object
[Discipulus]: i will need to handle by reference later on
[Eily]: kinda sounds like father Christmas is late
[hippo]: (asking because I'm sure you said before about learning English) Did you know there are 2 different words for smaller quantities in English? They are "less" and "fewer". Fewer applies to a number of discrete things like days.
Eily notes also
[hippo]: So if you don't drink as much milk and not as often you are said to drink less milk on fewer days. Confusing, eh?

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-01-23 09:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (242 votes). Check out past polls.

    Notices?