2012-04-30

{parameterized, variant} records

adda/type/{parameterized, variant} records:

4.15: adda/dstr/variant vs parameterized records:
. a parameterized type is not the same thing
as a variant record;
the parameter of a parameterized record type
works like a function, representing a set of subtypes;
eg, it might determine the max length of an array,
or the type of a list's items .
. the variant record, on the other hand
-- which is what is expressed by
.(x? #1: v.t1; #2: v.t2; #3: v.t3 #.)  --
is not requiring a parameter to express its discriminant;
the discriminant can be changed dynamically,
and must be changed in order to mirror
any changes in the way the variant is used .
. conversely, if the discriminant is changed,
then the current variant it represented must be erased,
as the new variant is initialized .
. a discriminant is something like a subtype tag in oop,
but there can be more than one of them
(using a sequence of case stmts).
. there can also be nested variant records
(using nested case stmts).
. we could say the syntax for a variant record
was simply any record type that included case stmts;
but what if the discriminants were also the parameters ?
. it simply sets the initial variant;
likewise, an array sized contstrained by a
type function's parameter
might still be dynamically resized,
ie, it would be specifying only the initial subtype .

4.14: mis.adda/type/parameterized record literals:

. if a record type literal is parameterized
what does that look like?
a record type literal is a type instance
so it would never be parameterized;
because,
the whole reason for parameterizing a record,
is to use the record type's name like a function .
4.15:
. the reason a record type is parameterized
is that it actually represents a set of types,
just like a function represents a set of mapping points .
. and although you might never use that in the usual programming,
you would need to talk about all sorts of types while
metaprogramming (writing programs that build programs);
. like this: [4.30: revise function syntax: ]
or like something that shows it returns a type?:
((x.{1..3}).type:
   .(x? #1: variant#1; #2: vari#2; #3: vari#3 #.)
)
--. that reminds me there are
2 different things I'm trying to model!
[@] adda/dstr/variant vs parameterized records

4.16: (arg).(rec).type:
. would the type expression:  (arg).(rec).type
be a parameterized record type literal?
(ie, a function returning a record type)
or would it be
a function returning function returning type?
well if it were (arg).(rec).t
then it would clearly be
a function returning function returning t
and not a function returning a record,
so letting .type be a special case would be confusing .

4.15: mis.adda/syntax/
confused record function with parameterized record type:
. in the current syntax, one is able to
confuse a parameterized record type with a
function that returns a record instance:
(x).(x,y:t)  -- returns a record instance,
t(x).type( .(x,y:t) ) -- returns a record type .
4.17:
. the t(x).type( .(x,y:t) ) -- returns a record type --
could be expressed as t(x).type.(x,y:t);
so, then it would read as type returns record?
how about .type`.(x,y:t) ?
4.30:
if t(x).type.(x,y:t) can be read as type returns record,
then does x.int.2 read as int returns 2 ?
how about x.int`range 2?
and so t(x).type`range .(x,y:t) .

No comments:

Post a Comment