1. Aliases for function names?

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?

new topic     » topic index » view message » categorize

2. Re: Aliases for function names?

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Aliases for function names?

GreenEuphorian said...

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 ) 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu