vvvv / VL-Language

The official repo for the design of the VL programming language
31 stars 0 forks source link

[Proposal] Optional explicit type parameters #39

Closed gregsn closed 3 years ago

gregsn commented 3 years ago

We want the user to be able to specify explicit type parameters on type definitions. This is necessary to solve Issue B mentioned here: #38

In the Name field you shall be able to write MyClass<MyT1, MyT2>.

By that, you tell the system

This proposal tries to not reinvent everything:

This proposal is not about optional explicit type parameters on

For now, we want to tackle the problems on type definitions. Let's see if we then still need those other forms of expression.

gregsn commented 3 years ago

Regarding the details:

What shall happen when you annotate a pin with type parameter A and it is connected to a node that feeds or accepts e.g. a Boolean.

Argue!

gregsn commented 3 years ago

Shall that type parameter vanish and be substituted by Boolean?

Option A) Replace every occurrence with the concrete type If this type parameter vanished from the body of the patch (it got replaced everywhere, so no type annotation left with that type parameter)

Option B) No. Always keep the parameter. Never substitute The type unification has to collect all the constraints for the type parameter. In the end, it should check if these are valid type parameter constraints. If yes these are kept, otherwise we report an error.

azeno commented 3 years ago

I wanted to add that this proposal might give us a way out regarding another issue: calling operations on This in generic patches is currently completely broken. We could say that self-referential generic patches will only work with explicit parameters.

gregsn commented 3 years ago

Works for me

gregsn commented 3 years ago

This got implemented for 2021.4. It's like specified here, but also comes with explicit type parameters for static operations. Layer operations still don't have that ability. Oh, and it's of course Option B): never substitute an explicit type parameter.