Closed Bug 584082 Opened 14 years ago Closed 14 years ago

Narcissus: eliminate uses of ==

Categories

(Other Applications Graveyard :: Narcissus, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: dherman, Assigned: dherman)

References

Details

Attachments

(1 file, 1 obsolete file)

We should use ===, which is clearer and less error-masking than ==, everywhere in the Narcissus codebase.

Dave
Channeling crock, or just running JSLint?

I intentionally use == where types are the same, since it's equivalent to ===. But maybe this is too fragile -- is there a bug?

/be
I agree with crock on this one, but not necessarily because it lets me tut-tut about JavaScript. It's just that, if we aren't using the extra functionality of ==, it's misleading to the reader -- why use the more powerful operation when you aren't using its power? Principle of least power or whatever you call it.

Dave
(South Park voice:) They got Dave -- bastards!

;-)

/be
I'll take the ribbing, but seriously: DWIM is rarely WIM, and if you don't even intend to be using it, you're taking the risk of silently masking bugs. No need to raise the spooky spectre of security, it's just better preparation for when bugs happen.

Dave
Assignee: general → nobody
Component: JavaScript Engine → Narcissus
Product: Core → Other Applications
QA Contact: general → narcissus
Keywords: narcissus
Blocks: 584777
This patch eliminates all uses of == and != except for the part where the evaluator is interpreting those operators. There's a spot where the original code used |== null| to check for either null or undefined, and I've replaced that with the more explicit two checks, using ===.

Dave
Assignee: nobody → dherman
Attachment #463743 - Flags: review?(pwalton)
r=me

Note that I prefer "foo == null" to "foo === null || foo === undefined", but I don't have really strong opinions either way.
Attachment #463743 - Flags: review?(pwalton) → review+
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
(In reply to comment #6)
> r=me
> 
> Note that I prefer "foo == null" to "foo === null || foo === undefined", but I
> don't have really strong opinions either way.

Yeah, this is another case where I used == intentionally (and still will in my own JS hacking). Slightly more economical and efficient, but maybe confusing to JS hackers who don't know the mysteries of ==, or who would prefer to forget.

/be
Attached patch Missed one test in jsexec (obsolete) — Splinter Review
Attachment #465439 - Flags: review?(pwalton)
Missed one! Patch attached.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Best to file a followup bug, or just fix it without a bug if you are cheeky. Reopening when there was not a back-out makes for a confusing audit trail.

/be
Sorry, didn't know about that protocol. WIll open a new bug.
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Attachment #465439 - Attachment is obsolete: true
Attachment #465439 - Flags: review?(pwalton)
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: