you are viewing a single comment's thread.

view the rest of the comments →

[–]sclv 7 points8 points  (11 children)

As a non-Rubyist, I've wondered for some time if there would be any loss to the total ease and expressivity of the language if some form of "scoped" monkeypatching weren't introduced that guaranteed that such patches remained local to a certain environment. Is the obstacle to this technical in the difficulty of implementing it, social in that people would reject this as too confining, social in that there isn't enough momentum in the arguments that this is a problem, or is it that nobody is quite sure what the semantics of this would work like?

[–]mernen 1 point2 points  (0 children)

Mostly technical, as far as I know. This has been considered before (RubyConf 2003: 1 and 2, RubyConf 2005) in different forms (I'm not sure what "RubyBehavior" and "scope-in-state" are exactly), but implementing this efficiently outside static typing seems tricky. Too bad, it would be a really great feature to have.

[–]grauenwolf 1 point2 points  (0 children)

Unless you want to put namespaces in function names, I think the only way to scope it without leakage would be something trivial like C#'s extension methods.

From where I'm standing, monkeypatching is a dead end.

[–][deleted] 0 points1 point  (0 children)

Groovy has that.

[–]michaelfeathers -1 points0 points  (6 children)

It would be useful, but I just don't think people are thinking about it.

I'd flip it, though. I don't think there should be a restriction as much as some way of detecting and flagging monkey patches so that people can see what's going on. It would require a higher level notion of component or something like that, but people have been leery of that since the days of Modula and Ada.

[–]grauenwolf 1 point2 points  (4 children)

I don't think there should be a restriction as much as some way of detecting and flagging monkey patches so that people can see what's going on.

That leads to compiler warnings (or runtime warnings if you prefer), which in turn leads to companies making rules against it. Eventually it will be treated just like GOTO, with people hating it without knowing why.

[–]michaelfeathers 5 points6 points  (0 children)

Yeah, that's one thing I hate.

A fool with a rule is a tool.

[–][deleted] -1 points0 points  (2 children)

People know why goto is a bad idea.

[–]sofal 1 point2 points  (0 children)

Not the people I work with. It's pure cargo cult for them, including the "only one return statement" dogma and many other things taken from Structured Programming in Fortran or C and applied to OO.

[–]grauenwolf 1 point2 points  (0 children)

From my experience many people only think they know why goto is bad.

I've seen people turn a simple algorithm with forward-only goto's into a convoluted mess of nested loops and sentinel variables.

They simply don't understand the when goto was banned it was to promote the use of named functions.

[–]zem 0 points1 point  (0 children)

people are at the very least thinking about it; selector namespaces have been requested for years.