in reply to 'Set' Method Return Value

  1. Nothing to add but an example: select FH uses this, since one often wants to re-select the originally selected file handle.

  2. I don't buy the rationale you gave for this method. The caller should not have to do integrity checks. The rationale for this one is probably for consistency with $b = $a = $val.

    This method is also useful when you want to provide a single method for setting and getting. For example, $cypher->iv($iv); and $iv = $cypher->iv();.

  3. This method can improve readability. A common alternative is a constructor that accepts a list (or a reference to a hash) of options.

However, I beg to differ on their ability to indicate success. None of these are particulary good at indicating success, because none of these are particulary good at indicating failure.
  1. Without limiting the values that can be used as parameters, the return value cannot be used to indicate failure. Some other means of indicating failure (such as exceptions) is necessary.

  2. Checking for failure entails check checking if the return value is different than the parameter's value. This could entail having to use a temporary variable, and checking if two things are equal can be very tricky depending on what kind of things make accesptable parameter. In short, some other means of indicating success (such as exceptions) would be preferable.

  3. In this case, a false value could be returned on failure, but that would cancel out the entire benefit of this method. If the function can return undef, one can no longer chain calls, since one would have to check the return value. It would be safer to just return 1 for success and undef for failure.