It’s easy to alias method names. Is there a way I can alias keywords
like if or end? I want to localize Ruby code to another human language
for learning/educational purposes.
Any way I can get ruby or to understand new synonyms for keywords?
It’s easy to alias method names. Is there a way I can alias keywords
like if or end? I want to localize Ruby code to another human language
for learning/educational purposes.
Any way I can get ruby or to understand new synonyms for keywords?
El Viernes, 18 de Diciembre de 2009, Sonja Kisa escribió:
It’s easy to alias method names. Is there a way I can alias keywords
like if or end? I want to localize Ruby code to another human language
for learning/educational purposes.Any way I can get ruby or to understand new synonyms for keywords?
IMHO this is not possible at all.
you can do it like this:
def IF(condition)
if condition
yield
end
end
IF(true){
puts “yes”
}
Maybe I need to edit parse.y or something.
From #ruby-lang on Freenode IRC tonight:
[21:44] Sonja:
[21:44] <argv[0]> right. you either get “if” or you get “somethingelse”,
but not both
[21:45] if you want both, you’ll have to declare both
english and otherlanguage as keywords and then modify the grammar
productions to accept both
[21:46] <argv[0]> yea, that.
[21:46] <argv[0]> which is not quite as easy
[21:46] essentially: if expr then? expr => (if|fi) expr
(then|neht)?
[21:46] just a bit tedious considering how f’d up the yacc
file is
[21:47] but start with something that isn’t replicated in C
like class or module
[21:47] experiment with that one change
[21:47] and then expand
[21:48] should all just be algebraic changes, substitute A|B
for all A
[21:50] looks like the 1.9 (trunk) version is very cleaned
up… keyword_elsif… very easy to track down all versions then
[21:51] yacc kinda sucks… but we’re stuck with it
(coughfor nowcough)
[21:52] my algebraic statement above isn’t quite that easy
since yacc doesn’t support EBNF productions cleanly… but you’ll get it
[22:06] <argv[0]> Sonja this is about as good as it gets without messing
with parse.y insane.rb · GitHub
On Dec 17, 2009, at 11:12 PM, Sonja Elen K. wrote:
Maybe I need to edit parse.y or something.
Most definitely. But I don’t see much of a point in it:
You will have to distribute the changed version of
Ruby by yourself. If the users have to run it on their
own computer, this can be a hassle.
The users will have a mismatch between their stuff
and every piece of ruby code out there, especially
tutorials and books, basically making self-tutoring
a pain.
You will have to make sure that “normal” Ruby code
still runs.
I don’t know whether thats worth the hassle if your
course is not very “special interest”.
Regards,
Florian
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs