ObjectiveCVerbalExpressions
ObjectiveCVerbalExpressions copied to clipboard
Removed all javascript-like functionality and syntax. This is Objective ...
This is Objective C, not javascript.
Thanks for the suggestion.
But I think that VerbalExpressions is like a DSL for building Regexps.
This is not the same as the conventional Objective-C.
It is not necessary to express in Objective-C in exchange for the writability and readability.
I was also trying to write in conventional Objective-C first. However, Objective-C was unsuitable for method chaining.
The pros of VerbalExpressions is writability and readability.
I think it is a better way to use dot syntax.
Could you please refer to this discussion also. => https://github.com/VerbalExpressions/JSVerbalExpressions/issues/44
Writability and readability? Not if you're a native Obj-C developer. Here at work, we were pretty saddened by the code.
On Aug 12, 2013, at 3:07 PM, kishikawa katsumi <[email protected]mailto:[email protected]> wrote:
Thanks for the suggestion.
But I think that VerbalExpressions is like a DSL for building Regexps. This is not the same as the conventional Objective-C. It is not necessary to express in Objective-C in exchange for the writability and readability.
I was also trying to write in conventional Objective-C first. However, Objective-C was unsuitable for method chaining.
The pros of VerbalExpressions is writability and readability. I think it is a better way to use dot syntax.
— Reply to this email directly or view it on GitHubhttps://github.com/VerbalExpressions/ObjectiveCVerbalExpressions/pull/3#issuecomment-22517129.
I agree with @jonusx. If you're writing code for a specific language and it looks like another then what's the point? I think there's enough Javascript to go around. A library written for Objective-C developers should follow Objective-C conventions not be a JS look-alike. I looked at the PR and it actually looks and feels a lot better of an Objective-C person.
OCVerbalExpression *expressions = [[OCVerbalExpression alloc] init];
[expressions startOfLine:YES];
[expressions then:@"http"];
[expressions maybe:@"s"];
[expressions then:@"://"];
[expressions maybe:@"www"];
[expressions anythingBut:@" "];
[expressions endOfLine:YES];
vs JS
// Create an example of how to test for correctly formed URLs
VerbalExpressions *tester = VerEx()
.startOfLine(YES)
.then(@"http")
.maybe(@"s")
.then(@"://")
.maybe(@"www")
.anythingBut(@" ")
.endOfLine(YES);
I'd actually find the first one a lot easier to understand if I'm sunk deep into Objective-C code.
I agree that the syntax in the PR looks much better as part of an objective-c codebase.
I agree with the pull request. In an Objective-C context, anything that tries to look like JavaScript (especially functions) just ends up looking like C.
By the way, if you want to chain there is a much better way of doing it in Objective-C then trying to ape JavaScript. Take a look at how ReactiveCocoa does it. Example:
VerbalExpressions *expressions = [[[[[
[VerbalExpressions new]
startOfLine:YES]
then:@"http"]
maybe:@"s"]
then(@"://")]
endOfLine:YES];
@kishikawakatsumi How about using this syntax?
I really like the ReactiveCocoa-style, but why not just support both syntaxes?
+1 for supporting multiple syntaxes. I happen to like the block-based one, it's much easier to type compared to the ReactiveCocoa-syntax with all the [[[[[[[[[[[...
Implementation-wise: smart usage of those @property blocks!