Is instantiabilty of templated types decidable?
Manfred Nowak
svv1999 at hotmail.com
Sun Nov 11 06:57:12 PST 2012
David Nadlinger wrote:
>> a) Instantiability is decidable
> an arbitrary limit, but useful
I doubt the usefullness of any value `v' ( here `v == 500')
because the recursive definition might come to an end at value
`v +1'. Especially in the case, that the coder knows of such a
limit, the limit should be adjustable---but an option for
adjusting the limit is missing.
>> b) Instantiability is not decidable
> The other types _are_ needed to be known
It is useless to force the compiler to know anything about a
type for which the instantiability is not decided---and it is a
prerequisite, that the instantiability is not decidable.
If the coder doesn't know the instantantiability either or
simply wants the compiler to stop at some point with the
expansions, the language should give the coder an oportunity to
declare those points.
For example: an attribute named `Undecided' can be used to
express such a declaration in the example given in the OP:
class Elem( size_t mynumber) {
Undecided( Elem!( mynumber +1)*) next;
}
Where the attribute `Undecided( T)' replaces `T' until its
instantiation by a type with similar meaning as "NaN" or `null',
for example `TypeWithUndecidedExistence' or `TWUE'. Of course:
although `TWUE' has `typeinfo' etc., `TWUE' poisons every type
constructing operation by that the result is again `TWUE'
-manfred
More information about the Digitalmars-d
mailing list