Don wrote:
bearophile wrote:
Don:
There seems to be no point in having a *single* integer value, shared
between the app and all libraries! It's just reducing future
flexibility.
It doesn't reduce flexibility at all,
I meant future D flexibility.
because if you need something more complex you don't use it and nothing
bad happens. You can even ignore it.
You are thinking about 10000+ lines long apps; about scaling up.
No, I'm not, actually. I've actually never worked on a large project.
I'm not a computer scientist.
IMO, computer scientists are over-rated. The only great (as in very
large) thing about them is their egos.
I am thinking about single-module 500-lines long programs that replace
some scripts; about scaling down too.
A compilation constant avoids me to modify the source every time I
need to change the size of some static array/matrix. With that I just
need a second Python script that calls dmd/ldc with a different
argument, instead of a little more complex Python script that changes
the source code of the D program, to modify the constant.
A very modern language like Fortress, designed for physics, has that
small feature :-) (It's available in C too, only integer/symbol
constants).
Yes, but it has MORE THAN ONE.
Some specifics -- it'd be nice to have a Windows version specified as an
integer. It'd be nice to have a DirectX version number. Can't do it.
version(int) is like a programming language with one variable. It's
ridiculous.
The feature berophile speaks of in C, and such (and even in Java with
properties) is IMO yet another special case with special syntax in other
languages. If/When D gets proper macros, this would be trivial to
implement. basic idea - the macro reads a properties file and defines a
constant with the value specified in that file.
This is another reason why I prefer the two-phase compilation approach
instead of D's CTFE - CTFE is limited to a small subset of D which can
be reduced to constant-folding whereas in a Nemerle-like system you have
the full power of the language: I/O, network, syscalls, whatever. For
instance this is used to verify SQL queries on the DB engine at
compile-time.