aliased functions
janderson
askme at me.com
Tue Mar 20 21:43:06 PDT 2007
Dan wrote:
> Hi guys,
>
> I was just going through my huge methods file, and I thought to myself that it might be beneficial if we somehow allowed ourselves to use:
>
> alias int function(int x, uint y) myFunctionStandard;
>
> myFunctionStandard myFunctionName {
> functionContents...
> }
>
> Reasons? Keeping it all in one place could reduce errors, make it more readable, and less verbose. I have a file with over 180 methods that all have identical parameters so they can be called through a common mechanism.
>
> Alternatively, anyone have a template for this already?
You could use tuples. Not quite as neat I guess.
template Tuple(E...)
{
alias E Tuple;
}
alias Tuple!(int, uint) myFunctionStandard;
alias int myFunctionStandardReturn;
myFunctionStandardReturn myFunctionName(myFunctionStandard tl)
{
functionContents...
}
More information about the Digitalmars-d
mailing list