[#50466] [ruby-trunk - Bug #7492][Open] Segmentation fault at DL::TestDL#test_call_double on x64 Windows 8 — "phasis68 (Heesob Park)" <phasis@...>

23 messages 2012/12/02

[#50558] [ruby-trunk - Feature #7511][Open] short-circuiting logical implication operator — "rits (First Last)" <redmine@...>

12 messages 2012/12/04

[#50575] [ruby-trunk - Feature #7517][Open] Fixnum::MIN,MAX — "matz (Yukihiro Matsumoto)" <matz@...>

20 messages 2012/12/05

[#50755] Becoming a committer — Charlie Somerville <charlie@...>

Hi ruby-core,

21 messages 2012/12/11
[#50759] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50784] Re: Becoming a committer — Charles Oliver Nutter <headius@...> 2012/12/11

It's really this easy? If so, I'll send over my public key today :)

[#50795] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50806] [ruby-trunk - Feature #7548][Open] Load and Require Callbacks — "trans (Thomas Sawyer)" <transfire@...>

12 messages 2012/12/12

[#50810] [ruby-trunk - Feature #7549][Open] A Ruby Design Process — "brixen (Brian Ford)" <brixen@...>

34 messages 2012/12/12

[#50867] [ruby-trunk - Bug #7556][Assigned] test error on refinement — "usa (Usaku NAKAMURA)" <usa@...>

14 messages 2012/12/13

[#50900] [ruby-trunk - Bug #7564][Open] r38175 introduces incompatibility — "tenderlovemaking (Aaron Patterson)" <aaron@...>

14 messages 2012/12/14

[#50951] [ruby-trunk - Bug #7584][Open] Ruby hangs when shutting down an ssl connection in gc finalization — "bpot (Bob Potter)" <bobby.potter@...>

12 messages 2012/12/17

[#51076] [ruby-trunk - Feature #7604][Open] Make === comparison operator ability to delegate comparison to an argument — "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>

12 messages 2012/12/22

[#51170] [ruby-trunk - Bug #7629][Open] Segmentation fault — "atd (Antonio Tapiador)" <atapiador@...>

13 messages 2012/12/28

[ruby-core:50673] Re: [ruby-trunk - Feature #4085] Refinements and nested methods

From: The 8472 <the8472@...>
Date: 2012-12-07 19:43:24 UTC
List: ruby-core #50673
On 07.12.2012 16:23, Rodrigo Rosenfeld Rosas wrote:
> Not all column names can be represented as method names. Or can they?

Most columns should be possible, considering that even unicode method 
names are valid.

For those cases where it's not possible there is __send__ in 
BasicObject. Or you can manually generate the AST-Object that would 
normally be spawned by method_missing. Or you could have a custom helper 
method. Or you could just call method_missing directly.

And before you say that's ugly, compare the following:

a)

   Foo.query{__send__("`illegal_method_name") == bar}


b)
   using SomeDSLRefinement do
     Foo.query(:"`illegal_symbol_name" => :bar)
   end


Personally I consider the first one more elegant, concise and 
expressive. Especially since you can actually write ruby code in the 
block and thus do things dynamically.

> Even if they could I don't like this approach. Look, I currently
> maintain an application that has some parts written in Grails, others in
> plain Java and others in Rails. I can do things even more advanced than
> what you suggested in Grails thanks to some features in Groovy.
>
> But the problem begins when you have some local variable (or method)
> name that happens to be the same as the column.

Local methods are not a problem with an instance_eval'd block on 
BasicObject. Local variables may conflict, but you have control over 
them since they are by definition *local*.


> In such cases the DSL approach doesn't really help and may yield to
> unexpected results (from a user POV)

Those "problems" are far more benign than the havok sometimes caused by 
monkey patching and usually result from a lack of understanding of the 
employed metaprogramming methods. I.e. it's a problem that can be fixed 
simply by increasing the user's knowledge through good documentation.



So really, i find this approach to making DSLs much cleaner than 
patching around in core objects.

Of course monkey patching does have its place, I'm not going to deny 
that. But DSLs shouldn't be the primary use-case for it. Glueing 
together two libraries that don't interact nicely with each other or or 
providing widely used utility methods throughout a whole gem/application 
namespace would be far more important in my opinion.

In This Thread

Prev Next