1. Aliases for function names?
- Posted by GreenEuphorian Jun 11, 2014
- 1537 views
I was wondering, is it possible to define aliases for function names, so that I may have something like the following:
a=ParticularlyLongFunctionName
x=a(var1)
I guess this feature would require anonymous functions, or high order functions. Is something of this sort supported in Euphoria?
2. Re: Aliases for function names?
- Posted by gbonvehi Jun 12, 2014
- 1526 views
The closest thing we've on Euphoria is routine_id: http://openeuphoria.org/docs/dynamic.html#_636_indirectroutinecalling
Edit: I think that Derek's answer is actually what you wanted, what I suggested would be necessary if you didn't know the name of the long routine until runtime.
3. Re: Aliases for function names?
- Posted by DerekParnell (admin) Jun 12, 2014
- 1530 views
I was wondering, is it possible to define aliases for function names, so that I may have something like the following:
a=ParticularlyLongFunctionName
x=a(var1)
I guess this feature would require anonymous functions, or high order functions. Is something of this sort supported in Euphoria?
Yes, something like this supported already.
All one has to do is create a shim function and so long as it is very small, it will get in-lined as if you had actually coded the full-name function. For example ...
function a(object arg) return ParticularlyLongFunctionName( arg ) end function x=a(var1)
The generated code for this is functionally identical to ...
x=ParticularlyLongFunctionName( var1 )