http://www.perlmonks.org?node_id=848351


in reply to Re^2: Modern Perl: The Book: The Draft
in thread Modern Perl: The Book: The Draft

Could it be that you and Anonymous Monk made the same mistake as I did initially of reading the example as if age() was meant as a read-only function?

As I understand the example, age() is a write-only(!) function, you set the time you want to stow away the cheese in a dark cellar (or you simply stow away the cheese a predetermined time). The following sentence in the book makes that quite clear I think. So 'ascertain' would be exactly the wrong meaning, suggesting reading of a stored value.

If I'm right, you made my point ;-). And in any case thanks for the compliment.

PS: If I'm right, the second age() call in the example following the cheese paragraph should have a parameter of "6", "6m" or "6 months"

Replies are listed 'Best First'.
Re^4: Modern Perl: The Book: The Draft
by ww (Archbishop) on Jul 07, 2010 at 01:37 UTC
    /me headslaps self.

    In fact, jethro's take is far more plausible than the view behind my dissent.

    From the times of two postings on the topic by an Anonymonk, the content of the direct reply to jethro's node seems to be a retraction of Re^2: Modern Perl: The Book: The Draft... but the notion of age() as a mutator does fit the fact that aging cheese changes (mutates) its character. :-)

    Thus, a re-dissent on that tangential matter: IMO, 6 months is singularly inadequate for sharp! cheddar; far better 12 ...or even, as some of our Wisconsinites pride themselves on doing, for 12 years or more. But, that re-dissent is posited on the notion that the methods used by those in America's dairyland as determined by empirical testing.

    ++ again, jethro

      as a mutator does fit the fact that aging cheese changes (mutates) its character. :-)

      It also makes the cheese unavailable for sale, since it is in storage :)

        1. Sell no cheese before its time (aged).
        2. No, it's in process (mutating).
        3. Are the feds still offering price supports; stockpiling cheese for school lunches?
        4. ...
Re^4: Modern Perl: The Book: The Draft
by Anonymous Monk on Jul 07, 2010 at 00:54 UTC
    I made the mistake of not looking at the paragraph and associated code.
    Of course, the mere existence of a method called name() or age() does not by itself imply the behavior of that object. A Dog object may have an age() which is an accessor such that you can discover $rodney is 8 but $lucky is 3. A Cheese object may have an age() method that lets you determine how long to stow $cheddar so that it becomes sharp; in other words, age() may be an accessor in one class but not in another:
    # how old is the cat? my $years = $zeppie->age(); # store the cheese in the warehouse for six months $cheese->age();
    I would lose the code and change the sentence to
    A Cheese object may have an age() method that stores the cheese in the warehouse for six months; in other words, age() may be an accessor in one class but a mutator in another.