From: Yehuda Katz Date: 2008-12-03T03:04:48+09:00 Subject: [ruby-core:20218] Re: Proposal: deferred blocks ------=_Part_79482_33059069.1228241424523 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm ok with it being a keyword, and I would (honestly) even be ok with storing the proc in string form and running something like RubyParser or Ripper (with UnifiedRuby) to convert it portably into a sexp. Charles, is that something that could work with JRuby? -- Yehuda On Tue, Dec 2, 2008 at 9:54 AM, Charles Oliver Nutter < charles.nutter@sun.com> wrote: > Yehuda Katz wrote: > >> Example: >> >> Article.select(defer {|a| a.title =~ /Some title/ }) >> >> class Article >> def self.select(sexp) >> # sexp is: s(:defer, s(:lasgn, :a), s(:match3, s(:lit, /Some title/), >> s(:call, s(:lvar, :a), :title, s(:arglist)))) >> end >> end >> >> I understand that this would require a more explicit definition of the >> parse tree, but it seems like UnifiedRuby has provided a viable starting >> point for that work. >> > > It would have to be a keyword to be portable, since e.g. 1.9 and JRuby will > have different (or no) ASTs to present. But I like the idea of an expression > tree trigger keyword in principal (similar to how LINQ uses "from" as its > trigger, I believe). > > - Charlie > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 ------=_Part_79482_33059069.1228241424523 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm ok with it being a keyword, and I would (honestly) even be ok with storing the proc in string form and running something like RubyParser or Ripper (with UnifiedRuby) to convert it portably into a sexp.

Charles, is that something that could work with JRuby?

-- Yehuda

On Tue, Dec 2, 2008 at 9:54 AM, Charles Oliver Nutter <charles.nutter@sun.com> wrote:
Yehuda Katz wrote:
Example:

Article.select(defer {|a| a.title =~ /Some title/ })

class Article
 def self.select(sexp)
   # sexp is: s(:defer, s(:lasgn, :a), s(:match3, s(:lit, /Some title/), s(:call, s(:lvar, :a), :title, s(:arglist))))
 end
end

I understand that this would require a more explicit definition of the parse tree, but it seems like UnifiedRuby has provided a viable starting point for that work.

It would have to be a keyword to be portable, since e.g. 1.9 and JRuby will have different (or no) ASTs to present. But I like the idea of an expression tree trigger keyword in principal (similar to how LINQ uses "from" as its trigger, I believe).

- Charlie




--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325
------=_Part_79482_33059069.1228241424523--