A
Alex Gutteridge
I'm working on converting a Python module (RPy) to Ruby and am trying
to keep the api as close to the original as possible. In Python it
(appears - my Python is very weak) that this is valid syntax:
foo[x](y,z)
Where 'foo' is an object with attribute 'x' which itself is callable
- in this case with the parameters 'y' and 'z'. The 'foo[x]' object
is actually an R function and some magic is subsequently performed to
convert the parameters and call the function from Python/Ruby.
From my experiments it appears that 'foo[x](y,z)' is always a
SyntaxError in Ruby and the closest I can get in Ruby syntax to the
Python is:
foo[x][y,z]
But this isn't quite as pretty, since the distinction between the
function ('foo[x]') and the parameters 'y' and 'z' is not as visually
obvious.
foo[x].call(y,z)
is another option, but goes still further from the Python api. Not a
big problem for sure, but I just wanted to make sure there wasn't
some magic trick I was missing to make the original Python ('foo[x]
(y,z)') also valid Ruby.
Dr Alex Gutteridge
Post-Doctoral Researcher
Bioinformatics Center
Institute for Chemical Research
Kyoto University
Gokasho, Uji, Kyoto 611-0011
Japan
to keep the api as close to the original as possible. In Python it
(appears - my Python is very weak) that this is valid syntax:
foo[x](y,z)
Where 'foo' is an object with attribute 'x' which itself is callable
- in this case with the parameters 'y' and 'z'. The 'foo[x]' object
is actually an R function and some magic is subsequently performed to
convert the parameters and call the function from Python/Ruby.
From my experiments it appears that 'foo[x](y,z)' is always a
SyntaxError in Ruby and the closest I can get in Ruby syntax to the
Python is:
foo[x][y,z]
But this isn't quite as pretty, since the distinction between the
function ('foo[x]') and the parameters 'y' and 'z' is not as visually
obvious.
foo[x].call(y,z)
is another option, but goes still further from the Python api. Not a
big problem for sure, but I just wanted to make sure there wasn't
some magic trick I was missing to make the original Python ('foo[x]
(y,z)') also valid Ruby.
Dr Alex Gutteridge
Post-Doctoral Researcher
Bioinformatics Center
Institute for Chemical Research
Kyoto University
Gokasho, Uji, Kyoto 611-0011
Japan