evincarofautumn / kitten

A statically typed concatenative systems programming language.

Home Page:http://kittenlang.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

define necessary?

trans opened this issue · comments

commented

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 use define? So for example:

define bottlesOfBeer (int ->):
  -> x;
  x verse
  if (x > 1):
    (x - 1) bottlesOfBeer

could just be

bottlesOfBeer (int ->):
  -> x;
  x verse
  if (x > 1):
    (x - 1) bottlesOfBeer

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 — words
  • type — data types
  • trait — trait declarations
  • instance — trait instances
  • permission — permissions
  • synonym — 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.

commented

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.