Mercurial > hg > ishara
changeset 29:61921dceded1
More documentation on type system.
author | samer |
---|---|
date | Sat, 19 Jan 2013 17:56:21 +0000 |
parents | 673b8e45d05a |
children | 28c9ff839f38 |
files | README.txt |
diffstat | 1 files changed, 24 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/README.txt Sat Jan 19 14:40:54 2013 +0000 +++ b/README.txt Sat Jan 19 17:56:21 2013 +0000 @@ -151,8 +151,29 @@ This is a bit clunky and is a hangover from a previous method of specifying argument lists - perhaps it shoud be A@X, where X is any type of types (ie a *kind*), eg - cells(type) - arbirary list of types - {[N]->type} - list of N types + cells(type) - arbirary list of types + {[N]->type} - list of N types - + For example, consider the last_ret which calls a given function with a list of + arguments, gets all the return values and returns the last one: + function y=last_ret(f,varargin) + R=cell(1,nargout(f)); + [R{:}]=f(varargin{:}); + y=R{end}; + end + + The type of this function can be declared as: + + last_ret :: + (A{1:N}->B{1:M}) ~'a function with N arguments and M returns', + A{1:N} ~'N further arguments matching types in A' + -> B{M} ~'the first return value'. + + User-defined types + + Further types can be defined either as type synonyms written as A ::= B, where + A is the new type and B is an existing type, or in terms of user-defined Matlab + classes, such as the sequence, signal and arrow types in this library. + +