IssueRaiser

Parametrise modules

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 = ...;` or `use foo<int, 'static> as int_foo`. The usual rules around well-formedness wrt bounds, and inference would apply.

Posted by nrc on Oct 30, 2014, 5:12 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.9,000 issues0 comments

github (Other)

Parametrise modules

nrcOct 30, 2014, 5:12 AM

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 = ...;` or `use foo<int, 'static> as int_foo`. The usual rules around well-formedness wrt bounds, and inference would apply.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue