Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #51350 > unrolled thread

Forth implementation in pure Forth?

Started byAlex Dowad <alexinbeijing@gmail.com>
First post2016-09-26 18:54 -0700
Last post2016-09-28 07:59 +0100
Articles 9 on this page of 29 — 16 participants

Back to article view | Back to comp.lang.forth


Contents

  Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-26 18:54 -0700
    Re: Forth implementation in pure Forth? Michael Barry <barrym95838@yahoo.com> - 2016-09-26 20:20 -0700
    Re: Forth implementation in pure Forth? Paul Rubin <no.email@nospam.invalid> - 2016-09-26 21:37 -0700
      Re: Forth implementation in pure Forth? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-27 08:27 +0200
        Re: Forth implementation in pure Forth? Cecil Bayona <cbayona@cbayona.com> - 2016-09-27 02:22 -0500
        Re: Forth implementation in pure Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 14:22 +0200
          Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-27 05:42 -0700
            Re: Forth implementation in pure Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 15:23 +0200
              Re: Forth implementation in pure Forth? rickman <gnuarm@gmail.com> - 2016-09-28 11:13 -0400
            Re: Forth implementation in pure Forth? Alex <alex@rivadpm.com> - 2016-09-27 14:25 +0100
              Re: Forth implementation in pure Forth? Alex <alex@rivadpm.com> - 2016-09-27 14:27 +0100
        Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-27 05:40 -0700
          Re: Forth implementation in pure Forth? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-27 15:47 +0200
          Re: Forth implementation in pure Forth? hughaguilar96@gmail.com - 2016-09-27 11:43 -0700
            Re: Forth implementation in pure Forth? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-09-27 21:51 +0100
              Re: Forth implementation in pure Forth? Cecil Bayona <cbayona@cbayona.com> - 2016-09-27 16:04 -0500
      Re: Forth implementation in pure Forth? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-26 21:10 -1000
    Re: Forth implementation in pure Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 14:18 +0200
    Re: Forth implementation in pure Forth? stephen@mpeforth.com (Stephen Pelc) - 2016-09-27 12:12 +0000
    Re: Forth implementation in pure Forth? Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-09-27 21:04 -0400
      Re: Forth implementation in pure Forth? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-28 10:57 +0200
        Re: Forth implementation in pure Forth? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-27 23:19 -1000
          Re: Forth implementation in pure Forth? rickman <gnuarm@gmail.com> - 2016-09-28 11:42 -0400
        Re: Forth implementation in pure Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-28 04:51 -0500
        Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-28 03:41 -0700
          Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-28 03:51 -0700
          Re: Forth implementation in pure Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-28 20:42 +0100
    Re: Forth implementation in pure Forth? Chris Curl <ccurl609@gmail.com> - 2016-09-27 20:40 -0700
    Re: Forth implementation in pure Forth? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-09-28 07:59 +0100

Page 2 of 2 — ← Prev page 1 [2]


#51422

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-28 10:57 +0200
Message-ID<86mviscsgv.fsf@molnjunk.nocrew.org>
In reply to#51412
Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> writes:
> The best that most seem to be able to do is to write a Forth mostly in
> Forth, but not completely.  [...]  The threaded-code Forths are able
> to eliminate all but a handful of Forth words which must be coded in
> another language.

What people usually mean that their Forth is witten in Forth, is that
your "another language" is also implemented in Forth.  I.e. the
primitives may be written in an assembler written in Forth.  Such an
assembler is more an extension of Forth than a separate language.  In
which case one could kinda say that the primitives also are written in
Forth.

[toc] | [prev] | [next] | [standalone]


#51423

From"Elizabeth D. Rather" <erather@forth.com>
Date2016-09-27 23:19 -1000
Message-ID<w4udneS248W_FnbKnZ2dnUU7-RHNnZ2d@supernews.com>
In reply to#51422
On 9/27/16 10:57 PM, Lars Brinkhoff wrote:
> Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> writes:
>> The best that most seem to be able to do is to write a Forth mostly in
>> Forth, but not completely.  [...]  The threaded-code Forths are able
>> to eliminate all but a handful of Forth words which must be coded in
>> another language.
>
> What people usually mean that their Forth is witten in Forth, is that
> your "another language" is also implemented in Forth.  I.e. the
> primitives may be written in an assembler written in Forth.  Such an
> assembler is more an extension of Forth than a separate language.  In
> which case one could kinda say that the primitives also are written in
> Forth.

