|
|
|
|
Quick Links
Understanding XL
In depth
Other projects
|
XLR: Extensible Language and Runtime
|
Frequently, when you declare a generic type, you also declare a number of related generic declarations (other types, algorithms, etc). Before the C++ STL, we had little experience with large bodies of generic code. The STL has popularized a number of concepts, such as ForwardIterator, which is used for any data type where both a dereference operator (operator* and an increment operator (operator++) exist. Unfortunately, these concepts translate in the code with little more than naming conventions on template parameters. The compiler cannot check anything before actually instantiating a type. In other words, anybody in the C++ community knows what a ForwardIterator is, except the compiler! In other words, the bandwidth of the C++ template mechanism is insufficient to represent a concept such as ForwardIterator. XL allows to declare validations for generics. Before even attempting to instantiate a template, the compiler attempts to instantiate the validation. If the validation is rejected, then the instantiation itself is rejected. There is even the possibility to select among candidates based on validation, as shown in this example, but I'm not really sure that this is a good idea... Note: At this stage, only the C++ version of the compiler implements generics.
|
Copyright 2006 Christophe de Dinechin (Blog)
E-mail: XL Mailing List (polluted by spam, unfortunately)