www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - templates and files.

reply kenny <funisher gmail.com> writes:
I was looking at h3retic's raytracer, and it got me thinking about using 
  d's templates as a parser. Seriously thinking actually. The template 
language is strong enough, do you suppose we could use some of the 
phobos file functions inside of D templates to allow for file input and 
output?

Uses I can think of off of the top of my head:

1. instead of having to store revision number in a d file, the template 
can look in .svn/entries or get the output of the linux command "date"
2. preparsed resources, including bitmaps, icons, and meshes (for games?)
3. preparsed interpreted languages (compiled DMDScript, lol?)
4. XML build script options
5. gui that is built off of an XML -- at compile time


My primary use would be to generate D code based on an external script. 
For example, I could write generic code, then have a configuration file, 
which will be parsed for the directives at compile time instead of 


Kenny
Jan 07 2007
next sibling parent reply Daniel Keep <daniel.keep+lists gmail.com> writes:
kenny wrote:
 I was looking at h3retic's raytracer, and it got me thinking about using 
  d's templates as a parser. Seriously thinking actually. The template 
 language is strong enough, do you suppose we could use some of the 
 phobos file functions inside of D templates to allow for file input and 
 output?
 
 Uses I can think of off of the top of my head:
 
 1. instead of having to store revision number in a d file, the template 
 can look in .svn/entries or get the output of the linux command "date"
 2. preparsed resources, including bitmaps, icons, and meshes (for games?)
 3. preparsed interpreted languages (compiled DMDScript, lol?)
 4. XML build script options
 5. gui that is built off of an XML -- at compile time
 
 
 My primary use would be to generate D code based on an external script. 
 For example, I could write generic code, then have a configuration file, 
 which will be parsed for the directives at compile time instead of 

 
 Kenny
One wonders why you would not just write D code that generates D code as output... which is *vaguely* what templates are, anyway. -- Daniel P.S. Interesting factoid: Haskell is in the odd position of having a type system so powerful, it's Turing-complete. Now THAT'S scary. P.P.S. Actually, scary would be a program that generates D code written in D, compiled to a turing machine tape, which is run by code written in the C preprocessor, which is run by a CPP written in the Haskell type system, compiled for another turing machine built using LEGO. *brainsplode*
Jan 07 2007
next sibling parent Tom <tom nospam.com> writes:
Daniel Keep escribió:
 kenny wrote:
 [...]
 
 P.P.S.  Actually, scary would be a program that generates D code written 
 in D, compiled to a turing machine tape, which is run by code written in 
 the C preprocessor, which is run by a CPP written in the Haskell type 
 system, compiled for another turing machine built using LEGO. *brainsplode*
Hahaha, here am I, sitting at my PC, laughing out loud! (I feel such a nerd ;) ) Very funny :) -- Tom;
Jan 07 2007
prev sibling next sibling parent reply "Andrey Khropov" <andkhropov_nosp m_mtu-net.ru> writes:
Daniel Keep wrote:

 P.S.  Interesting factoid: Haskell is in the odd position of having a type
 system so powerful, it's Turing-complete.  Now THAT'S scary.
 
 P.P.S.  Actually, scary would be a program that generates D code written in
 D, compiled to a turing machine tape, which is run by code written in the C
 preprocessor, which is run by a CPP written in the Haskell type system,
 compiled for another turing machine built using LEGO. brainsplode
Things are gonna be even more scary in the future. Because now W3C pushes forward that thing that they call Semantic Web, which will essentially turn Web into a worldwide weak AI system. How about a global brain? -- AKhropov
Jan 07 2007
parent Georg Wrede <georg nospam.org> writes:
Andrey Khropov wrote:
 Things are gonna be even more scary in the future. Because now W3C pushes
 forward that thing that they call Semantic Web, which will essentially turn Web
 into a worldwide weak AI system. How about a global brain?
Seeing T1 back in the 80's, I had almost a religious revelation. The recursive storyline was already stunning, but the bit about Skynet reaching consciousness and then starting to learn at an exponential rate, just blew my socks off. And I saw it in 1984, Orwell's year. Our university got hooked up to the Internet in 1989, some five years later we got the WWW, things like CORBA, Yahoo, Google, Wikipedia, computer worms, malware, crackers, junk mail, DoS attacks, cell phones, blue-tooth viruses, ... I keep getting these /deja vu/s over and over again! If somebody told me Dan Brown's Digital Fortress has happened for real, I'd hardly raise an eyebrow. The times, they sure ain't gettin' boring. Heh, and there's no telling if the Internet actually will take down our civilization some day! And if somebody says they can't think of any way it could, I'd have to say that's the very point here, right?
Jan 07 2007
prev sibling parent reply Georg Wrede <georg nospam.org> writes:
Daniel Keep wrote:
 P.P.S.  Actually, scary would be a program that generates D code written 
 in D, compiled to a turing machine tape, which is run by code written in 
 the C preprocessor, which is run by a CPP written in the Haskell type 
 system, compiled for another turing machine built using LEGO. *brainsplode*
Jan 07 2007
parent Alexander Panek <a.panek brainsware.org> writes:
Georg Wrede wrote:
 Daniel Keep wrote:
 P.P.S.  Actually, scary would be a program that generates D code 
 written in D, compiled to a turing machine tape, which is run by code 
 written in the C preprocessor, which is run by a CPP written in the 
 Haskell type system, compiled for another turing machine built using 
 LEGO. *brainsplode*
To quote Tom: Here I am, sitting in front of my PC, laughing out very loudly. Really. *whipes away the tear of laugh*
Jan 07 2007
prev sibling parent "Andrey Khropov" <andkhropov_nosp m_mtu-net.ru> writes:
kenny wrote:

 I was looking at h3retic's raytracer, and it got me thinking about using
 d's templates as a parser. Seriously thinking actually. The template language
 is strong enough, do you suppose we could use some of the phobos file
 functions inside of D templates to allow for file input and output?
 
 Uses I can think of off of the top of my head:
 
 1. instead of having to store revision number in a d file, the template can
 look in .svn/entries or get the output of the linux command "date" 2.
 preparsed resources, including bitmaps, icons, and meshes (for games?) 3.
 preparsed interpreted languages (compiled DMDScript, lol?) 4. XML build
 script options 5. gui that is built off of an XML -- at compile time
 
 
 My primary use would be to generate D code based on an external script. For
 example, I could write generic code, then have a configuration file, which
 will be parsed for the directives at compile time instead of execution time.

 
 Kenny
Looks like what you need is Lisp (absolutely dynamic) or Nemerle (staged). -- AKhropov
Jan 07 2007