Page MenuHomeFeedback Tracker

Add/Fix template restrictions via base type
Assigned, NormalPublic

Description

To restrict what classes are allowed to be used with the template (so assumptions in code can be made about the interface all template variants will share) I propose to extend the synctax of templates from

class MyTemplate<Class T>

to

class MyTemplate<BaseType T>

which would be the equivalent to c#'s class MyTemplate<T> where T : BaseType

It should not introduce any new syntax parsing-wise and does not break existing use where people just have set the default to Class for now.

EDIT

I appears that this should generally work already but only if the restrictive type is part of a lower script module. So maybe this is a bug?

class TemplateRestriction
{
}

class TemplateTest<TemplateRestriction T>
{
}

Returns Bad type 'TemplateRestriction'

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Jul 4 2022, 10:30 AM
Arkensor updated the task description. (Show Details)Jul 4 2022, 10:57 AM
Arkensor changed Reproducibility from N/A to Always.
Arkensor renamed this task from Add template restrictions via base type to Fix template restrictions via base type.
Arkensor renamed this task from Fix template restrictions via base type to Add/Fix template restrictions via base type.
Geez changed the task status from New to Assigned.Jul 11 2022, 11:31 PM