I don't know if this was discussed already, but it's definitely a great
idea!

On Wed, Sep 7, 2011 at 8:54 PM, Rodrigo Rosenfeld Rosas
<[email protected]>wrote:

> Is there any reason why Rails decided not to support argument binding in
> controller actions like Merb?
>
> https://github.com/wycats/**merb/tree/master/merb-action-**args<https://github.com/wycats/merb/tree/master/merb-action-args>
>
> The idea is to be able to do stuff like this:
>
> class MyController < ApplicationController
>    def find(term, limit=10, offset=0)
>        # if params[:limit] exists, it would be passed as the limit argument
> when the method is called by ActionDispatcher. Otherwise, 10 would be
> assumed
>        # raise BindingNotPresent unless params[:term].present?
>    end
> end
>
> Grails 2 will also bring such kind of feature and, as types can be
> optionally declared in Groovy, it is able to automatically type cast params
> too.
>
> As a curious note, Perl 6 has a great feature (among several others) that
> will enable you to write a main function that will bind arguments from the
> command line to the function params names too:
>
> http://perlgeek.de/en/article/**5-to-6#post_14<http://perlgeek.de/en/article/5-to-6#post_14>
>
> ---
>
> # file doit.pl
>
>  #!/usr/bin/perl6
>  sub MAIN($path, :$force, :$recursive, :$home = '~/') {
>      # do stuff here
>  }
>
>  # command line
>  $ ./doit.pl --force --home=/home/someoneelse file_to_process
>
> ---
>
> I like this style of automatic bindings.
>
> I'm not sure if one can inspect method arguments names in Ruby 1.8 though,
> but I guess this is possible since it seems that Merb supported this feature
> on Ruby 1.8 too...
>
> Was this feature already suggested on this list? If so, what was the reason
> it was rejected? Performance impact, maybe?
>
> Thanks in advance,
>
> Rodrigo.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To post to this group, send email to 
> rubyonrails-core@googlegroups.**com<[email protected]>
> .
> To unsubscribe from this group, send email to
> rubyonrails-core+unsubscribe@**googlegroups.com<rubyonrails-core%[email protected]>
> .
> For more options, visit this group at http://groups.google.com/**
> group/rubyonrails-core?hl=en<http://groups.google.com/group/rubyonrails-core?hl=en>
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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/rubyonrails-core?hl=en.

Reply via email to