9.4: adda/type"st:
. type"st is like the abbrev' for street,
as the word"string reminds of street-ing,
since string is an array of objects,
just as street is an array of buildings .
eg, ch.st = character string .
9.6: adda/type"tall/providing efficiency:
. concerned with efficiency,
there must be some way to specify when a value is returned directly
rather than by some indirect route (a pointer or param'less function) .
9.6: adda/type"tall/tall'ness is another dimension of type-tagging:
. tall'ness is another dimension of type-tagging .
. make it part of typedef:
.tall.z may be any {immed, ptr, code} returning z;
whereas:
.z would be the efficient z object
with no tag indicating route .
9.7: mis.adda/syntax/type modifier operator:
. wondered if \ would be good for specifying access modes: type\mode
but then for / you get /\mode which is confusion .
9.9: adda/type"enum:
. multinum lets enum have multiple codings
they stand for sets .
. they map to ints;
could also map to other types .
. that idea is showing enum is one sort of relation
. enum is supposed to be a relation that's bijective
between {symbol, binary value} .
separate dimension from binary repr of symbol
is symbol's attributes
. if the attrib's are per instance then they need to be coded too .
. but if global then acts like lisp`symbol`{properities, attributes} .
9.10: adda/syntax/generic types:
. concerning adda/type"tall,
. if the syntax is x.tall.t,
then is that mixing well with other generic types that reverse that order?:
eg, x.ch.st,
following the tall example,
it should be x.st.ch .
9.12: adda/math/how is n! like x**y ?:
n! = *(1...n),
x**y = *(.(i.1..n) i:y )
9.23: todo.adda/define types like biop relative to enclosing type:
. need way to define types like biop relative to enclosing type;
eg, t`*.biop = *(t,t).t .
9.23: adda/type"wordcode/including ascii strings:
. char type ascii could fit within 4byte words,
the head tells the size in bytes,
then to figure the number words (and get past the padding),
divide size in bytes by 4(#bytes in word)
. that divide is efficiently done as (shift 2) .
[9.29:
. likewise, words made from other words could be strings of word`parts
where the header said what type the multibyte string was holding .
] .
9.24: adda/type"uniop:
. symbols can be functions without having to declare such,
the use of a param' decl' is needed only to tell the parser
whether there's an implicit (apply)
ie, does it have to consider the symbol as being followed by its arg ?
. the symbol can also decl' itself as param'less
but then later take a param by using an explicit (apply):
eg, (f.tall apply x).
9.25: adda/type"streaming:
. when piping functions together, f o g (x)
f's output is going to g's input;
and this works really efficiently if both are streaming in chunks:
f produces a list item, then g consumes a list item .
. the type stream should be reserved as a pragma
for indicating that a routine's inout is being handled like this .
. a param' is datatyped a file rather than a stream
whenever it needs to input the entire file
before being able to work on any of it .
. if (f) is streaming to file function (g)
the system can still use a piping buffer the size of file items,
but then unlike pipes between streaming routines
the system is having to swap out pages of g's mem'
as it builds this huge d'str to absorb the entire file:
f -> pipe.buf -> g -> dstr -> output .
9.26: adda/syntax/{records, arrays, functions, pointers}/{literals, type.decl's}:
. does adda have a directory syntax?
dir's and rec's are similar, but dir is ptr based .
. what is the record syntax that module headers can use
to show how their operations should be placed in menu's ?
r`: (fields) -- named rec literal
d/: (subdir items) -- named dir literal
. that is confusing;
rec's root is like a label to rec,
so label syntax seems natural;
but, first:
the theory of how {ptr, fun, aray}`decl's all fit together ?
f(x).y
, a#(x).y
, d/.y
, r`.() .
. rec is like an array in name;
eg, makes sense to have r`(..).Y;
but then separating names from types .
. conversely, A(X).Y can be expressed as a
A= (x`1:y, x`2:y, ...)
. and:
(x`1: y`2, x`2: y`2, ...) is (X).Y .
. all these types have literals whose type is identifiable as syntax,
except the ptr,
so using label syntax to mean a const we can have:
A: (x`1: y`1, ...)
Rec: (x`1: y#1`1, x`2: y#2`1,...)
or to mean a var:
A: (x`1.Y, ...)
Rec: (x`1.Y#1, x`2.Y#2,...) .
f: {.(x).y .... }
A: (.(x).y ... )
[9.29:
. notice how if they are labels,
then having more than one label tagging an object
would mean they are all aliases .
]
. the ptr still needs a literal,
hint, it's like a function, how?
value assigned to ptr is setting fun's arg .
. to stay consistent with decl's,
may look like this:
p/: (rec), -- or:
p/: var`decl
p/: value
. to have a const ptr:
p:/ literal
. um, keep in mind
p/.y is shorthand for p is type /.y, or p.(/.y)
and all labels should be typed, so do
p./: -- or:
p/:
. you can also use typing shorthand for
{rec, array, fun}
but with caveat that it's not needed due to
literal's syntax is providing typing .
. since .(x) is the sign of being a function type,
this is composable:
eg, f.(x).(x).y declares f returns a function,
so,
rec's can't use literal types? on the contrary:
the fun isn't just the .(x) it's the .(x).y,
having just the .(,,,) means that rec is the terminal type .
[!] adda/declaring externals with "<<,,,>>
. rec syntax can be
r`.(...) or
r.(...)
. like array, rec can be traversed with (k in rec`keys) .
array and rec can be accessed simply:
. the [a#(x).y].syntax is a convenience
to express the array like a function:
. a# or a#
is also expressable like an rec: a` .
. an array can be decl'd like a rec:
a.(x.y, x`2.y, ...)
. a rec`decl can use params to indicate keys
and then have ret`type list compon'types:
r`(x.t).(t1, t2, ...) .
. f(x.t).(t1, t2, ...) -- returns a rec with f(x),
while
r`(x.t).(t1, t2, ...) -- returns a rec with (r)
[9.29:
. this looks at first glance to be saying that r has a component
that is described by a parenthetical
-- like being expressed by a result rather than a literal symbol .
(allowing that sort of thing is what can make c so confusing)
]
. keep in mind that
there are simple subsets of adda to be pointed out for beginners
. adda's being a full lang with a simple subset .
9.26: adda/type"enum:
. math uses the same enclosure for type systems
that it does for vectors: <,,,>;
enum is
<
values: {,,,},
`++, `--, ...
> .
9.30: adda/unifying functions and datatypes:
. a subroutine is a sort of datatype definition
where the act'rec is the instance structure,
and apply is the only operation;
indeed, the apply.op also doubles as the alloc, init, and dealloc .
. other possible parts about the type include
( f`options:
. client`locals that are for the client to change options;
these are like the preferences on a mac app'
or the environment var's of a unix command .
. they are like parameter's
but the binding applies to all future calls made by the current client .
. the options preferred by each client are also filed
(persistent between client activations)
, f`mem:
. client`locals that are for private use by the subroutine;
these persist between calls to f .
--. whether this routine is a local or part of a shared library,
a mem or options declaration implicitely means
declaring a record in each client
that persists between calls made by the client .
. in oop`lingo, {option, mem}.space is named "(class var's) .
, f`filed:
. client`locals like f`mem, but these are filed
(persistent between client activations, like c.lang's static locals)
, f`exceptions:
. these are related to options,
and are meant to model how mac has dialogs with the client
rather than be like the typical exceptions
as found in ada or python:
. if the client can provide an adequite handler for a problem,
then the subroutine can proceed rather than terminate abnormally;
eg,
f`ex#[file not found](place.io, file)`=
"( [ask user for file`location](place, file) )
. like options, the way an exception`handler is defined
will affect the all subsequent calls that need interaction;
. alt'ly, a client can use exceptions like {ada, python} does:
by not defining a handler, calling the subroutine,
and then checking whether it terminated abnormally
by using its exception names as if they were truth var's:
f`[div by zero] ?
[suggest client use the symbolic math pkg]
--. whether handling the exception during the sub`call or afterward,
exceptions are listing all the externalities the sub' depends on,
and handlers are codifying ways to insure problems get unkinked .
. why wouldn't you just make sure things were unkinked in the first place?
as a pythoneer pointed out:
it's cheaper to just assume things are ok,
and then fix them when they aren't;
also, rapid prototyping is helpful for testing out ideas,
and there can't be any rapid design
when the programmer has to prove his program doesn't need safety gear
like array bounds checking and raising exceptions .
. exceptions also make sure that clients know it when their
servers are not dealing properly with dependencies .
)
todo:
. how is a literal look? just keep things grouped:
f(x).y . f`...
but how to define a type where you want to say various functions
doing it like a type without referening to name of instance var?
t.type = ( (x).y; `... ) .
. once a sub's body is defined,
adda can tell you what the act'rec looks like
ie the whole variant record
once all the optional declare blocks are taken into acct .
. this info might be of use by the compiler
for figuring how large to make the initial act'rec .
then again, that's only without recursion .
prog:
( args
, locals
, { sub1: (args, locals)
, sub2: (args, locals)
}
) .
10.7: todo.adda/type"ch.st:
. should there be any dif'tween string and array of char?
adda/type"enum:
10.17: sci:
. how to define enums?
en.type`= (symbol).Z;
trafficlight.type`= en(red, yellow, green);
x.trafficlight .
10.20:
. enums are encoding like records can
only it's being done on a set, not a list .
...
. dimensioning can help with arithmetic on enums
as there are 2 ways
just as there are with pointers:
consider each enum symbol an increment,
or consider them to be the ints doing the encoding .
. since the encoding can be adhoc and discontinuous,
how should the system handle moving to a
code that doesn't map to symbol?
. the default should be pointer arithmetic,
ie, en`+2 is 2 symbols ahead of the current one .
then dimension as int for working with codes .
10.13: adda/pointer/implicit heap usage:
. having an explicit pointer in your type.def
usually means
you want the option to alias another symbol;
however, for the sake of completeness,
if it's assigned a value of the target`type
when it's not even pointing at anything,
then the assignment could mean
that an object is to be alloc'd on the local heap,
and the value assigned to that;
ie,
ptr/`= val is then the same as
ptr`= new(value) .
10.17: adda/syntax/type.literals:
. is my syntax such that I can unambiguously
refer to type.literals?
/.type -- ptr
().t -- function
#().t -- array
`().t -- record .
10.19: adda/syntax/type.literals:
. the current record type specifier
is the same as scope declared
or record value instantiation?
but this may not be a problem
since type.literals are needed only when expecting a type.def' .
10.20: adda/syntax/type.literals:
. component names include: head, face, body .
. types`faces are the list of interfaces it responds to .
. eg,
t`body is ...
t`face is ... (more than 1? use set);
each face can be symbol or literal .
. type`literal is <...>
eg, num`face is
{
int, real,
< ;;;
uniop: -, /; biop: -, +, /, *
>
} .
10.20: adda/syntax/inequalities:
. x<= c is same as
x in -infinity ... c .
10.21: adda/syntax/type.literals:
< ;;;
faces: ,,,;
uni:,,,;
bi:,,,;
multi:,,,;
fun: ,,,;
>
. the multi is binary infixes that are associative can be grouped
like * and unlike / .
. the functionals include inputs or outputs that involve
types other than the current one,
so that definitions must include those types .
. the use of the <;;;> enclosure for this literal
is so that (,,,) can mean a record.type,
and {,,,} can mean an enumeration.type .
[and <,,,> can mean vector]
10.22: adda/syntax/unions:
t.type`= t1 u t2 u
10.24: adda/syntax/type decl's:
. labels should be used for all constants,
eg, num.supertype: <...> .
and type decl's should always be considered constant ...
. couldn't ever use the idea of a variable type?
eg:
protector.type`= fighter;
robot.protector;
protector.type`= negotiator .
10.29: adda/syntax/type`literals:
. 3 main type.literals are
( set -- listing literal values of enum'd .
, tuple -- listing components of record type,
, vector -- abstraction <...>-list
) --. in the <...>, there can be keywords
that can sort out the oop details .
[11.9:
. the <...> brackets are associated primarily with vectors
only because that is usally one's first exposure to the idea of
a list refering not to members,
but to attributes of members .
. the pointy enclosures remind us that items are indicating
the numeric components of each dimension
which in turn expresses the direction towards which
a value is pointing at in a multi-dimensional space
(planes, volumes, hyperspaces, ...
vs the single-dimensional space of a scalar in reals ) .
] .
11.16: adda/syntax/char.string quotes:
. for strings that might include unbalanced paren's,
use "[];
if the string could include unbal'd instances of every enclosure pair
then use markup: [!]"( .... [!]) .
11.18: adda/type"unions:
. the reason c needs different operations for
{bit-wise, boolean}{and, or, not}
is that, in c terms,
every int is a union of (truth, int, array of bit) .
. notice c does have a (not) for ints
that works like a complement:
. the bit-wise complement of an unsigned int
does give its complement:
eg, complement of the base-4 numbers is:
00(0): 11(3)
01(1): 10(2)
10(2): 01(1)
11(3): 00(0)
[... don't you have to add one?
I think the complement of x is base-x ]
. how is adda doing unions and translating to c?
{ x.{truth, int, #.bits} }
truth`x -- needs a type.id possessing it .
. you could also make explicit the type
x.truth
but then this requires decl's to be placed in a decl'zone,
so you know whether dot-type is a decl
vs a union member selector .
. may want to divide cases into
high level union -- where tag is enforced --
vs low level -- where unchecked conversions are allowed .
12.29: adda/enum.type:
. enum.type actually refers to enumeration of values .
. review def enumeration: detailed or seriatim account .
No comments:
Post a Comment