Re: [stack] Concatenative Hardware

Don Groves <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Hi,  All --

Since I've mentioned generators and my lazy list example, I may as well
present the entire design for discussion. Also, I've decided on a name
change. Instead of Catenate, I've decided on ACL. ACL could stand for
A Concatenative Language, or Another Concatenative Language, or
Anterior Cruciate Ligament, but it doesn't have to. It will be  
referred to
simply as ACL.

A generator is a persistent function. When activated, it pushes a  
copy of
itself on the stack. The copy performs the generative function and  
remains
on the stack until specifically dropped. Each time it comes to the  
top of
the stack it generates a value according to its definition.

Example: [1 2 ...] defgen Z+

Z+ is now a generator a copy of which will generate positive integers as
long as it remains active (until dropped from the stack).

stack:
=> Z+

yields -

stack:[2 3 ...] 1
=>

The next time it comes to the top of the stack, it will generate a 2,  
thusly -

stack:[3 4 ...] 2
=>

This behaviour continues until the user/program decides to stop it.  
Thus,
the ellipsis generator, ..., can mimic an infinite list. Z+ is  
included in the
ACL standard library.

This form of generator may also be finite: [1 3 ... 99] defgen odd<100
behaves like this -

stack:
=> odd<100

stack:[3 5 ... 99] 1
=>
... and so on until 99 is produced, at which point the generator copy
self-destructs.

ACL will have other generator forms, such as the Fibonacci sequence.

Comments, suggestions, etc., are solicited and greatly appreciated,
Don Groves

"Computers are like Old Testament gods; lots of rules and no mercy."
  -- Joseph Campbell
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.