Are templates required ?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Jan 19 06:55:01 PST 2007


Anders F Björklund wrote:
> Frits van Bommel wrote:
> 
>>> Are templates an optional feature of D 1.0,
>>> or are they required by any implementation ?
>>>
>> I'd say it's required to be fully compliant to the spec. However, I 
>> don't think it's necessarily sufficient reason to deny the other 
>> benefits of D to users of an old toolchain.
> 
> Which spec is that ? I don't recall them failing any tests.

I was talking about the D 1.0 spec, which seemed to be what you were 
talking about.

> For me it would be cool to just have a version(D_Templates),
> but that doesn't work if/when crucial parts of D uses them.

Well, I believe they're in the spec for D 1.0, specifically the part 
located at http://www.digitalmars.com/d/template.html. So IMHO to be 
fully compliant to the spec, they'd have to work :P.

As far as I'm aware though, they're pretty self-contained. I don't think 
there are major parts of Phobos that would be broken if templates didn't 
work, unless you count boxing.
I think a version of D without template support would still be pretty 
useful. Though obviously not as useful as a version that *does* support 
templates :).

>> How does g++ fix this, by the way? C++ has templates, so it should be 
>> possible. Or does that also fail for 'more complex programs'?
> 
> Apple's GCC 3.3 supports C, C++ and Objective-C. But not D...

That much I'm aware of.
Though I must say I've never used Mac OS for more than a few hours, and 
then only for word processing and image editing, not programming.

> (and GDC doesn't build with Apple GCC 3.3, only with GCC 4.0)

How about 3.4? Or was that never shipped by Apple?

> I believe that in the Dark Ages, templates used to fail all
> over the place, but that C++ compilers eventually caught up ?

I only got into C-like languages when GCC 3.4 was out, so I also never 
used 3.3.

>> And in what way would "private" template emission fail, anyway? It 
>> might cause extra bloat but I can't see how it would fail?
> 
> DMDscript doesn't work because it throws exceptions at start:
> "Error: circular initialization dependency with module script"

How is this related to templates?
(Does it use "static this()" in a template or something?)

> readf/TypeInfo doesn't work, because it uses "is" to compare.
> (and since it emits multiple instances, that doesn't work OK)

That seems to be an instance of what I expected might happen and wrote 
in the paragraph you seem to have cut...

>> Something else about the original problem: Would it maybe be possible 
>> to backport once-only linkage to the old GCC? Or would that be a lot 
>> of work?
> 
> It's a lot of work, and I haven't been able to complete it yet.
> (there is also very little demand for such a thing, it seems...)

I must say I have no idea how many people are using old versions of Mac OS.
Another option might be to supply an entire new toolchain. Or was the 
ABI changed before the first version of GCC that GDC supports?

> I think David has deprecated GCC 3.3 for GDC in general, as well.

Well, it *is* pretty old by now. 3.4 has been out for almost 3 years 
now, and 4.0 was almost 2 years ago. (Though IIRC 4.0.0 was buggy at 
first...)
[Reference: http://gcc.gnu.org/releases.html]

> And DMD doesn't have any support for Mac, just Windows and linux.

Aside: that's all I've ever needed :).

Though I can definitely understand people on macs might not like that...



More information about the Digitalmars-d mailing list