On 08/11/2019 17:18, Ben Grasset via fpc-pascal wrote: > On Fri, Nov 8, 2019 at 11:04 AM Jonas Maebe <jo...@freepascal.org > <mailto:jo...@freepascal.org>> wrote: > > You can't. It's the main difference between C++ templates, which is a > Turing-complete programming language, and generics, which is simply a > parametrising mechanic. > > I know what you mean, and I'm aware, but you actually kind of can to the > fairly straightforward extent that I'm concerned about with Ryan's patch > (i.e. simply passing constant results as constraints rather than > function parameters.)
It does explain why templates can contain invalid C++: it's because the invalid C++ gets discarded before it is (semantically) presented to the C++ parser. This does not work with generics, because generics are Pascal themselves. Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal