-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Parametrise modules #424
Copy link
Copy link
Open
Labels
A-inferenceType inference related proposals & ideasType inference related proposals & ideasA-modulesProposals relating to modules.Proposals relating to modules.A-resolveProposals relating to name resolution.Proposals relating to name resolution.A-syntaxSyntax related proposals & ideasSyntax related proposals & ideasA-typesystemType system related proposals & ideasType system related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.postponedRFCs that have been postponed and may be revisited at a later time.RFCs that have been postponed and may be revisited at a later time.
Metadata
Metadata
Assignees
Labels
A-inferenceType inference related proposals & ideasType inference related proposals & ideasA-modulesProposals relating to modules.Proposals relating to modules.A-resolveProposals relating to name resolution.Proposals relating to name resolution.A-syntaxSyntax related proposals & ideasSyntax related proposals & ideasA-typesystemType system related proposals & ideasType system related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.postponedRFCs that have been postponed and may be revisited at a later time.RFCs that have been postponed and may be revisited at a later time.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I would like to be able to parametrise modules by types and lifetimes. Type parameters are useful where many items in a module should use the same concrete type. E.g., taking some implementation as a parameter we want to ensure that all functions and data types in a module use the same implementor without annotating every item with the same type parameters. Likewise, parameterising by lifetimes is useful if we are to assume that many objects in a module have the same lifetime. This is especially useful in conjunction with arena allocation.
Details
Module declarations may have formal type and lifetime parameters and where clauses, e.g,
mod foo<X, 'a> where X: Bar { ... }.Module uses, including in use expressions which include an alias, can have actual type and lifetime parameters. E.g,
let x: foo<int>::Baz = ...;oruse foo<int, 'static> as int_foo.The usual rules around well-formedness wrt bounds, and inference would apply.