[fpc-pascal] Generic type conflicts

Jonas Maebe jonas at freepascal.org
Fri Nov 8 17:23:04 CET 2019


On 08/11/2019 17:18, Ben Grasset via fpc-pascal wrote:
> On Fri, Nov 8, 2019 at 11:04 AM Jonas Maebe <jonas at freepascal.org
> <mailto:jonas at 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


More information about the fpc-pascal mailing list