-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Often I find that I want to have a name alias for a complex type definition. This would be particularly helpful in a number of scenarios:
-
When defining an API, it would be nice to have a more descriptive name for the users of the API. I believe that this can increase code readability.
-
Less typing, some type definitions are quite complex, a simple alias could reduce the amount of copy-paste semantics.
Suppose I have a function that takes an argument which is rather complex:
declare function local:my-function($a as (function() as map(xs:string, map(xs:string, (function(xs:integer) as xs:float+)*)))+)It would be easier/nicer if I could have something like the following:
declare type alias local:lazy-math-functions
as (function() as map(xs:string, map(xs:string, (function(xs:integer) as xs:float+)*)))+;
declare function local:my-function($a as local:lazy-math-functions) {
...
};
declare function local:my-other-function($a as local:lazy-math-functions, $b as xs:int+) {
...
};Aliases are likely only syntactic sugar, they are not types themselves. The query processor should always report errors based on the real types, of course if the processor wants to keep the name of the type alias around for better error reporting, then it is free to do so.
We could also consider the vsisibility of type aliases of a module, perhaps we want to allow %public and %private like annotations.