Bug 143388 - is* API methods should be @properties
Summary: is* API methods should be @properties
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-03 14:54 PDT by Geoffrey Garen
Modified: 2015-04-07 10:46 PDT (History)
1 user (show)

See Also:


Attachments
Patch (13.82 KB, patch)
2015-04-03 14:55 PDT, Geoffrey Garen
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2015-04-03 14:54:12 PDT
is* API methods should be @properties
Comment 1 Geoffrey Garen 2015-04-03 14:55:34 PDT
Created attachment 250100 [details]
Patch
Comment 2 Mark Lam 2015-04-03 15:12:23 PDT
Comment on attachment 250100 [details]
Patch

r=me
Comment 3 Michael Saboff 2015-04-03 15:15:27 PDT
Comment on attachment 250100 [details]
Patch

What about code that use the old idioms?  Isn't there a binary compatibility issue?
Comment 4 Geoffrey Garen 2015-04-03 15:18:37 PDT
> What about code that use the old idioms?  Isn't there a binary compatibility
> issue?

The Objective-C language generates method implementations for @property's, so old code that uses method invocation syntax still works.
Comment 5 Geoffrey Garen 2015-04-03 15:18:54 PDT
Committed r182336: <http://trac.webkit.org/changeset/182336>
Comment 6 Joseph Pecoraro 2015-04-04 10:55:59 PDT
Comment on attachment 250100 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250100&action=review

> Source/JavaScriptCore/API/JSValue.h:383
> -- (BOOL)isUndefined;
> +@property (readonly) BOOL isUndefined;

I think ObjC convention would be to not include "is" in the property name, but specify it in the getter, like:
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//apple_ref/doc/uid/TP40011210-CH5-SW1

    @property (readonly, getter=isUndefined) undefined;

That said, I'm not sure if these are exceptional cases because of their names.
Comment 7 Geoffrey Garen 2015-04-06 11:05:30 PDT
> I think ObjC convention would be to not include "is" in the property name,
> but specify it in the getter, like:
> https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/
> ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//
> apple_ref/doc/uid/TP40011210-CH5-SW1

Yes, that is often true of properties.

>     @property (readonly, getter=isUndefined) undefined;
> 
> That said, I'm not sure if these are exceptional cases because of their
> names.

The consensus among some experts was that these properties were special because a property like "object.array" (as opposed to "object.isArray") might be expected to produce or consume an array, which is not what these properties do.
Comment 8 Joseph Pecoraro 2015-04-06 12:17:33 PDT
> >     @property (readonly, getter=isUndefined) undefined;
> > 
> > That said, I'm not sure if these are exceptional cases because of their
> > names.
> 
> The consensus among some experts was that these properties were special
> because a property like "object.array" (as opposed to "object.isArray")
> might be expected to produce or consume an array, which is not what these
> properties do.

The "object.array" would not have existed, it still produces "object.isArray". That said, since it is readonly, I think what you have reads better anyways. In the end it all amounts to the same thing =)
Comment 9 Geoffrey Garen 2015-04-06 13:36:35 PDT
> The "object.array" would not have existed, it still produces
> "object.isArray".

Hmmm... not even in Swift?
Comment 10 Joseph Pecoraro 2015-04-07 10:46:00 PDT
(In reply to comment #9)
> > The "object.array" would not have existed, it still produces
> > "object.isArray".
> 
> Hmmm... not even in Swift?

Good point, I didn't think about Swift! I assumed it would respect "getter=" but after looking at some examples online, it looks like it doesn't.