Summary: | is* API methods should be @properties | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Geoffrey Garen <ggaren> | ||||
Component: | New Bugs | Assignee: | Geoffrey Garen <ggaren> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | joepeck | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Attachments: |
|
Description
Geoffrey Garen
2015-04-03 14:54:12 PDT
Created attachment 250100 [details]
Patch
Comment on attachment 250100 [details]
Patch
r=me
Comment on attachment 250100 [details]
Patch
What about code that use the old idioms? Isn't there a binary compatibility issue?
> 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.
Committed r182336: <http://trac.webkit.org/changeset/182336> 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. > 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. > > @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 =)
> The "object.array" would not have existed, it still produces
> "object.isArray".
Hmmm... not even in Swift?
(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. |