Do any programming languages have everything as first-class citizens? This includes not only functions, but types, classes, etc. too. Having everything first-class can be a flexible and non-kludgy alternative to generics/templates.
Name:
Anonymous2012-03-10 18:21
>>26
It's probably difficult to think of an actual use case that would be useful, but an example:
array : type -> int -> type
arr = instance (array int 4)
arr2D = instance (array (array int 4) int 4)
array2D_t : type -> int -> int -> type
array2D_t item_t x_dim y_dim =
array (array item_t x_dim) y_dim
arr2D = instance (array2D_t int 20 20)
weird : int -> type
weird n =
if (n % 2) == 0 then
int
else
array int 23
end
test n =
let what_now_bitch instance (weird n)
in print what_now_bitch