dmd git master version

H. S. Teoh hsteoh at qfbox.info
Thu Oct 13 04:16:46 UTC 2022


On Thu, Oct 13, 2022 at 03:52:57AM +0000, norm via Digitalmars-d wrote:
> On Wednesday, 12 October 2022 at 20:45:43 UTC, H. S. Teoh wrote:
[...]
> > Thanks for the tip. (Though I must say, it strikes me as a little
> > odd to key the version number off git tags, which are fluid and
> > arbitrarily-assigned, as opposed to actual source code that reflects
> > the actual functionality behind a particular version number...)
[...]
> Using git tags is quite common in places where I've worked. CI/CD is
> configured to build a release with changelog and release note when it
> sees a semantic version tag arrive.
[...]
> This `v1.2.3-0-gabcd12345` clearly indicates the version, if it is
> actually a release build, and the commit hash, which for us we find
> most important.  One less dereference we have to do when bugs are
> reported.
[...]

It's not so much the usage of git tags for release versioning that I
find odd.  It's the fact that dmd 2.100.2 insists that it's 2.098, sets
`__VERSION__` to 2098L, and believes that it's 2.098, yet the state of
code is clearly already 2.100.2 and the compiler will behave like a
2.100.2 compiler.

In my mind, the state of source code defines the meaning behind the
version number, and therefore the version number ought to be encoded in
the source code, so that the two are consistent.  This is particularly
so in a D compiler where the version number returned by `__VERSION__`
could cause semantic changes in downstream user code (due to static if,
etc.).

Imagine the hypothetical case where 2.100.2 introduced a breaking syntax
change for which user code has to be updated; a user project that wants
to be compilable with both versions of the compiler would likely do
something like:

	static if (__VERSION__ <= 2098L) {
		... // implement feature using 2.098 syntax
	} else {
		... // implement feature using 2.100.2 syntax
	}

In this case, since the compiler thinks it's 2.098, it will compile the
first branch of the static if, but since it's actually a 2.100.2
compiler, it will fail to compile the code that's meant for 2.098. To
add to the confusion, it claims that it's a 2.098 compiler, which will
surely leave users *really* scratching their heads as to what exactly is
going on. :-P


T

-- 
People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth


More information about the Digitalmars-d mailing list