Re: [stack] Notation for typed arrays in Cat
"Christopher Diggins" <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Apr 4, 2008 at 1:25 PM, William Tanksley, Jr <[email protected]> wrote: > Christopher Diggins <[email protected]> wrote: > > I am again playing with the idea of how to introduce typed arrays in to > Cat. > > The following is the notation that I prefer, but I am concerned about > > the confusion of ['a] meaning a list of 'a in types, and [a] meaning a > > quotation in the code: > > Factor uses {} for arrays and [] for quotations (and lists). It does > seem to me that there should be a way to denote different type > treatment, especially if the two entities behave differently in other > ways (for example, lists could be conceptually sequential, while > arrays could be conceptually parallel; thus, "i" would work on lists, > while the combinators we're talking about would be expected to execute > an array). > > Another syntax I am seriously considering is: > > uncons : ('a* -> 'a* 'a) > > cons : ('a* 'a -> 'a*) > > empty : ('a* -> 'a* bool) > > count : ('a* -> 'a* int) > > This nicely expresses "an unknown number of elements of this single > type", which is (I believe) what you mean by "array". What would an > array literal look like in Cat, though? It _should_ (one would think) > be possible to tell the difference between an untyped list and a typed > array reasonably quickly. Sorry for the confusion I am using the terms "array" and "list" interchangeably. In Cat a quotation is not a list (or array or whatever). There is also no built-in syntax for writing list literals in Cat. A quotation is [1 2 3]. A list is generated using the "list" instruction. E.g. "[1 2 3] list". We can overload "(", ")" and "," to construct lists like (1, 2, 3) but this is just syntactic sugar. What I am proposing that all lists in Cat will become either lists of "any" (e.g. dynamically typed) or can be lists of some specific type (e.g. int*, or ('A -> 'B)*) I hope this clarifies things Thanks for your feedback! - Christopher