Re: Computer Language Question
From: | Keith <kam@...> |
Date: | Tuesday, November 26, 2002, 20:55 |
> Also, while working as a Unix sys admin and studying Mongolian I have
> thought about (but not yet worked on) a unix shell based on Mongolian
> grammar. At least a little bit of it. Mongolian is strongly SOV, and
> unix is basically VSO. So instead of a normal unix command like:
> mv file1 file2 -- move file1 into file2
> it would read like:
> file1 file2 mv
> Should be easy to do, but I've never gotten around to it.
> David Stokes
Well FORTH and its derivatives (Postscript and the Klingon computer
language) work just like this. It's called "Reverse Polish Notation" --
anyone know why? Some early pocket calculators worked like this too. You
feed in values and they go on to a stack, then when you enter an
operator (equivalent to a verb) the appropriate number of values are
pulled off the stack and replaced by the result. Most compilers and
interpreters work like this internally anyway. The advantage is that you
have no need of parentheses (the complete antithesis of LISP = "Lots of
Irritating Silly Parentheses").
Example :
(2 * 5) - sin(pi / 8) becomes
2 5 * pi 8 / sin -
where "sin" is an 'intransitive verb', "-" a 'transitive verb' (sub. and
obj. distinguished by order) and "*" a "verb" needing two noun phrases
both of which are equivalent grammatically and semantically (order
depending on emphasis ???)
Detractors to Forth call it a "write only language", mind you that's how
I often feel about C :-)
Keith
Replies