2010-03-30

arrays and structs compared

3.21: adda/dstr/array vs record:

. a remaining problem is how rec's and arrays
are the same yet demand differing syntax?
ie, why not rec#field?
instead of rec`field
or use array`item
instead of array#item ?
. during use, rec's and arrays are
not the same:
refering to them both as functions: domain -> codomain;
only arrays can leave some of their domain undefined
according to limits set by the attributes:
array`length
or array`last .
. also, the arg for #()
is expected to be an expression returning enum
while the x in rec`x
is expected to be a symbol literal .

. if you want an array treated as record
you can define it like one: a.(e1.t, e2, ...)
-- e2 has same type as e1
since the default typing in a list
is the same type as was last defined .

. you could also treat record like an array
by keeping type info in a tag field:
rec#.tagged
where tagged is:
( val.tall --. ptr to any type .
, typeis.symbol --. indicator of val's current type .
) .

No comments:

Post a Comment