New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return value of STORE #14835
Comments
From @vportonThis is a bug report for perl from porton@narod.ru, What is done with return value of STORE (with for example tied hashes)? What `$obj{FIELD} = 123;` returns if %obj is a tied hash? This is undocumented (not only for tied hashes, but also tied arrays, etc.) Flags: Site configuration information for perl 5.20.2: Configured by Debian Project at Fri May 15 11:27:53 UTC 2015. Summary of my perl5 (revision 5 version 20 subversion 2) configuration: Locally applied patches: @INC for perl 5.20.2: Environment for perl 5.20.2: |
From @jkeenanOn Sun Aug 02 10:08:10 2015, porton@narod.ru wrote:
Based on reading 'perldoc perltie', I would say that the return value of STORE is whatever is the return value of the method that you write to implement STORE. Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @vportonOn Sun, 2015-08-02 at 15:54 -0700, James E Keenan via RT wrote:
-- |
From @tonycozOn Sun, Aug 02, 2015 at 10:08:11AM -0700, via RT wrote:
It should return $obj{FIELD}, like any other scalar assignment. Tony |
From @vportonOn Sun, 2015-08-02 at 16:54 -0700, Tony Cook via RT wrote:
-- |
From @jkeenanOn Sun Aug 02 16:59:43 2015, porton@narod.ru wrote:
Could you submit a patch for consideration? Thank you very much. -- |
From @tonycozOn Mon, Aug 03, 2015 at 02:58:58AM +0300, Victor Porton wrote:
I'm not sure, and don't feel much need to test it. I'd expect it to
It's not as clear as it could be, and refers to the behaviour in C: Assignment operators work as in C. ... ... Unlike in C, the scalar assignment operator produces a valid lvalue. So you really need to know how a C assignment operator works to Tony |
From @iabynOn Sun, Aug 02, 2015 at 10:08:11AM -0700, via RT wrote:
It is discarded.
a key lookup of a tied hash, e.g. $obj{FIELD}, returns a temporary The scalar assign operator returns whatever was on its LHS - in this case For example in this code: $x = ($obj{FIELD} = 1); perl would call STORE() followed by FETCH(), while with this: ($obj{FIELD} = 1) = 2; STORE would be called twice. -- |
From @tonycozOn Sun Aug 02 10:08:10 2015, porton@narod.ru wrote:
The documentation for scalar STORE says: Don't worry about which implies any return value is ignored. A reader can make the reasonable assumption that applies to hash and array ties. I wonder if that could be re-worded to: Any return value from STORE is ignored; the semantic of assignment returning the and duplicated to the hash and array STORE documentation. Tony |
Migrated from rt.perl.org#125737 (status was 'open')
Searchable as RT125737$
The text was updated successfully, but these errors were encountered: