Prev: Trouble running sample script with Shoooes
Next: Suggestion of Array#=== which improves case/when behavio
From: Sonja Kisa on 17 Dec 2009 20:51 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? -- Posted via http://www.ruby-forum.com/.
From: Iñaki Baz Castillo on 17 Dec 2009 20:56 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. -- Iñaki Baz Castillo <ibc(a)aliax.net>
From: Haoqi Haoqi on 17 Dec 2009 21:41 you can do it like this: def IF(condition) if condition yield end end IF(true){ puts "yes" } -- Posted via http://www.ruby-forum.com/.
From: Sonja Elen Kisa on 17 Dec 2009 21:42 Maybe I need to edit parse.y or something. -- Posted via http://www.ruby-forum.com/.
From: Sonja Elen Kisa on 17 Dec 2009 22:21 From #ruby-lang on Freenode IRC tonight: [21:44] <manveru> Sonja: http://github.com/shyouhei/ruby/blob/trunk/parse.y#L10106-10154 [21:44] <argv[0]> right. you either get "if" or you get "somethingelse", but not both [21:45] <zenspider> 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] <zenspider> essentially: if expr then? expr => (if|fi) expr (then|neht)? [21:46] <zenspider> just a bit tedious considering how f'd up the yacc file is [21:47] <zenspider> but start with something that isn't replicated in C like class or module [21:47] <zenspider> experiment with that one change [21:47] <zenspider> and then expand [21:48] <zenspider> should all just be algebraic changes, substitute A|B for all A [21:50] <zenspider> looks like the 1.9 (trunk) version is very cleaned up... keyword_elsif... very easy to track down all versions then [21:51] <zenspider> yacc kinda sucks... but we're stuck with it (*cough*for now*cough*) [21:52] <zenspider> 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 http://gist.github.com/259256 -- Posted via http://www.ruby-forum.com/.
|
Next
|
Last
Pages: 1 2 Prev: Trouble running sample script with Shoooes Next: Suggestion of Array#=== which improves case/when behavio |