aliased functions

Chris Nicholson-Sauls ibisbasenji at gmail.com
Tue Mar 20 17:10:43 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?

Or in other words, its like a function-decleration level interface definition, yes? 
Actually I have wanted something like this from time to time.  For example, in one project 
I have a module with about fifteen functions with the exact same signature, aside from 
name.  And several other modules, all containing bundles of functions, and all of them 
with that very same signature.  Suppose I extend that signature in a later revision...  Or 
suppose I typo while implementing yet another...  Or suppose a lot of things.  It would've 
been very handy to have something like this to keep me on track.

I may not be fond of languages that hold my hand, but I am fond of languages that help me 
hold my own.  :)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list