Open trans opened 7 years ago
The examples are pretty old (2014), and not very illustrative. Every top-level program element that’s not an expression begins with a keyword:
define
— wordstype
— data typestrait
— trait declarationsinstance
— trait instancespermission
— permissionssynonym
— synonyms (aliases)vocab
— vocabularies (namespaces)So parsing can’t “run away” and consume a bunch of things that look like expressions, only to accumulate a pile of hard-to-understand error messages. The redundancy makes it easier to recover from syntax errors.
Ah, right, I knew type
. The rest not so much. I understand the rational, although it's too bad as I think name primacy tends to be a bit nicer to read, especially when one element in particular will largely dominate every program. I suppose that's why Chuck Moore chose :
to mean "define".
Perhaps something more like the following is not out of the question?
bottlesOfBeer fn(int ->):
Bool type:
Another option is having each program element in separate sections (sort-of Cobol style). Personally, I think that's an underrated approach.
That reminds me, how does Kitten handle exporting and importing?
P.S. About these keywords, I notice that "define" is a verb, the rest nouns.
Looking over the examples it appears every definition starts with
define
and there are no other "starting words" to be found. If that is so, is it really necessary to even usedefine
? So for example:could just be