[MUD-Dev] Properties of computer languages

Cynbe ru Taren cynbe at muq.org
Thu Jun 17 04:04:52 CEST 1999


Caliban Tiresias Darklock <caliban at darklock.com> asks: 

| I'm in the process of redesigning the macro language of my game, and I
| recall seeing at one time a list... a very short list... of things that a
| computer language absolutely required. Sort of a bare-bones "what you need
| to do everything you need to do in any given program". Two of the things on
| the list were conditionals (if/then/else) and iteration (for/next and
| do/while). There were either two or three other things listed, but I don't
| remember what they were. Does anyone here have a memory spark going off as
| to what list I'm talking about and where I can find it? I think one of the
| other things was something along the lines of subroutine/function declaration.

Reminds me of a question I ask C novices sometimes:  How many of
C's control structures can be dispensed with?  (Hint:  More than
you'd think at first blush.)

Answer:  If you have array indexing and arrays of functions,
you can do 'if' as 'ary[a!=b](x)', say.  So all the
conditionals can be dispensed with.  If you have recursion,
you can also dispense with all iteration constructs, of
course.  So the answer is that in principle, basically
-none- of the C 'control constructs' as usually defined
are actually necessary. :)


In general, a conditional of some sort, and recursion, are the
practical minimal set you're thinking of.  Look at the languague which
Scheme compiles down to after all macro expansion is done on something
like the Guy Steele's Rabbit compiler, and you'll see more or less
this.

You'll note that every datastructure can be understood as an example
of function definition if you wish: Guy L Steele has a classic paper
called I think "Lamdba, the Ultimate Constructor" elaborating on that.
So function definition, function invocation and a conditional get you
basically everything.  (See John Conway, say, for building up all of
arithmetic from this sort of basis.) As a practical matter, a constant
or two like zero can be useful, of course. :)

If you want to get pedantically extreme, look at the lambda calculus
literature, which for example shows you how to do recursion using
only the 'paradoxical' Y-combinator.  (If memory serves me right.)
The lambda calculus probably strips things down further than you
really care to go, however. :)

 Cynbe




_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev




More information about the mud-dev-archive mailing list