On Tue, May 17, 2011 at 1:35 AM, john skaller
<[email protected]> wrote:
>
> Felix provides arrays which include the length in the type and actually
> allows *some* algorithms to be written with these but other, clearly
> sensible, useful, and correct algorithms, cannot be written.
> For example in Felix you can't concatenate two arrays because the lengths
> can't be added by the type system.
Have you considered adding some form of dependent types to Felix to
allow expressing this sort of thing? In ATS for example you can do
something like (using lists with the length encoded because I have the
example handy):
fun{a:t@ype} list_append {n1,n2:nat} (xs: list (a, n1), ys: list (a,
n2)): list (a, n1+n2) =
case+ xs of
| nil () => ys
| cons (x, xs) => cons(x, list_append(xs, ys))
(see http://www.bluishcoder.co.nz/2010/09/01/dependent-types-in-ats.html
for examples and explanations of the syntax)
Can you give an example of how making functions take tuples improves
certain types of code or makes things possible that weren't before? I
remember way back when you used to post in the 'genstl' mailing list
about templates and C++ you experimenting with a style of functions
taking one argument which was a struct type with members for each
argument, and composing these in interesting ways via templates, but
the details are lost to my memory.
Chris.
--
http://www.bluishcoder.co.nz
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev