Autogenerate convenience functions for options #14466

Closed
staticfloat opened this Issue Aug 26, 2012 · 3 comments

Projects

None yet

3 participants

@staticfloat
Contributor

My fingers are lazy, so rather than write the boiler plate of a function like:

def myoption?
  build.include? 'with-myoption'
end

to save my fingers the work of typing build.include? 'with-myoption' every time, I thought I could work some define_method magic inside of the option method and have it auto-generate methods for options, so that if the user codes in option "with-dep" they can immediately say dep? (Or if we don't want to specialize on with-xyz options, the auto-generated function could have a name like with_xyz?)

What do you guys think? I'm going to wait until JackNagels dependency improvements have landed so I can build on top of those and hopefully get the automatic options generated by dependencies also having their own convenience functions.

@adamv
Contributor
adamv commented Aug 26, 2012

I'm -1 on this, and would rather wait until "features" are implemented, after the options improvements.

We could then autogenerate build.with.feature? and build.without.feature? methods.

@jacknagel
Contributor

I actually have this implemented in a private branch, but have been holding off (a) to let the recent options API stabilize and (b) for the reasons @adamv mentioned above.

@staticfloat
Contributor

Cool, thanks guys. I'll just close this then as you have it under control. I hope both these features land soon, they're really great!

@xu-cheng xu-cheng locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.