D - let the implementation be the definition
- Lewis (9/9) Jan 03 2004 admittedly, im green around the gills when it comes to a language such a...
- Walter (15/24) Jan 03 2004 D, but
- Lewis (17/63) Jan 07 2004 thanks for the reply walter
- Andy Friesen (17/37) Jan 07 2004 a.d:
- Lewis (7/54) Jan 07 2004 thanks andy,
- J Anderson (7/62) Jan 07 2004 If you haven't solved the problem (and for other problems), it would be
- Walter (5/6) Jan 10 2004 another module
admittedly, im green around the gills when it comes to a language such as D, but i have a complaint/question/suggestion... Why must functions and such be declared twice? It is my understanding that the predeclared function is to serve as a prototype for the compiler to do type checking and make sure that the calling is correct. I dont understand why this is needed as the actual function itself could easily serve as the prototype for itself, IMHO. Could someone be kind enough to explain why this is needed? and why it isnt possible to make the function implemtation also its declaration.
Jan 03 2004
"Lewis" <dethbomb hotmail.com> wrote in message news:bt5t92$2dr1$1 digitaldaemon.com...admittedly, im green around the gills when it comes to a language such asD, buti have a complaint/question/suggestion... Why must functions and such be declared twice?Why indeed. They don't in D <g>.It is my understanding that the predeclared function is to serve as aprototypefor the compiler to do type checking and make sure that the calling iscorrect.I dont understand why this is needed as the actual function itself couldeasilyserve as the prototype for itself, IMHO. Could someone be kind enough to explain why this is needed? and why itisntpossible to make the function implemtation also its declaration.It's needed in C and C++ because the semantics of the language are compile-as-you-go one pass through the file. That design was appropriate for machines with little memory. D, on the other hand, does multiple passes over the code, so forward declarations are not needed. Machines have much more memory now, so the old compromises are unnecessary. Ironically, compiling C++ these days requires a great deal of memory, even though it remains a one pass semantic language.
Jan 03 2004
Walter wrote:"Lewis" <dethbomb hotmail.com> wrote in message news:bt5t92$2dr1$1 digitaldaemon.com...thanks for the reply walter i guess im at a loss *still* when it comes to how 'import' works... it is my belief that when i type import std.c.string; that all the functions within that file should then be available in the current module as if i had pasted the code into that module (i think) Ive spent two weeks messing with things trying to figure out how to make functions i have in another module work in the current module, it keeps giving me a undeclared error as in: Error 42: Symbol Undefined _Left 12 //a Left() function i coded in another module Ive added all my modules to the command line, imported all modules, and every other thing i can think of and it still wont recognize when i use a function from another module in my current module. -sigh If someone is willing to help i could paste some code that im using from each module and to help me get the command line i need to make it compile... frustrated newbie :) Lewisadmittedly, im green around the gills when it comes to a language such asD, buti have a complaint/question/suggestion... Why must functions and such be declared twice?Why indeed. They don't in D <g>.It is my understanding that the predeclared function is to serve as aprototypefor the compiler to do type checking and make sure that the calling iscorrect.I dont understand why this is needed as the actual function itself couldeasilyserve as the prototype for itself, IMHO. Could someone be kind enough to explain why this is needed? and why itisntpossible to make the function implemtation also its declaration.It's needed in C and C++ because the semantics of the language are compile-as-you-go one pass through the file. That design was appropriate for machines with little memory. D, on the other hand, does multiple passes over the code, so forward declarations are not needed. Machines have much more memory now, so the old compromises are unnecessary. Ironically, compiling C++ these days requires a great deal of memory, even though it remains a one pass semantic language.
Jan 07 2004
Lewis wrote:i guess im at a loss *still* when it comes to how 'import' works... it is my belief that when i type import std.c.string; that all the functions within that file should then be available in the current module as if i had pasted the code into that module (i think) Ive spent two weeks messing with things trying to figure out how to make functions i have in another module work in the current module, it keeps giving me a undeclared error as in: Error 42: Symbol Undefined _Left 12 //a Left() function i coded in another module Ive added all my modules to the command line, imported all modules, and every other thing i can think of and it still wont recognize when i use a function from another module in my current module. -sigh If someone is willing to help i could paste some code that im using from each module and to help me get the command line i need to make it compile... frustrated newbie :) Lewisa.d: import b; int main() { B(); return 0; } b.d: void B() { printf("B!\n"); } Then, at the command line: D:\temp\dstuff>dmd a.d b.d D:\temp\dstuff>a B! -- andy
Jan 07 2004
Andy Friesen wrote:Lewis wrote:thanks andy, that seems to be what im doing (similar to what someone else mentioned before), i must be not including the modules correctly in my commandline somewhere... off to try again :) regards Lewisi guess im at a loss *still* when it comes to how 'import' works... it is my belief that when i type import std.c.string; that all the functions within that file should then be available in the current module as if i had pasted the code into that module (i think) Ive spent two weeks messing with things trying to figure out how to make functions i have in another module work in the current module, it keeps giving me a undeclared error as in: Error 42: Symbol Undefined _Left 12 //a Left() function i coded in another module Ive added all my modules to the command line, imported all modules, and every other thing i can think of and it still wont recognize when i use a function from another module in my current module. -sigh If someone is willing to help i could paste some code that im using from each module and to help me get the command line i need to make it compile... frustrated newbie :) Lewisa.d: import b; int main() { B(); return 0; } b.d: void B() { printf("B!\n"); } Then, at the command line: D:\temp\dstuff>dmd a.d b.d D:\temp\dstuff>a B! -- andy
Jan 07 2004
inline Lewis wrote:Andy Friesen wrote:If you haven't solved the problem (and for other problems), it would be helpful if you sent an example, with either you make file or the command line entry your using. That way we'll be able to solve your problem much more quickly. Two weeks? You should of posted sooner <g> AndersonLewis wrote:thanks andy, that seems to be what im doing (similar to what someone else mentioned before), i must be not including the modules correctly in my commandline somewhere... off to try again :) regards Lewisi guess im at a loss *still* when it comes to how 'import' works... it is my belief that when i type import std.c.string; that all the functions within that file should then be available in the current module as if i had pasted the code into that module (i think) Ive spent two weeks messing with things trying to figure out how to make functions i have in another module work in the current module, it keeps giving me a undeclared error as in: Error 42: Symbol Undefined _Left 12 //a Left() function i coded in another module Ive added all my modules to the command line, imported all modules, and every other thing i can think of and it still wont recognize when i use a function from another module in my current module. -sigh If someone is willing to help i could paste some code that im using from each module and to help me get the command line i need to make it compile... frustrated newbie :) Lewisa.d: import b; int main() { B(); return 0; } b.d: void B() { printf("B!\n"); } Then, at the command line: D:\temp\dstuff>dmd a.d b.d D:\temp\dstuff>a B! -- andy
Jan 07 2004
"Lewis" <dethbomb hotmail.com> wrote in message news:bthmng$2i94$1 digitaldaemon.com...Error 42: Symbol Undefined _Left 12 //a Left() function i coded inanother module That's coming from the linker. It means (most likely) that the module defining Left() is missing from the command to the linker.
Jan 10 2004