digitalmars.D - Function Prototypes in D?
- Joscci (5/5) May 25 2007 Hello everyone,
- Sean Kelly (7/14) May 25 2007 You can use prototypes if the implementation for a function is compiled
- Joscci (3/20) May 25 2007 Gotcha. Thanks for the clarification -- and for answering. :o)
- BCS (3/18) May 25 2007 Prototypes can be used, but should only be used where the source is not ...
- Joscci (2/24) May 25 2007 Sweet. Thanks for your input. :o)
Hello everyone, I'm a newcomer to the D language (though not new to programming) and currently reading through the documentation to learn this fascinating new language. In any case, I was wondering -- does D make use of function prototypes like in C/C++? or are function definitions all that is necessary in D? I did tried experimenting with the compiler and it appears that the answer to my question is the latter, but wanted to make sure this is indeed the case. Thanks!
May 25 2007
Joscci wrote:Hello everyone, I'm a newcomer to the D language (though not new to programming) and currently reading through the documentation to learn this fascinating new language. In any case, I was wondering -- does D make use of function prototypes like in C/C++? or are function definitions all that is necessary in D? I did tried experimenting with the compiler and it appears that the answer to my question is the latter, but wanted to make sure this is indeed the case.You can use prototypes if the implementation for a function is compiled separately, but you can't prototype a function that is later defined, and you can't provide multiple prototypes for the same function, even if they match exactly. I've found this last restriction to be somewhat frustrating at times, as I believe it even applies to private prototypes. Sean
May 25 2007
Sean Kelly Wrote:Joscci wrote:Gotcha. Thanks for the clarification -- and for answering. :o) - Joscci -Hello everyone, I'm a newcomer to the D language (though not new to programming) and currently reading through the documentation to learn this fascinating new language. In any case, I was wondering -- does D make use of function prototypes like in C/C++? or are function definitions all that is necessary in D? I did tried experimenting with the compiler and it appears that the answer to my question is the latter, but wanted to make sure this is indeed the case.You can use prototypes if the implementation for a function is compiled separately, but you can't prototype a function that is later defined, and you can't provide multiple prototypes for the same function, even if they match exactly. I've found this last restriction to be somewhat frustrating at times, as I believe it even applies to private prototypes. Sean
May 25 2007
Reply to Joscci,Hello everyone, I'm a newcomer to the D language (though not new to programming) and currently reading through the documentation to learn this fascinating new language. In any case, I was wondering -- does D make use of function prototypes like in C/C++? or are function definitions all that is necessary in D? I did tried experimenting with the compiler and it appears that the answer to my question is the latter, but wanted to make sure this is indeed the case. Thanks!Prototypes can be used, but should only be used where the source is not available (closed source libs or cross language linking).
May 25 2007
BCS Wrote:Reply to Joscci,Sweet. Thanks for your input. :o)Hello everyone, I'm a newcomer to the D language (though not new to programming) and currently reading through the documentation to learn this fascinating new language. In any case, I was wondering -- does D make use of function prototypes like in C/C++? or are function definitions all that is necessary in D? I did tried experimenting with the compiler and it appears that the answer to my question is the latter, but wanted to make sure this is indeed the case. Thanks!Prototypes can be used, but should only be used where the source is not available (closed source libs or cross language linking).
May 25 2007