evincarofautumn / kitten

A statically typed concatenative systems programming language.
http://kittenlang.org/
Other
1.1k stars 42 forks source link

Make variadic “vector” and “tuple” words. #140

Open evincarofautumn opened 10 years ago

evincarofautumn commented 10 years ago

vector should take a compile-time constant size and produce a vector of that size. tuple should do a similar thing for tuples. That is, 3 vector should produce code that constructs a vector with three elements.

It is possible to type vector dependently. Pseudocode:

define vector<s, a> (s a n elems, n :: uint -> s, a vector):
  __make_vector

type elems<s, a, n>:
  if (n = 0) { s } else { s a (n - 1) elems, a }