Re: [stack] S-K Construction of Dip?

Manfred Von Thun <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <C2171F01.7E6%[email protected]>


On 24/2/07 9:45 PM, "Brent L Kerby" <[email protected]> wrote:

[..]
  
> But, if you can show me a really nice flat programming language, you may be
> able to change my mind :-)
> 
Not a NICE flat programming language, but interesting in the present
context: 
machine language or assembler.

Consider a very small procedural programming language with nesting: A
statement is either an assignment, or a compound statement which is a
sequence of statements, or a conditional consisting of a test and a
statement, or a loop consisting of a test and a statement. (Not even
procedure calls allowed). So a statement can contain other statements,
nested arbitrarily deeply. Nothing flat here.

Compile into machine language or assembler. Assignments translate into a
sequence of instructions, but that is of no interest here.  Compound
statements translate into the sequence of instructions produced by the
sequence of statements, also of no interest. But interestingly, conditionals
and loops are  translated into a FLAT sequence of instructions containing
two new instructions that are not in the source language: conditional and
unconditional JUMP instructions. We also have the notion of a program
counter, which is simply incremented by most instructions. Only the JUMP
instructions change the program counter explicitly.

We have: nested source language, flat target language. Price: extra
instructions in the target language, plus new concept.

A possible technique for flattening a concatenative language? Probably
yes. But the flattened version will not be pretty.

If the procedural language also has callable procedures, there is another
level of nesting. It is flattened by introducing a runtime stack and new
instructions CALL and RETURN for pushing and popping return addresses.

Powerful? Yes. Pretty? No.

Maybe this will give people some ideas about flattening concatenative
languages.

  - Manfred




[Non-text portions of this message have been removed]
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.