digitalmars.D - obj file for mixin?
- Tim Keating (7/7) Jan 10 2007 This may seem like a dumb question but . . . a source file that is
- Daniel Keep (9/17) Jan 12 2007 Actually, some people have used this very behaviour to do some very cool...
- kenny (6/27) Jan 12 2007 Are there any examples of this anywhere? This sounds very very
- Daniel Keep (11/27) Jan 13 2007 I haven't looked at it in a while, but I think Mango does this for its'
- kenny (13/49) Jan 13 2007 darn, it's not everything I hoped for, but that is still REALLY COOL.
- Bruno Medeiros (8/64) Jan 18 2007 I'm sure there's a simpler way to achieve that. Perhaps can use build in...
This may seem like a dumb question but . . . a source file that is imported solely for a template that gets used as a mixin will not be compiled into an obj file, correct? The more I think about this, the more it seems like the logical behavior, but MAN did it freak me out when I noticed its absence from my build directory. ("How in the hell did I link that code in there?!?") TK
Jan 10 2007
Tim Keating wrote:This may seem like a dumb question but . . . a source file that is imported solely for a template that gets used as a mixin will not be compiled into an obj file, correct? The more I think about this, the more it seems like the logical behavior, but MAN did it freak me out when I noticed its absence from my build directory. ("How in the hell did I link that code in there?!?") TKActually, some people have used this very behaviour to do some very cool (and kinda scary) shell scripting with D. The idea is that you write your scripting libraries as template mixins, then use "dmd -run" to run your .d file as a script. If you're on a *NIX, you can even then use a hashbang. D's also fast enough that compiling the script every time isn't a big deal. You certainly wouldn't want to try it with C :3 -- Daniel
Jan 12 2007
Are there any examples of this anywhere? This sounds very very interesting to me. Actually so interesting that, you may have just changed the way I was going to implement something ;) Does that mean that I can essentially use D as a scripting language? *Can't contain excitement!* Daniel Keep wrote:Tim Keating wrote:This may seem like a dumb question but . . . a source file that is imported solely for a template that gets used as a mixin will not be compiled into an obj file, correct? The more I think about this, the more it seems like the logical behavior, but MAN did it freak me out when I noticed its absence from my build directory. ("How in the hell did I link that code in there?!?") TKActually, some people have used this very behaviour to do some very cool (and kinda scary) shell scripting with D. The idea is that you write your scripting libraries as template mixins, then use "dmd -run" to run your .d file as a script. If you're on a *NIX, you can even then use a hashbang. D's also fast enough that compiling the script every time isn't a big deal. You certainly wouldn't want to try it with C :3 -- Daniel
Jan 12 2007
kenny wrote:Are there any examples of this anywhere? This sounds very very interesting to me. Actually so interesting that, you may have just changed the way I was going to implement something ;) Does that mean that I can essentially use D as a scripting language? *Can't contain excitement!*I haven't looked at it in a while, but I think Mango does this for its' build scripts (or they might have removed that). Also, I did something similar with the build scripts for my cairo bindings (they're up at dsource.org/projects/bindings/ somewhere, I believe). So yes, you *can* use D as a kinda scripting language. Just keep in mind that if you write a scripting library, instead of:module my_lib; void some_func(); class Foo { }You need to do this:module my_lib; template my_lib { void some_func(); class Foo { } }And then do this in your script:mixin my_lib.my_lib;-- Daniel
Jan 13 2007
darn, it's not everything I hoped for, but that is still REALLY COOL. Thanks! A game could create bindings to the core, and then use DMD to compile all of the files before the game starts. A whole AI could be written using d's "scripting" ability :) That's really really awesome. Why doesn't someone do that? For my purposes (web development), it doesn't satisfy everything that I want. I still need another layer of abstraction, but that does give the ability for the content server to have extensions compiled on the fly (without reloading the servers -- just the d files) AWESOME!!! Thanks again :) Kenny Daniel Keep wrote:kenny wrote:Are there any examples of this anywhere? This sounds very very interesting to me. Actually so interesting that, you may have just changed the way I was going to implement something ;) Does that mean that I can essentially use D as a scripting language? *Can't contain excitement!*I haven't looked at it in a while, but I think Mango does this for its' build scripts (or they might have removed that). Also, I did something similar with the build scripts for my cairo bindings (they're up at dsource.org/projects/bindings/ somewhere, I believe). So yes, you *can* use D as a kinda scripting language. Just keep in mind that if you write a scripting library, instead of: > module my_lib; > void some_func(); > class Foo { } You need to do this: > module my_lib; > template my_lib { > void some_func(); > class Foo { } > } And then do this in your script: > mixin my_lib.my_lib; -- Daniel
Jan 13 2007
kenny wrote:darn, it's not everything I hoped for, but that is still REALLY COOL. Thanks! A game could create bindings to the core, and then use DMD to compile all of the files before the game starts. A whole AI could be written using d's "scripting" ability :) That's really really awesome. Why doesn't someone do that? For my purposes (web development), it doesn't satisfy everything that I want. I still need another layer of abstraction, but that does give the ability for the content server to have extensions compiled on the fly (without reloading the servers -- just the d files) AWESOME!!! Thanks again :) Kenny Daniel Keep wrote:I'm sure there's a simpler way to achieve that. Perhaps can use build in some sort of way? Or one can create a shell script that wraps calls to rdmd and passes the lib's precompiled .objs as parameters (that's what I have been doing so far). It works fairly ok except from some Cygwin quirks. -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#Dkenny wrote:Are there any examples of this anywhere? This sounds very very interesting to me. Actually so interesting that, you may have just changed the way I was going to implement something ;) Does that mean that I can essentially use D as a scripting language? *Can't contain excitement!*I haven't looked at it in a while, but I think Mango does this for its' build scripts (or they might have removed that). Also, I did something similar with the build scripts for my cairo bindings (they're up at dsource.org/projects/bindings/ somewhere, I believe). So yes, you *can* use D as a kinda scripting language. Just keep in mind that if you write a scripting library, instead of: > module my_lib; > void some_func(); > class Foo { } You need to do this: > module my_lib; > template my_lib { > void some_func(); > class Foo { } > } And then do this in your script: > mixin my_lib.my_lib; -- Daniel
Jan 18 2007