Only the OP can say whether that's what he meant. But, indeed, many 
Forths have been written that way. Chuck was writing Forth "in Forth" in 
this sense when I met him in 1970, and FORTH, Inc. has never had a Forth 
implemented any other way. But as some have pointed out, of course this 
chain has to have a beginning that involves not-Forth.

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

[toc] | [prev] | [next] | [standalone]


#51441

Fromrickman <gnuarm@gmail.com>
Date2016-09-28 11:42 -0400
Message-ID<nsgobt$t98$1@dont-email.me>
In reply to#51423
On 9/28/2016 5:19 AM, Elizabeth D. Rather wrote:
> On 9/27/16 10:57 PM, Lars Brinkhoff wrote:
>> Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> writes:
>>> The best that most seem to be able to do is to write a Forth mostly in
>>> Forth, but not completely.  [...]  The threaded-code Forths are able
>>> to eliminate all but a handful of Forth words which must be coded in
>>> another language.
>>
>> What people usually mean that their Forth is witten in Forth, is that
>> your "another language" is also implemented in Forth.  I.e. the
>> primitives may be written in an assembler written in Forth.  Such an
>> assembler is more an extension of Forth than a separate language.  In
>> which case one could kinda say that the primitives also are written in
>> Forth.
>
> Only the OP can say whether that's what he meant. But, indeed, many
> Forths have been written that way. Chuck was writing Forth "in Forth" in
> this sense when I met him in 1970, and FORTH, Inc. has never had a Forth
> implemented any other way. But as some have pointed out, of course this
> chain has to have a beginning that involves not-Forth.

I believe the not-Forth beginning is only needed if you are running on 
your target.  If running on a host machine, the entire program can be 
written in Forth, no?  In fact, if appropriate words are defined, there 
is no need for an assembler written in Forth in the Forth written in 
Forth code.  All the target aware code can be on the host system only 
including the assembler.

This is really no different from any other language, is it?  To write a 
C compiler for a target, many would simply write that in C on a host 
system (or use one already written) after writing and assembler for the 
target in C on that same host system.  No need to include the assembler 
on the target unless that is what you want.

Hmmm... maybe that is a bad example as most (or all) C compilers produce 
assembly code that requires an assembler.  lol

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#51427

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2016-09-28 04:51 -0500
Message-ID<OZudnbH0lYEGD3bKnZ2dnUU7-WWdnZ2d@supernews.com>
In reply to#51422
Lars Brinkhoff <lars.spam@nocrew.org> wrote:
> Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> writes:
>> The best that most seem to be able to do is to write a Forth mostly in
>> Forth, but not completely.  [...]  The threaded-code Forths are able
>> to eliminate all but a handful of Forth words which must be coded in
>> another language.
> 
> What people usually mean that their Forth is witten in Forth, is that
> your "another language" is also implemented in Forth.  I.e. the
> primitives may be written in an assembler written in Forth.  Such an
> assembler is more an extension of Forth than a separate language.  In
> which case one could kinda say that the primitives also are written in
> Forth.

Absolutely so, yes.  And a Forth code generator written in Forth is
also a Forth program.  Of course it is possible to write Forth in
Forth.

Andrew.

[toc] | [prev] | [next] | [standalone]


#51429

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-28 03:41 -0700
Message-ID<d0f509e6-147f-46e8-969d-f61f2f10177b@googlegroups.com>
In reply to#51422
Dear comp.lang.forth,

Thank you for your many and varied replies to my post. It looks like Ulrich Hoffman's paper is just what I was looking for; thanks Jan! I will also look for Lars Brinkhoff's GitHub repo.

I'm surprised at how much confusion the idea of a "Forth implementation written in Forth (sans assembler)" seems to have raised. I was looking for exactly that, no more, no less. A Forth program which reads Forth source text and executes it.

Why would one want such a thing? One reason is for educational/entertainment purposes, something like a quine. An interesting challenge, just for its own sake, or to see how many different ways it can be done. Alex (no surname) noted that this can be done using code like:

: DUP DUP ;
: SWAP SWAP ; \ and so on

...but this is trivial and uninteresting, like this Ruby quine:

print File.read(__FILE__)

...and a null program is even less interesting. Maybe I should revise my request to "a Forth interpreter or compiler written in Forth, *without* any asm, not even using an assembler defined in Forth itself, with an explicit interpreter loop, explicit dictionary, and explicit data and return stacks".

