On Oct 16, 2009, at 7:19 PM, Markus Roberts wrote: > > Is there a path that allows us to get rid of the idiom you hate but > > retains the usefulness of -w? > > Initialize the variables? That's why the warning is there. It's > essentially a carryover from languages that want you to declare all > your variables, and the proper way to respect the convention is to > effectively do just that: list them in he initializer with their > starting values. > > If we don't want to rely on ruby's semantics for uninitialized > variables, we should initialize them. If we do want to use it we > should use it, rather than reimplementing it.
I guess I just think that's a bigger code smell - you have accessors that handle every other direct access to the variable, but then you have this lone initializer that also does direct access. It seems cleaner to have a mixin that providers attr_accessor-like behaviour but with an initializer method for unitialized variables: attribute(:foo) do ...this is the initializer code end But that's probably working too hard. Although, I've wanted something akin to the 'traits' functionality that Ara T. Howard has provided, which would make default values and all that kind of stuff really easy, so it might be worth it overall. > > Other than this one warning, I think ruby -w is useful, and I would > prefer that our code not throw warnings. > > As a side issue, do we want to deal with all the warnings the code > presently throws if you run it -w (I'm not advocating this, just > raising the question). Spot checking, it looks like some of them > have been there for several years. > > I guess my point is, I don't think ruby -w is useful, or at least > it's warnigs should be taken with a big grain of salt. It warns on > too many things (default variable initialization, redefining > methods, etc.) that seemed like they should generate warnings to the > C-programmers who wrote ruby but are now, going on fifteen years > later, seen as good sound idiomatic ruby. I actually think redefining methods is a very useful warning, and I've tried to get rid of them when I notice them - I've certainly found a couple of bugs that way. -- There are no such things as applied sciences, only applications of science. -- Louis Pasteur --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
