K, Dylan, etc etc etc.

Raul Deluth Miller rockwell@nova.umuc.edu
Fri, 10 Feb 1995 13:37:02 -0500

First off, sorry I've been so sketchy about K.  I'm told that release
1.0 of the documentation has been written as of this week, and that
the language is expected to have a significant overhaul next year
before it's publically released.  However, I think there's a lot of
neat features in it...

(1) lambda calculus.
(2) statement oriented
(3) line end equivalent to ; [significant for both code and data]
(4) elegantly simple (only about 40 symbols: apply, mapcar, ...)
(5) fast [implementation not language, but perhaps relevant...]
(6) context free grammar (unlike LISP, APL, J, ... dunno about dylan)
(7) integrated (high level) support for GUI and other communications
(8) interactive environment.
(9) runtime linking with compiled low-level code
(10) constant time array append
(11) constant time array access
(12) all objects displayed in executable format (except in gui, where
"executable" isn't a meaningful concept. )
(13) same notation for function call and array reference
[mathematically, the concepts are equivalent].
(14) symbol tables as first class data (good for modularity... in
"unix" or "dos" terms, think of it this way: you can put directories
inside of files.)

The K GUI is, perhaps, one of it's more interesting features.  In a
classic sense, the GUI is not a part of the language.  More generally,
most languages don't really address issues of i/o and formatting at a
very high level...  Exceptions include things like spreadsheets, and
perhaps WWW -- these aren't particularly shining examples of
programming language design, but they're good examples of high-level

A bit about K's notation.  If you have a three dimensional array, you
can get at a specific element using array[1;2;3].  If you have a
function of three arguments, you can get a specific value using
function[1;2;3].  If you are interested in a specific sublist of the
array you can express that as array[1;2;].  If you wish to curry the
function to yield a function of one argument you can express that as
function[1;2;].  Function bodies are set off using curly braces (just
like C).  Unlike C, however, K has a lambda notation, which means that
you've dummy arguments at the begining of the function body..

I wish I knew enough K to show examples of the code, but .. well, with
the caution that this is probably wrong (I'm just guessing):

binsearch: {
	[list; target]
	low: 0
	high: (#list)-1

	while [ low < high
		guess: (low + high) % 2
		if [ target > guess
			low: 1+guess
			high: guess

This is pretty basic, so I don't think there's many things I could
have screwed up.  But, if I had access to the documentation, the first
thing I'd do is look up the syntax for 'while'...  And, if I had an
implementation, it would take me maybe 30 seconds to test it (cut and
past into K, then type binsearch[2 3 5 7 11; 3])...

Enough for now...

Raul D. Miller
Account expiring on 13 Feb'95: <rockwell@nova.umuc.edu>/<rockwell@nova.umd.edu>
Temporary alternative:           <rdr@home.merit.edu>/<rdr@legislate.com>
Temporary alternative:     <raul@tad.micro.umn.edu>/<raul@gopher.legislate.com>