From: Yehuda Katz Date: 2008-12-03T03:17:49+09:00 Subject: [ruby-core:20219] Re: Proposal: deferred blocks ------=_Part_79686_10392766.1228242207196 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Just to follow up on my previous comment, simply having a feature of Ruby that procs remember their string form (or be capable of composing it at runtime) would be adequate to handle this problem with no new keywords required. We could simply use the pure-ruby ruby-parser at runtime to convert the string form into a unified sexp. So again, the minimal feature request is just to have a source_string (or the like) method on Proc that would return the source of the proc as a string. -- Yehuda On Tue, Dec 2, 2008 at 10:04 AM, Yehuda Katz wrote: > 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 > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 ------=_Part_79686_10392766.1228242207196 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Just to follow up on my previous comment, simply having a feature of Ruby that procs remember their string form (or be capable of composing it at runtime) would be adequate to handle this problem with no new keywords required.

We could simply use the pure-ruby ruby-parser at runtime to convert the string form into a unified sexp.

So again, the minimal feature request is just to have a source_string (or the like) method on Proc that would return the source of the proc as a string.

-- Yehuda

On Tue, Dec 2, 2008 at 10:04 AM, Yehuda Katz <wycats@gmail.com> wrote:
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



--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325
------=_Part_79686_10392766.1228242207196--