GetPropertyNames and friends should not take outparams by reference

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: jimb, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [fixed-in-tracemonkey])

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
Created attachment 476412 [details] [diff] [review]
Change GetPropertyNames to take its out-parameter by address, not by non-const reference.

When a function takes an out-parameter by reference, it makes it harder to see where things are being modified at call sites. SpiderMonkey has a policy of passing outparams by address. GetPropertyNames and the various function templates that implement it do not follow this convention.

The new 'fix' js::ObjectOps member for bug 492849 should not propagate this error.
(Reporter)

Updated

7 years ago
Attachment #476412 - Flags: review?(brendan)
(Reporter)

Updated

7 years ago
Blocks: 492849
Comment on attachment 476412 [details] [diff] [review]
Change GetPropertyNames to take its out-parameter by address, not by non-const reference.

Thanks, for some reason I let this pass, even though I'm the grumpy grandpa of "non-const-refs for out/inout params considered harmful". Gotta stay grumpy!

/be
Attachment #476412 - Flags: review?(brendan) → review+
(Reporter)

Comment 2

7 years ago
Nothing grumpy about it. For what it's worth, that convention is part of the Google C++ style as well. Pretty operator-overloading-based domain-specific languages are perhaps an exception.
When I first loaded cfront 0.9 off magtape in 1985, it was clear that operators (complex, the canonical example) were the strong motivation for mutable reference parameters.

/be
(Reporter)

Comment 4

7 years ago
http://hg.mozilla.org/tracemonkey/rev/118c067aa766
(Reporter)

Updated

7 years ago
Whiteboard: [fixed-in-tracemonkey]

Comment 5

7 years ago
http://hg.mozilla.org/mozilla-central/rev/118c067aa766
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.