On Thu, 2 Jun 2011 20:05:34 +0900, Ilias Lazaridis wrote:
> On 2 Ϧ, 10:02, Peter Zotov <whitequ... / whitequark.org> wrote:
>> On Thu, 2 Jun 2011 13:25:25 +0900, Ilias Lazaridis wrote:
>>
>> > On 1 Ϧ, 16:22, Robert Klemme <shortcut... / googlemail.com> 
>> 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.