Compile time executable calling?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jul 15 10:34:19 PDT 2013


On Mon, Jul 15, 2013 at 02:06:47PM -0300, Ary Borenszweig wrote:
> On 7/15/13 2:03 PM, Ali Çehreli wrote:
> >On 07/13/2013 09:05 AM, Ary Borenszweig wrote:
> >
> > > What would actually be cool is to run any kind of code at compile
> > > time (within a sandbox, if you want). For example reading a mysql
> > > database and generating classes for the tables at compile time. No
> > > need to run a separate executable and remember to run it before
> > > compiling your program.
> >
> >Humans make mistakes all the time, especially with repetitive tasks.
> >That's why such tasks are handled by tools like 'make'.
> >
> >Ali
> 
> Why have CTFE at all if you can produce the desired code with an
> external program, output it to some file and then use it with
> import("file")? Just use 'make'.

That's an invalid argument. CTFE allows compile-time introspection of
types and declarations within the language. To move this outside the
compiler would require essentially re-implementing the compiler so that
you can parse your code to extract types, declarations, etc., in order
to perform CTFE. This means it's better for it to be in the compiler.

OTOH, executing arbitrary programs has nothing to do with the compiling
of D source code. That belongs to the OS level of operations, not inside
the compiler.


> I believe a programming language should be as self-contained as
> possible for building an executable out of it. The more you can do
> within the language itself, minimizing external dependencies, the
> better. Because users need only to understand the language. They don't
> need to understand make, build systems and whatnot.
[...]

I don't understand this reluctance to learn how to use build systems.
Why insist on building a house with only a hammer, and refuse to learn
how to use a screwdriver and wrench? Sure, you *can* build a house with
only a hammer if you try hard enough, but why not use tools that already
exist?

(Of course, the problem is exacerbated by make being a really poor
example of a build system, but also the one most people know about.
Perhaps that explains part of the bad rep of build systems.)


T

-- 
What are you when you run out of Monet? Baroque.


More information about the Digitalmars-d mailing list