Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Symbolic: The KBNK recognizer

Author: Ian Osgood

Date: 17:09:02 02/24/04

Go up one level in this thread


On February 24, 2004 at 00:53:15, Christophe Theron wrote:

>On February 23, 2004 at 17:55:41, Gareth McCaughan wrote:
>
>>On February 23, 2004 at 13:52:47, Christophe Theron wrote:
>>
>>> From what I see, LISP has a basic "(operator arg arg arg...)" structure
>>> (correct me if I'm wrong, the last time I looked at LISP was 15 or 20 years
>>> ago).
>>...
>>> But there is something that I find very inelegant: if one is ready to
>>> give up on the more standard "operator(arg,arg...)" or "arg1 operator arg2"
>>> (like in "a+b"), then it is possible to do it without the parenthesis!
>>
>>Yes. But then you lose some useful things.
>>
>>  - You can no longer have optional arguments or keyword arguments.
>>    (Well, more or less. You can do, e.g., something similar to C's
>>    "printf", where one parameter determines how many others to
>>    pop off the stack.)
>
>
>
>It is not a problem in Forth to have a variable list of arguments, because you
>have all the tools you need to manage the stack. Forth is all about the stack.
>

Variable argument style is not really encouraged, however.  First, it makes
things harder to test.  Second, there are usually ways to refactor it so the
variable depth is not required.

>
>>  - The structure of the code is no longer there. You can reconstruct
>>    it, but it isn't *there* in the list structure.
>
>
>
>You use identation for that. You would ident a LISP program anyway, wouldn't
>you?
>
>
>
>
>> That makes writing
>>    macros much, much harder. Macros are one of the major reasons
>>    why Lisp is cool.
>
>
>
>In Forth, any object is a macro, in a sense.
>
>If LISP is cool because it has macros, I guess Forth is even cooler! :)
>

As with Lisp or Scheme, you have a lot of control over the compiler in Forth.
Although the mechanism is different, you can do a lot of the same things
with parsing and defining words in Forth as you can with macros in Lisp.
Forth is lower level, though, and mucking around with already compiled
code requires knowledge of the particular implementation.   Like Lisp,
you can build up source dynamically at compile time if you wish.

There are some interesting state-machine implementations in Forth
designed so that the program looks just like the state table used to
specify the state transitions.  Very elegant.

Ian



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.