ObjectiveCVerbalExpressions icon indicating copy to clipboard operation
ObjectiveCVerbalExpressions copied to clipboard

Removed all javascript-like functionality and syntax. This is Objective ...

Open jonusx opened this issue 12 years ago • 9 comments

This is Objective C, not javascript.

jonusx avatar Aug 12 '13 17:08 jonusx

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.

kishikawakatsumi avatar Aug 12 '13 19:08 kishikawakatsumi

Could you please refer to this discussion also. => https://github.com/VerbalExpressions/JSVerbalExpressions/issues/44

kishikawakatsumi avatar Aug 12 '13 19:08 kishikawakatsumi

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.

jonusx avatar Aug 12 '13 19:08 jonusx

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.

Tonkpils avatar Aug 13 '13 13:08 Tonkpils

I agree that the syntax in the PR looks much better as part of an objective-c codebase.

nilsou avatar Aug 20 '13 14:08 nilsou

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.

zakdances avatar Sep 08 '13 01:09 zakdances

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?

zakdances avatar Sep 08 '13 04:09 zakdances

I really like the ReactiveCocoa-style, but why not just support both syntaxes?

maxsz avatar Sep 09 '13 07:09 maxsz

+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!

alexmnps avatar Jan 31 '14 12:01 alexmnps