-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DSL vs. method chaining? #4
Comments
Not that I'm advocating one way over the other, but using method chaining instead of using a block would allow to use reserved words such as "then", "or" and so on. |
Using a DSL inside a block is more Ruby-like though. |
DSLs have indeed become an inherent part of Ruby culture and I don't want to sound like I'm DSL-bashing, but I'm not sure if I'd agree that a DSL inside a block is more Ruby-like than method chaining. Using DSLs is a programming pattern that the community has adopted due to the ease of implementation in the language, whereas method chaining is a built-in feature of the language. |
I did originally use the DSL because it felt more Rubyist, but I think that the decision could be revisited. @jgabrielygalan, that's another valid point I hadn't considered. It would be nice to have the reserved words. @joem, As far as keeping up with the other versions, most of the implementation stays the same (besides the reserved words). After the initial DSL setup, everything was ported line-by-line. With a few slight modifications, it could be made to work with chaining or the DSL, but I'm not sure that's what we should do. The DSL also offers some extra benefits. For example, it makes the I feel like the DSL is cleaner and fits better for a Ruby library, but that's just my personal opinion. |
Hey, just for fun, I tried implementing a method chaining VerEx Ruby package. It's only one file and not by any means complete, May have many bugs, but still passes the URL testing example on the README. |
@saivineet89, very cool! You actually may be able to tweak the existing library to make it work with chaining and then everything else will work the same. |
@ryan-endacott , Thanks :) |
Now both DSL and method chaining are supported(I've only tested the URL test on README and it works :) |
This isn't so much an 'issue' as it simply 'something to consider':
I noticed that this is one of the only (if not the only) implementation listed on the organization page that doesn't use method chaining for the
start_of_line()
,find()
,maybe()
, etc. methods...I wonder if it might be better to follow the original's method chaining strategy instead of this DSL approach? I'm pretty sure there are things possible with method chaining that you can't do with the DSL (although admittedly I'm not sure if any of it's actually useful). Also, it might make it easier to translate and keep up with any possible changes to the other versions if it were more closely following their implementations.
What's your take?
The text was updated successfully, but these errors were encountered: