Any chance to call Tango as Extended Standard Library
Jason House
jason.james.house at gmail.com
Sun Jan 18 10:34:11 PST 2009
Andrei Alexandrescu wrote:
> I'd be curious to find out more about a runtime queryable struct
> interface. How would it work? What idioms would it enable?
I don't know what Lars is thinking of, but I think of struct interfaces as a non-polymorphic / compile-time inheritance. AKA, you can have a struct implement it, but you can't cast it to a base struct/interface. Outside of defining the struct, I'd expect it to only be usable in templates and is-expressions
e.g.
template usesRanges( T : ForwardRange ){
...
}
usesRanges!(int) x;
LameExample.d: 243: Error int does not implement ForwardRange concept
Ranges.d: 12: head() not implemented
Ranges.d: 13: empty() not implemented
Ranges.d: 14: next() not implemented
Looking really quickly at http://en.wikipedia.org/wiki/C%2B%2B0x#Concepts I think I'm probably thinking of what C++0x calls Concepts. I didn't read enough to see if it's exactly what I'm thinking or just a close match. While every template that uses forward ranges could make a messy criteria using if clauses after the template, it may simply be too hard to read and too long to write. The template above would work without any extra if criteria... Misuse of the template will give cryptic compiler errors oddly reminiscent of STL...
More information about the Digitalmars-d
mailing list