From: Peter Zotov Date: 2011-06-02T20:29:48+09:00 Subject: Re: CORE - Alternative Variable Substitution On Thu, 2 Jun 2011 20:05:34 +0900, Ilias Lazaridis wrote: > On 2 Ιούν, 10:02, Peter Zotov wrote: >>  On Thu, 2 Jun 2011 13:25:25 +0900, Ilias Lazaridis wrote: >> >> > On 1 Ιούν, 16:22, Robert Klemme >> wrote: >> >> It can be as easy as >> > [...] >> >> > You suggested implementation adds a new function. >> >> > At least, if you suggest an implementation, do it in the OO way >> > (overloading the relevant method). >> >>  There is no separate method in Ruby which does the variable >>  substitution. >>  This functionality is hardcoded into lexer and parser. > > I understand. > > This means it is not easy, if not impossible to alter the behaviour. > > Can I change this functionality with a C-level extension, but without > altering the ruby source? Definitely no (for MRI, at least). Basically, C extensions can provide the same functionality as Ruby libraries (define modules, classes, functions etc.), but in C. There is several hacks you can do with an extension, but they are hard to implement/debug and are non-portable. Moreover, the compiled lexer is a huge state machine which consists of a switch() and a lot of symbol-to-transition association tables. You won't be able to patch that anyhow. -- WBR, Peter Zotov.