Compile time filesystem access?

2012-01-30 Thread Manu
Is D capable of accessing the filesystem at compile time, for instance, to load and parse an XML DOM, or some other structural metadata, which may be used to generate the associative struct and its members? I can think of many other uses for the technology too. It seems extremely powerful, and I'm

Re: Compile time filesystem access?

2012-01-30 Thread Andrej Mitrovic
Only with `enum xmldata = import(file.xml);`, but you have to pass the -J switch and a directory path for the location of the file. E.g.: module test; enum xmldata = import(file.xml); void parse(string data)() { } void main() { parse!(xmldata)(); } $ dmd -J. test.d . is short for the

Re: Compile time filesystem access?

2012-01-30 Thread Andrej Mitrovic
Rather short docs since it's a simple feature: http://www.d-programming-language.org/expression.html#ImportExpression

Re: Compile time filesystem access?

2012-01-30 Thread Vladimir Panteleev
On Monday, 30 January 2012 at 13:23:19 UTC, Manu wrote: Is D capable of accessing the filesystem at compile time, for instance, to load and parse an XML DOM, or some other structural metadata, which may be used to generate the associative struct and its members? I can think of many other uses

Re: Compile time filesystem access?

2012-01-30 Thread Manu
On 30 January 2012 15:30, Vladimir Panteleev vladi...@thecybershadow.netwrote: On Monday, 30 January 2012 at 13:23:19 UTC, Manu wrote: Is D capable of accessing the filesystem at compile time, for instance, to load and parse an XML DOM, or some other structural metadata, which may be used to

Re: Compile time filesystem access?

2012-01-30 Thread David Nadlinger
Be careful, though, the import expression (understandably) expects a compile-time string, which means that you can't directly use it from CTFE (e.g. to open additional files included by the IDL file you are parsing), but instead have to go back to compile-time land and then pass the contents

Re: Compile time filesystem access?

2012-01-30 Thread Manu
On 30 January 2012 15:41, Manu turkey...@gmail.com wrote: On 30 January 2012 15:30, Vladimir Panteleev vladi...@thecybershadow.netwrote: On Monday, 30 January 2012 at 13:23:19 UTC, Manu wrote: Is D capable of accessing the filesystem at compile time, for instance, to load and parse an

Re: Compile time filesystem access?

2012-01-30 Thread Gor Gyolchanyan
Hear hear! How I understand what you mean! I just wanna freakin' look at it, but build a legitimate magical mystery toy with endless possibilities! On Mon, Jan 30, 2012 at 6:24 PM, Manu turkey...@gmail.com wrote: On 30 January 2012 15:41, Manu turkey...@gmail.com wrote: On 30 January 2012

Re: Compile time filesystem access?

2012-01-30 Thread Adam D. Ruppe
On Monday, 30 January 2012 at 14:24:32 UTC, Manu wrote: I want to know if a library is present, and automatically disable non-vital features if it isn't. I'd like it too... here's what I tried. It doesn't work, though. === void libraryTest(string lib)() { mixin(import ~ lib ~ ;); } template

Re: Compile time filesystem access?

2012-01-30 Thread bls
On 01/30/2012 07:18 AM, Adam D. Ruppe wrote: On Monday, 30 January 2012 at 14:24:32 UTC, Manu wrote: I want to know if a library is present, and automatically disable non-vital features if it isn't. I'd like it too... here's what I tried. It doesn't work, though. I am afraid I miss the

Re: Compile time filesystem access?

2012-01-30 Thread Manu
On 30 January 2012 18:11, bls bizp...@orange.fr wrote: On 01/30/2012 07:18 AM, Adam D. Ruppe wrote: On Monday, 30 January 2012 at 14:24:32 UTC, Manu wrote: I want to know if a library is present, and automatically disable non-vital features if it isn't. I'd like it too... here's what I

Module detection [Was: Compile time filesystem access?]

2012-01-30 Thread David Nadlinger
On 1/30/12 3:24 PM, Manu wrote: Here's another one I'm endlessly wishing I had in C. I want to know if a library is present, and automatically disable non-vital features if it isn't. It shits me to tears when I can't build something because a non-vital dependant lib is not available for a given

Re: Compile time filesystem access?

2012-01-30 Thread Timon Gehr
On 01/30/2012 04:18 PM, Adam D. Ruppe wrote: On Monday, 30 January 2012 at 14:24:32 UTC, Manu wrote: I want to know if a library is present, and automatically disable non-vital features if it isn't. I'd like it too... here's what I tried. It doesn't work, though. === void libraryTest(string

Re: Compile time filesystem access?

2012-01-30 Thread Marco Leise
Am 30.01.2012, 15:24 Uhr, schrieb Manu turkey...@gmail.com: Here's another one I'm endlessly wishing I had in C. I want to know if a library is present, and automatically disable non-vital features if it isn't. It shits me to tears when I can't build something because a non-vital dependant

Re: Compile time filesystem access?

2012-01-30 Thread Manu
On 30 January 2012 19:30, Marco Leise marco.le...@gmx.de wrote: Am 30.01.2012, 15:24 Uhr, schrieb Manu turkey...@gmail.com: Here's another one I'm endlessly wishing I had in C. I want to know if a library is present, and automatically disable non-vital features if it isn't. It shits me to

Re: Compile time filesystem access?

2012-01-30 Thread Iain Buclaw
On 30 January 2012 17:48, Manu turkey...@gmail.com wrote: On 30 January 2012 19:30, Marco Leise marco.le...@gmx.de wrote: Am 30.01.2012, 15:24 Uhr, schrieb Manu turkey...@gmail.com: Here's another one I'm endlessly wishing I had in C. I want to know if a library is present, and automatically

Re: Compile time filesystem access?

2012-01-30 Thread Manu
On 30 January 2012 20:03, Iain Buclaw ibuc...@ubuntu.com wrote: On 30 January 2012 17:48, Manu turkey...@gmail.com wrote: Exactly, and nobody I've ever met has either. They just seem to exist, magically appeared out of nowhere in all major linux projects that have existed for 20 years or

Re: Compile time filesystem access?

2012-01-30 Thread Jacob Carlborg
On 2012-01-30 18:48, Manu wrote: On 30 January 2012 19:30, Marco Leise marco.le...@gmx.de mailto:marco.le...@gmx.de wrote: Am 30.01.2012, 15:24 Uhr, schrieb Manu turkey...@gmail.com mailto:turkey...@gmail.com: Here's another one I'm endlessly wishing I had in C. I want

Re: Compile time filesystem access?

2012-01-30 Thread Marco Leise
Aren't those configure scripts generate by some other tool :) Maybe. I never digged that deep into build processes. After some time I got myself to write Makefiles, but that's about it. I see names like automake, m4, configure etc. pop up now and then and have no idea what role each

Re: Compile time filesystem access?

2012-01-30 Thread Danni Coy
configure scripts are usually part of the automake build system which used to be the standard on linux maybe 5 years ago I think it went out of favour roughly the same time as cvs. On Tue, Jan 31, 2012 at 5:29 AM, Marco Leise marco.le...@gmx.de wrote: Aren't those configure scripts generate by

Re: Compile time filesystem access?

2012-01-30 Thread Peter Alexander
On Monday, 30 January 2012 at 13:23:19 UTC, Manu wrote: Is D capable of accessing the filesystem at compile time, for instance, to load and parse an XML DOM, or some other structural metadata, which may be used to generate the associative struct and its members? I can think of many other uses