Aside from entertainment value, something like this could be useful as part of a metacompiler. The resulting metacompiler could be executed by any other Forth implementation which happened to be available, fed its own source code as input, and would emit a standalone binary which could then be used to compile other programs.

Thanks again, all... AD

[toc] | [prev] | [next] | [standalone]


#51431

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-28 03:51 -0700
Message-ID<eb7980e5-9079-494c-9ef4-ba4f17273293@googlegroups.com>
In reply to#51429
...Just discovered that Lars Hoffman's GitHub account is an absolute gold mine. Lars, consider yourself followed!

[toc] | [prev] | [next] | [standalone]


#51448

FromGerry Jackson <gerry@jackson9000.fsnet.co.uk>
Date2016-09-28 20:42 +0100
Message-ID<nsh6eu$lps$1@dont-email.me>
In reply to#51429
On 28/09/2016 11:41, Alex Dowad wrote:
> ...and a null program is even less interesting. Maybe I should revise my request to "a Forth interpreter or compiler written in Forth,*without*  any asm, not even using an assembler defined in Forth itself, with an explicit interpreter loop, explicit dictionary, and explicit data and return stacks".
>
> Aside from entertainment value, something like this could be useful as part of a metacompiler. The resulting metacompiler could be executed by any other Forth implementation which happened to be available, fed its own source code as input, and would emit a standalone binary which could then be used to compile other programs.
>

You might find Retro interesting. It is built on the Ngaro virtual 
machine which is implemented in various languages including Forth. See 
http://forthworks.com/retro/

-- 
Gerry

[toc] | [prev] | [next] | [standalone]


#51415

FromChris Curl <ccurl609@gmail.com>
Date2016-09-27 20:40 -0700
Message-ID<04c17b71-5841-41cc-a7f3-58e75c7397d0@googlegroups.com>
In reply to#51350
It seems to me this is a silly topic. In order to implement a Forth system in 
Forth, you need a Forth system in which to implement the new Forth. 

At the end of the day, EVERY language needs to resolve eventually into 
the CPU'smachine "language". Forth can generate that itself, as can many 
other languages that are not assembly.

The only other option is a native Forth stack machine; one with a CPU 
that implements the primitive Forth instructions like SWAP and DUP and
so on. My project is along these lines. https://github.com/CCurl/Forth_C

Obviously, if you already have a Forth system, you can generate ANOTHER 
Forth system. That is easy, and it is how most mature Forths are built, 
so that must not be what you are looking for. Or maybe you just weren't
aware that this is how they are made ... ?

Additionally, it is no problem generating a Forth system for another CPU;
that is also a very common activity.

But if you (AD) want an original, "first generation" Forth system that was 
written in itself, then you are either not being clear about what you want,
or are not thinking clearly.

So what exactly are you actually asking about or looking for?

[toc] | [prev] | [next] | [standalone]


#51417

FromJan Coombs <jenfhaomndgfwutc@murmic.plus.com>
Date2016-09-28 07:59 +0100
Message-ID<20160928075904.4607d5b6@HP-6550b>
In reply to#51350
On Mon, 26 Sep 2016 18:54:37 -0700 (PDT)
Alex Dowad <alexinbeijing@gmail.com> wrote:

> Greetings all,
> 
> A Google search reveals many free Forths written in C,
> assembler, Java, etc. But none written in Forth itself. Does
> anybody have one available?
> 
> If your answer is "write one yourself"... well, I've written
> several, but would like to compare.
> 
> Thanks, AD

Perhaps this from EuroForth might be relevant:

Abstract

This document defines a Forth threaded code (inner) interpreter
written entirely in high level standard Forth. For this it
defines a specific threaded code structure of colon definitions,
a compiler from high level Forth to this threaded code and a
corresponding inner interpreter to execute it. This inner
interpreter can run in a stepwise way and so gives the
surrounding environment control of its execution behavior. A
real time environment thus might slice the execution of threaded
code in small pieces and provide an interactive command shell
while still meeting its real time requirements.


nn: Implementing the Forth Inner Interpreter in High Level Forth
http://www.complang.tuwien.ac.at/anton/euroforth/ef16/papers/hoffmann.pdf
Video:
https://wiki.forth-ev.de/doku.php/events:euroforth-2016:interpreter


Jan Coombs

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.forth


csiph-web