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


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

Re: EXIT THEN

Started byGerry Jackson <gerry@jackson9000.fsnet.co.uk>
First post2017-01-23 11:22 +0000
Last post2017-01-23 21:04 +0000
Articles 10 — 3 participants

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


Contents

  Re: EXIT THEN Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-01-23 11:22 +0000
    Re: EXIT THEN hughaguilar96@gmail.com - 2017-01-23 10:23 -0800
      Re: EXIT THEN rickman <gnuarm@gmail.com> - 2017-01-23 15:05 -0500
        Re: EXIT THEN hughaguilar96@gmail.com - 2017-01-23 21:58 -0800
          Re: EXIT THEN rickman <gnuarm@gmail.com> - 2017-01-24 03:53 -0500
            Re: EXIT THEN hughaguilar96@gmail.com - 2017-01-27 18:55 -0800
              Re: EXIT THEN hughaguilar96@gmail.com - 2017-01-28 16:06 -0800
              Re: EXIT THEN hughaguilar96@gmail.com - 2017-01-29 22:26 -0800
              Re: EXIT THEN hughaguilar96@gmail.com - 2017-03-22 07:04 -0700
      Re: EXIT THEN Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-01-23 21:04 +0000

#54295 — Re: EXIT THEN

FromGerry Jackson <gerry@jackson9000.fsnet.co.uk>
Date2017-01-23 11:22 +0000
SubjectRe: EXIT THEN
Message-ID<o64ouj$ofi$1@dont-email.me>
On Sunday, January 22, 2017 at 10:30:17 PM UTC, hughag...@gmail.com wrote:
 > On Sunday, January 22, 2017 at 2:15:27 AM UTC-7, Gerry wrote:
 > > On 21/01/2017 02:55, hughaguilar96@gmail.com wrote:
 > > > On Friday, January 20, 2017 at 6:47:45 AM UTC-7, Gerry wrote:

...

 > I didn't notice that the code had OF rather than IF inside of it. I 
agree that using OF outside of a CASE is non-standard.

Hence my question below about whether you ever fully read a post before 
attacking.

 >
 > > > Here we have Gerry accusing HAA of being a "standard Forth hater" and
 > > > saying that his use of END will "lead to your posts being ignored."
 > > > These are strong words --- also idiotic --- END is trivial to write
 > > > in standard ANS-Forth.
 > >
 > > Don't you ever read a post properly? Or do you just take in a 
sample of
 > > words from a sentence and then enter attack mode, inventing things
 > > people didn't write? I wrote "carrying on griping and sniping about 
the
 > > standard is tedious and will lead to your posts being ignored". I
 > > suspect you've already achieved that status with many people.
 >

...

 > > > This is what Elizabeth Rather
 > > > demands --- this is the same as in COBOL in which all programs
 > > > were written in raw COBOL without any help from any code-library
 > > > whatsoever --- this was done in COBOL because the stated goal was
 > > > that the programs would be readable by non-programmers (mostly
 > > > business majors) who have learned raw COBOL but who haven't learned
 > > > about any extensions (called "subroutines").
 > >
 > > I don't understand why you waste your time writing crap like this,
 > > nobody reads it, you'd be better off spending your time getting on 
with
 > > Straight Forth - or even finding a garage with some screws that need
 > > sorting :)
 >
 > I don't understand why you waste your time defending crap like 
ANS-Forth. Nobody uses ANS-Forth

I don't defend all of it, many of your criticisms are valid e.g. PAD 
moving around is stupid (but understandable in a historical context). 
But then it is trivial to define a text buffer and use that ignoring PAD 
totally.

I use, and I suppose thereby sort of defend, ANS Forth because I can use 
other people's code if I wish e.g. your String Stack, your Novice 
package, the FFL, the Forth scientific Library. Some years ago I used 
Anton Ertl's Gray parser generator 'out of the box' and extended it to 
do what I wanted. I can use ANS standard code posted here if I wish. I 
can write tools that others can use on different Forth systems. Sure ANS 
Forth sometimes gets in the way but there are always ways round it.

Is that enough reasons?

 > --- you'd be better off spending your time helping me with Straight Forth

Sorry I've enough on my plate with other projects, family life etc.

 > --- or just become a COBOL programmer, as there is some employment 
opportunities still available for COBOL, which is not true of ANS-Forth.

Now you're being silly.

 >
 > ANS-Forth is total crap!!! Just press the flush lever

Well until something better comes along ...

 > --- I think the ANS-Forth enthusiasts can't admit a mistake and so 
they continue to defend ANS-Forth decades after it became obvious that 
it was a mistake --- this is very similar to a bad poker player who 
continues betting on his pocket tens after the flop comes all faces and 
aces and the opponents have begun betting and raising.

I wouldn't know about that.

-- 

Gerry

[toc] | [next] | [standalone]


#54308

Fromhughaguilar96@gmail.com
Date2017-01-23 10:23 -0800
Message-ID<1247513d-993c-4113-94d9-88311542572b@googlegroups.com>
In reply to#54295
On Monday, January 23, 2017 at 4:22:31 AM UTC-7, Gerry wrote:
> On Sunday, January 22, 2017 at 10:30:17 PM UTC, hughag...@gmail.com wrote:
>  > I don't understand why you waste your time defending crap like 
> ANS-Forth. Nobody uses ANS-Forth
> 
> I don't defend all of it, many of your criticisms are valid e.g. PAD 
> moving around is stupid (but understandable in a historical context). 
> But then it is trivial to define a text buffer and use that ignoring PAD 
> totally.
> 
> I use, and I suppose thereby sort of defend, ANS Forth because I can use 
> other people's code if I wish e.g. your String Stack, your Novice 
> package, the FFL, the Forth scientific Library. Some years ago I used 
> Anton Ertl's Gray parser generator 'out of the box' and extended it to 
> do what I wanted. I can use ANS standard code posted here if I wish. I 
> can write tools that others can use on different Forth systems. Sure ANS 
> Forth sometimes gets in the way but there are always ways round it.
> 
> Is that enough reasons?

This is a common rhetoric technique. The ANS-Forth cult say that anybody who opposes ANS-Forth is opposed to having a standard and wants a complete free-for-all. The implication is that ANS-Forth is the only choice for a standard.

This is very similar to how a politician says that apple-pie is good, and then says that anybody who opposes his run for office must hate apple-pie. Of course, everybody likes apple-pie, so the implication is that everybody should vote for him.

I think that a Forth standard is good. Straight Forth makes sense for a desktop-computer system --- I'm dubious of the need for a micro-controller Forth, and I'm not really qualified to design a micro-controller Forth --- I wouldn't be opposed to such a thing if people better qualified were to design one, and I would want Straight Forth to support a cross-compiler for any micro-controller Forth.

I can foresee several Forth standards existing at the same time. Straight Forth would be for cross-compiling, and for numerical programs (because it has ratios which are more precise than IEEE-754 floats). Oforth has parallel execution and tagged data; the tagged data makes it a scripting language similar to Scheme/Lisp and all of their derivatives (Ruby, Python, Factor, etc.), and I'm not really clear on what the parallel coroutines are for. Ilya Tarasov seems to be fascinated by the need for IEEE-754 floats with their huge range, whereas I don't think the huge range is important --- a compromise could be reached here in that two Forth standards could be compatible in every way except for their definition of what a number is (I say a ratio, and Ilya says a float) --- programs could compile and run on either system without modification, although they would produce slightly different results (also, programs that need the huge range will fail completely on my system with the smaller range).

I'm okay with people taking Forth in different directions --- it is a good idea to have communication though, so there aren't pointless incompatibilities between the Forth standards --- but it is possible to have different Forth standards with different purposes in use simultaneously.


ANS-Forth doesn't have any only purpose except to be a marketing gimmick from Forth Inc.. --- it is crap --- everybody who supports ANS-Forth is essentially an unpaid salesperson for Forth Inc., the majority of whom are not capable of writing even the simplest Forth programs.

>  > --- I think the ANS-Forth enthusiasts can't admit a mistake and so 
> they continue to defend ANS-Forth decades after it became obvious that 
> it was a mistake --- this is very similar to a bad poker player who 
> continues betting on his pocket tens after the flop comes all faces and 
> aces and the opponents have begun betting and raising.
> 
> I wouldn't know about that.

ANS-Forth is founded entirely upon 1970s technology. It is basically the corpse of Charles Moore's Forth work from the 1970s, warmed over. This was good technology in the 1970s, similar to how pocket tens are a good hand in poker pre-flop --- the flop (the invention of personal computers) killed the hand though --- ANS-Forth should never have become the standard, because it was a losing hand in 1994.

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


#54318

Fromrickman <gnuarm@gmail.com>
Date2017-01-23 15:05 -0500
Message-ID<o65nij$hf7$1@dont-email.me>
In reply to#54308
On 1/23/2017 1:23 PM, hughaguilar96@gmail.com wrote:
> On Monday, January 23, 2017 at 4:22:31 AM UTC-7, Gerry wrote:
>> On Sunday, January 22, 2017 at 10:30:17 PM UTC, hughag...@gmail.com
>> wrote:
>>> I don't understand why you waste your time defending crap like
>> ANS-Forth. Nobody uses ANS-Forth
>>
>> I don't defend all of it, many of your criticisms are valid e.g.
>> PAD moving around is stupid (but understandable in a historical
>> context). But then it is trivial to define a text buffer and use
>> that ignoring PAD totally.
>>
>> I use, and I suppose thereby sort of defend, ANS Forth because I
>> can use other people's code if I wish e.g. your String Stack, your
>> Novice package, the FFL, the Forth scientific Library. Some years
>> ago I used Anton Ertl's Gray parser generator 'out of the box' and
>> extended it to do what I wanted. I can use ANS standard code posted
>> here if I wish. I can write tools that others can use on different
>> Forth systems. Sure ANS Forth sometimes gets in the way but there
>> are always ways round it.
>>
>> Is that enough reasons?
>
> This is a common rhetoric technique. The ANS-Forth cult say that
> anybody who opposes ANS-Forth is opposed to having a standard and
> wants a complete free-for-all. The implication is that ANS-Forth is
> the only choice for a standard.

I think you are mistaken about this.  There is a standard.  If you wish 
to use it, then use it and reap the benefits.  If you wish to attempt to 
define another standard, go for it.  It will be interesting to see how 
many use it.  You seem obsessed with tearing down what others have built 
up rather than just doing your own work and showing everyone how it 
should be done.

-- 

Rick C

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


#54337

Fromhughaguilar96@gmail.com
Date2017-01-23 21:58 -0800
Message-ID<372a792d-4ffc-4d05-abfe-d05296394e2d@googlegroups.com>
In reply to#54318
On Monday, January 23, 2017 at 1:05:12 PM UTC-7, rickman wrote:
> On 1/23/2017 1:23 PM, hughaguilar96@gmail.com wrote:
> > This is a common rhetoric technique. The ANS-Forth cult say that
> > anybody who opposes ANS-Forth is opposed to having a standard and
> > wants a complete free-for-all. The implication is that ANS-Forth is
> > the only choice for a standard.
> 
> I think you are mistaken about this.  There is a standard.  If you wish 
> to use it, then use it and reap the benefits.  

This "standard" was a marketing gimmick of Elizabeth Rather --- the only reason why ANSI certified it was because Charles Moore's name was listed in the document as a supporter --- this is despite the fact that Charles Moore never supported ANS-Forth.

There are no benefits to reap --- being an ANS-Forth promoter just means sucking up to Forth Inc. --- this is depravity and filth.

> If you wish to attempt to 
> define another standard, go for it.  It will be interesting to see how 
> many use it.  

I don't want a herd of sycophants such as yourself --- I am only interested in actual programmers --- you have never written any Forth code that I'm aware of; you just suck up to Forth Inc.; you disgust me!

> You seem obsessed with tearing down what others have built 
> up rather than just doing your own work and showing everyone how it 
> should be done.

This reminds me of when the Forth-200x committee (the "Committee of Can't") was insisting that it is impossible for a quotation to have access to the parent function's local variables --- then I wrote my rquotations in a few lines of easy code that work under VFX and SwiftForth and which have access tot he parent function's local variables --- then Julien Fondren described this as "hate coding."

Only in a cult does the concept of "hate coding" make sense --- ANS-Forth is a marketing gimmick, and any working Forth code written outside of Forth Inc. or MPE diminishes the marketing value of ANS-Forth --- if ANS-Forth were intended for writing Forth code, then working Forth code would be considered to be a positive contribution.

Consider this thread:
https://groups.google.com/forum/#!topic/comp.lang.forth/92KNs8p4J6Y%5B1-25%5D
I wrote an early-binding version of MACRO: and I got seriously attacked by Alex Wegel for this --- the guy is profoundly hateful! --- and Julien Fondren made a death threat against me, and Juergen Pintaske said that he wanted to kick me in the teeth (this is the same Juergen Pintaske who works for Stephen Pelc as a salesman and who suggested that Stephen Pelc and Leon Wagner be appointed "benevolent dictator for life," but would alternate years on the throne).

What exactly have "others" (Elizabeth Rather) built? PAD is the only thing that comes to mind...

In regard to SYNONYM Stephen Pelc told me to RTFM --- he means the VFX manual, not the ANS-Forth document which I have already read --- he means that I need to get trapped in vendor lock-in using his non-standard SYNONYM that only works under VFX.

I made Stephen Pelc look stupid by writing an ANS-Forth version that works fine (my ALIAS allows >BODY to work properly) --- now Stephen Pelc hates me for writing ANS-Forth code that does what he described as impossible --- he makes snide remarks such as: "Do try to keep up," and he refuses to acknowledge the existence of the disambiguifiers that make ALIAS SYNONYM and MACRO: possible.

All that I have ever seen from the ANS-Forth supporters is hate --- all they do is try to tear down my work --- a typical example is Alex McDonald saying that I have a "serious misunderstanding of how pointers work" because I wrote a SORT function that works on arrays of structs as well as arrays of pointers.

ANS-Forth is a cult --- ANS-Forth is a purely negative contribution to Forth --- ANS-Forth is the reason why Forth died out (Forth was well known and reasonably respected prior to 1994, but afterwards became increasingly unknown until our modern time in which the vast majority of CS majors graduate without having ever heard of it.)

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


#54339

Fromrickman <gnuarm@gmail.com>
Date2017-01-24 03:53 -0500
Message-ID<o674jl$en7$1@dont-email.me>
In reply to#54337
On 1/24/2017 12:58 AM, hughaguilar96@gmail.com wrote:
> On Monday, January 23, 2017 at 1:05:12 PM UTC-7, rickman wrote:
>> On 1/23/2017 1:23 PM, hughaguilar96@gmail.com wrote:
>>> This is a common rhetoric technique. The ANS-Forth cult say that
>>> anybody who opposes ANS-Forth is opposed to having a standard
>>> and wants a complete free-for-all. The implication is that
>>> ANS-Forth is the only choice for a standard.
>>
>> I think you are mistaken about this.  There is a standard.  If you
>> wish to use it, then use it and reap the benefits.
>
> This "standard" was a marketing gimmick of Elizabeth Rather --- the
> only reason why ANSI certified it was because Charles Moore's name
> was listed in the document as a supporter --- this is despite the
> fact that Charles Moore never supported ANS-Forth.
>
> There are no benefits to reap --- being an ANS-Forth promoter just
> means sucking up to Forth Inc. --- this is depravity and filth.

And just when I thought you might be calming down....


>> If you wish to attempt to define another standard, go for it.  It
>> will be interesting to see how many use it.
>
> I don't want a herd of sycophants such as yourself --- I am only
> interested in actual programmers --- you have never written any Forth
> code that I'm aware of; you just suck up to Forth Inc.; you disgust
> me!

At least I have done something useful today. :)


>> You seem obsessed with tearing down what others have built up
>> rather than just doing your own work and showing everyone how it
>> should be done.
>
> This reminds me of when the Forth-200x committee (the "Committee of
> Can't") was insisting that it is impossible for a quotation to have
> access to the parent function's local variables --- then I wrote my
> rquotations in a few lines of easy code that work under VFX and
> SwiftForth and which have access tot he parent function's local
> variables --- then Julien Fondren described this as "hate coding."

Yes, I can see the connection.  When you are on a tear everything 
reminds you of hate.


> Only in a cult does the concept of "hate coding" make sense ---
> ANS-Forth is a marketing gimmick, and any working Forth code written
> outside of Forth Inc. or MPE diminishes the marketing value of
> ANS-Forth --- if ANS-Forth were intended for writing Forth code, then
> working Forth code would be considered to be a positive
> contribution.
>
> Consider this thread:
> https://groups.google.com/forum/#!topic/comp.lang.forth/92KNs8p4J6Y%5B1-25%5D
>
>
> I wrote an early-binding version of MACRO: and I got seriously attacked by Alex Wegel for this --- the guy is profoundly hateful! --- and Julien Fondren made a death threat against me, and Juergen Pintaske said that he wanted to kick me in the teeth (this is the same Juergen Pintaske who works for Stephen Pelc as a salesman and who suggested that Stephen Pelc and Leon Wagner be appointed "benevolent dictator for life," but would alternate years on the throne).
>
> What exactly have "others" (Elizabeth Rather) built? PAD is the only
> thing that comes to mind...
>
> In regard to SYNONYM Stephen Pelc told me to RTFM --- he means the
> VFX manual, not the ANS-Forth document which I have already read ---
> he means that I need to get trapped in vendor lock-in using his
> non-standard SYNONYM that only works under VFX.
>
> I made Stephen Pelc look stupid by writing an ANS-Forth version that
> works fine (my ALIAS allows >BODY to work properly) --- now Stephen
> Pelc hates me for writing ANS-Forth code that does what he described
> as impossible --- he makes snide remarks such as: "Do try to keep
> up," and he refuses to acknowledge the existence of the
> disambiguifiers that make ALIAS SYNONYM and MACRO: possible.

You are good at making yourself look stupid anyway.


> All that I have ever seen from the ANS-Forth supporters is hate ---
> all they do is try to tear down my work --- a typical example is Alex
> McDonald saying that I have a "serious misunderstanding of how
> pointers work" because I wrote a SORT function that works on arrays
> of structs as well as arrays of pointers.

I don't believe I have ever "torn down" your work.  I would enjoy 
disdcussing Forth with you if you would just calm down and stop ranting 
about how everyone hates you and criticizes your work.

Look at it this way.  Everyone else here gets along fairly well.  Are we 
*all* in the same mutual benefit society?  Or maybe the problem is just 
how you look at things???


> ANS-Forth is a cult --- ANS-Forth is a purely negative contribution
> to Forth --- ANS-Forth is the reason why Forth died out (Forth was
> well known and reasonably respected prior to 1994, but afterwards
> became increasingly unknown until our modern time in which the vast
> majority of CS majors graduate without having ever heard of it.)

If ANS-Forth is so evil, why do you waste your time with it?  Why not do 
your own thing and ignore the rest of the Forth world?

-- 

Rick C

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


#54477

Fromhughaguilar96@gmail.com
Date2017-01-27 18:55 -0800
Message-ID<4f940b1f-b4b0-402d-a426-5f65a42d4e85@googlegroups.com>
In reply to#54339
On Tuesday, January 24, 2017 at 1:53:47 AM UTC-7, rickman wrote:
> On 1/24/2017 12:58 AM, hughaguilar96@gmail.com wrote:
> >> You seem obsessed with tearing down what others have built up
> >> rather than just doing your own work and showing everyone how it
> >> should be done.
> >
> > This reminds me of when the Forth-200x committee (the "Committee of
> > Can't") was insisting that it is impossible for a quotation to have
> > access to the parent function's local variables --- then I wrote my
> > rquotations in a few lines of easy code that work under VFX and
> > SwiftForth and which have access tot he parent function's local
> > variables --- then Julien Fondren described this as "hate coding."
> 
> Yes, I can see the connection.  When you are on a tear everything 
> reminds you of hate.
> 
> > Only in a cult does the concept of "hate coding" make sense ---
> > ANS-Forth is a marketing gimmick, and any working Forth code written
> > outside of Forth Inc. or MPE diminishes the marketing value of
> > ANS-Forth --- if ANS-Forth were intended for writing Forth code, then
> > working Forth code would be considered to be a positive
> > contribution.

Well, I wrote a <SWITCH construct in ANS-Forth that compiles into a jump-table. This is not as good as what C has because the table entries can't share local variables.

Of course, I'm just tearing down what Elizabeth Rather has built up --- with my code that works I'm shining a spotlight on the stupidity of the CASE in ANS-Forth that became the standard --- maybe Julien Fondren will describe this as "hate coding" and make another death threat against me; that should be humorous!

Here is an example of my code working:

<switch  ok-1 
:noname  cr ." one" ;             1 swof  ok-1 
:noname  cr ." neg three" ;      -3 swof  ok-1 
:noname  cr ." four" ;            4 swof  ok-1 
:noname  cr ." two" ;             2 swof  ok-1 
:noname  cr ." unknown" ;         fast-switch> fff  ok
1 fff 
one ok
10 fff 
unknown ok
3 fff 
unknown ok
-3 fff 
neg three ok

I don't allow duplicate entries. Here is an example of catching this error:

<switch  ok-1 
:noname  cr ." one" ;             1 swof  ok-1 
:noname  cr ." one" ;             1 swof *** <SWITCH statements not allowed to have duplicate targ values ***
 -> :noname  cr ." one" ;             1 swof
                                           ^
I currently limit the jump-table size to 2^16 --- this allows FAST-SWITCH> to be used to simulate a micro-processor with 16-bit opcodes. I limit the size so the programmer doesn't accidentally create a jump-table that consumes megabytes. Here is an example of catching this error:

<switch  ok-1 
:noname  cr ." one" ;             1 swof  ok-1 
:noname  cr ." one million" ;     1000000 swof  ok-1 
:noname  cr ." four" ;            4 swof  ok-1 
:noname  cr ." unknown" ;         fast-switch> bbb *** FAST-SWITCH> has too large of a range. Use SLOW-SWITCH> instead. ***
 -> :noname  cr ." unknown" ;         fast-switch> bbb
                                                  ^
I also have SLOW-SWITCH> that is like FAST-SWITCH> except that it doesn't limit the size of the table. SLOW-SWITCH> doesn't generate a big sparse table like FAST-SWITCH> does, but instead it generates a packed table and then uses BSEARCH to find the table entry. This would be needed for simulating a micro-processor with 32-bit opcodes. For the most part, FAST-SWITCH> should be used --- SLOW-SWITCH> should only be used when memory usage is an issue --- note that the value JT-LIMIT determines the limit in size of a FAST-SWITCH> jump-table, and the user can change this if desired.

Here is an example of SLOW-SWITCH> working:

<switch  ok-1 
:noname  cr ." one" ;             1 swof  ok-1 
:noname  cr ." neg three" ;      -3 swof  ok-1 
:noname  cr ." four" ;            4 swof  ok-1 
:noname  cr ." two" ;             2 swof  ok-1 
:noname  cr ." unknown" ;         slow-switch> sss  ok
1 sss 
one ok
10 sss 
unknown ok
3 sss 
unknown ok
-3 sss 
neg three ok

My code needs novice.4th and list.4th already loaded (the most recent versions). HAA will be pleased to see that I used his END rather than EXIT THEN in my code --- this was a "game changer!" --- my code is now much more readable than my usual muddled mess!

---------------------------------------------------------------------------


\ You can build a colon word called XXX that switches on targ values. This is how:
\ <SWITCH
\ :NONAME ... ;  targ SWOF
\ ...
\ :NONAME ... ;  FAST-SWITCH> xxx  ( targ -- )

\ The colon word XXX executes a table-entry corresponding to the targ value.
\ If there is no match, then the xt value prior to FAST-SWITCH> is executed as the default.

\ The targ values don't have to be provided in any particular order --- they get sorted internally.
\ If a duplicate targ value is provided, SWOF will abort with an error message at compile-time.

\ This is pretty crude because, unlike in C, the table entries can't have common local variables.
\ I would have liked to use my rquotations, but they don't have an xt that is known at compile-time,
\ so it is not possible to build a jump-table at compile-time. They have a "continuation" that is only known at run-time.
\ My <SWITCH that I have here uses :NONAME for the table entries --- they can have common global variables.

\ FAST-SWITCH> uses the targ value as an index to do the table look up. This is very fast.
\ If the range is too large however, then FAST-SWITCH> will abort with an error message to save memory.
\ In this case, use SLOW-SWITCH> instead. This builds a smaller table and uses BSEARCH to look up the table-entry.

\ Set JT-LIMIT to the range that you want FAST-SWITCH> to support.
\ It is currently set at 2^16 so you can have jump-tables with up to 64K entries. These consume a lot of memory.
\ If memory usage is an issue, then set JT-LIMIT to a smaller value. Use SLOW-SWITCH> instead of FAST-SWITCH>.
\ If the jump-table is sparse, SLOW-SWITCH> might be faster because there is less data-cache thrashing.

\ <SWITCH is primarily provided for writing VM simulators.
\ JT-LIMIT is currently set at 2^16, so it supports simulating a micro-processor with 16-bit opcodes (such as the AVR).
\ SLOW-SWITCH> would be needed for a micro-processor with 32-bit opcodes (such as the ARM or MIPS).

\ Some micro-processors (or byte-code VMs) have 8-bit opcodes, but also have post-bytes on some of the opcodes.
\ These variable-sized opcodes could be done with nested FAST-SWITCH> constructs.

list
    w field .xt
    w field .targ
constant jt

: init-jt ( xt targ node -- node )
    init-list >r
    r@ .targ !
    r@ .xt !
    r> ;

: new-jt ( xt targ -- node )
    jt alloc
    init-jt ;

: kill-jt ( head -- )
    each[  dealloc  ]each ;

: show-jt ( head -- )
    each[  cr  .targ @ .  ]each ;

: jt> ( new-node node -- new-node flag )    \ used by INSERT-ORDERED to build an ascending list without duplicates
    .targ @  over .targ @
    2dup = abort" *** <SWITCH structures not allowed to have duplicate targ values ***"
    > ;

: <switch ( -- head )
    nil ;

: swof ( head xt targ -- new-head )
    new-jt                                  \ -- head node
    ['] jt> swap  insert-ordered drop ;

1 16 lshift  value jt-limit                 \ should be at least 256 so we can support byte-code simulators

\ JT-LIMIT is the index that is too big for the jump-table. This can be any reasonable size.
\ The jump-table size is limited so the programmer doesn't accidentally build a jump-table consuming megabytes.
\ I set it at 2^16 to support simulating a micro-processor with 16-bit opcodes.

: fast-switch> { head default | adr offset size -- }    \ stream: name
    align here  to adr
    head .targ @  to offset
    head tail .targ @  offset -  to size
    size jt-limit > abort" *** FAST-SWITCH> has too large of a range. Use SLOW-SWITCH> instead. ***"
    offset  head each[  >r      \ -- targ
        begin  r@ .targ @  over <> while  default ,  1+  repeat
        r> .xt @ ,  1+  ]each  drop
    : ( targ -- )
        offset lit, -,          \ -- index
        dup,  size lit,  u>,  if,       drop,  default lit, execute,
        else,                           w lit, *,  adr lit, +,  @, execute,         then,  ;,
    head kill-jt ;

: jt-direction ( target mid-element -- -1|0|1 )         \ for use by BSEARCH
    @                                   \ -- target mid-value
    2dup = if  2drop  0 end                             \ note for HAA: I used your END rather than EXIT THEN
    < if  -1  else  1  then ;

: slow-switch> { head default | adr size -- }           \ stream: name
    align here  to adr
    head length  to size
    head each[  dup .targ @ ,  .xt @ ,  ]each
    : ( targ -- )
        adr lit,  size lit,  rot,  d lit,  ['] jt-direction lit,  postpone bsearch
        0=,  if,                        drop,  default lit, execute,
        else,                           w lit, +,  @, execute,                      then,  ;,
    head kill-jt ;

\ Testra had a switch construct written in UR/Forth assembly-language that built two arrays,
\ one of targ values and one of xt values. It generated code that would use SCASW to search the targ values.
\ I recommended using a binary search instead. I was told that SCASW is faster, even though it is sequential.
\ On the 80486, the ciscy instructions did usually provide better performance than hand-written code.
\ Because Testra was into building custom processors, they needed a fast simulator.
\ I didn't use their simulator for the MiniForth though --- I wrote my own in MFX.

\ The best way to write a simulator is to have your assembler not only generate the machine-code
\ for the target processor, but also generate a Forth program on the host machine that simulates it.
\ This generated simulation is much faster than a simulator that looks up opcodes at run-time.
\ This only works if you have the source-code for the target processor program that you are simulating.

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


#54505

Fromhughaguilar96@gmail.com
Date2017-01-28 16:06 -0800
Message-ID<c2252275-d4fb-4826-a05d-9907d4c331ef@googlegroups.com>
In reply to#54477
On Friday, January 27, 2017 at 7:55:48 PM UTC-7, hughag...@gmail.com wrote:
>     size jt-limit > abort" *** FAST-SWITCH> has too large of a range. Use SLOW-SWITCH> instead. ***"

I found a minor bug. That line should read:

    size jt-limit u> abort" *** FAST-SWITCH> has too large of a range. Use SLOW-SWITCH> instead. ***"

Here is a test:

<switch  ok-1 
:noname  cr  ." three" ;          3 swof  ok-1 
:noname  cr  ." three billion" ;  3000000000 swof  ok-1 
:noname  cr  ." neg three" ;     -3 swof  ok-1 
:noname  cr  ." unknown" ;        fast-switch> fff *** FAST-SWITCH> has too large of a range. Use SLOW-SWITCH> instead. ***
 -> :noname  cr  ." unknown" ;        fast-switch> fff
                                                  ^
  ok
<switch  ok-1 
:noname  cr  ." three" ;          3 swof  ok-1 
:noname  cr  ." three billion" ;  3000000000 swof  ok-1 
:noname  cr  ." neg three" ;     -3 swof  ok-1 
:noname  cr  ." unknown" ;        slow-switch> sss 
SSS is redefined  ok
1 sss 
unknown ok
3 sss 
three ok
3000000000 sss 
three billion ok

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


#54536

Fromhughaguilar96@gmail.com
Date2017-01-29 22:26 -0800
Message-ID<5a173001-b0e8-4922-ab64-ed5614c39399@googlegroups.com>
In reply to#54477
On Friday, January 27, 2017 at 7:55:48 PM UTC-7, hughag...@gmail.com wrote:
> Well, I wrote a <SWITCH construct in ANS-Forth that compiles into a jump-table. This is not as good as what C has because the table entries can't share local variables.

Note that it is not necessary to write constructs similar to <SWITCH that work for strings or floats or whatever. None of these can use a jump-table --- that is only possible with integers because the integers can be used as indices into the jump-table --- all of these other data types would have to be implemented similar to SLOW-SWITCH> that uses BSEARCH internally to find the correct entry.

This isn't necessary because I already have ASSOCIATION.4TH that works with strings or floats or whatever. This isn't quite as efficient as BSEARCH because the LLRB tree isn't guaranteed to be exactly balanced, but it is pretty close to being balanced and should be almost as efficient.

ASSOCIATION.4TH is more robust than <SWITCH anyway --- it allows entries to be added to the tree or removed from the tree at run-time --- <SWITCH builds its array at compile-time and it never changes.

For the most part, I primarily see <SWITCH being used with FAST-SWITCH> for fast simulation of VMs. This is a pretty important use case though, because building processors on FPGAs is important and being able to simulate them on a desktop computer is necessary.

Of course, none of this will ever be used by anybody except myself --- the ANS-Forth cult members will complain that a jump-table is not the "Forth Way" --- they will continue to defend Eaker's CASE as the ANS-Forth standard way.

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


#56110

Fromhughaguilar96@gmail.com
Date2017-03-22 07:04 -0700
Message-ID<6ed795bf-6074-460c-af39-0d726d73630b@googlegroups.com>
In reply to#54477
On Friday, January 27, 2017 at 7:55:48 PM UTC-7, hughag...@gmail.com wrote:
> On Tuesday, January 24, 2017 at 1:53:47 AM UTC-7, rickman wrote:
> > On 1/24/2017 12:58 AM, hughaguilar96@gmail.com wrote:
> > >> You seem obsessed with tearing down what others have built up
> > >> rather than just doing your own work and showing everyone how it
> > >> should be done.
> > >
> > > This reminds me of when the Forth-200x committee (the "Committee of
> > > Can't") was insisting that it is impossible for a quotation to have
> > > access to the parent function's local variables --- then I wrote my
> > > rquotations in a few lines of easy code that work under VFX and
> > > SwiftForth and which have access tot he parent function's local
> > > variables --- then Julien Fondren described this as "hate coding."
> > 
> > Yes, I can see the connection.  When you are on a tear everything 
> > reminds you of hate.
> > 
> > > Only in a cult does the concept of "hate coding" make sense ---
> > > ANS-Forth is a marketing gimmick, and any working Forth code written
> > > outside of Forth Inc. or MPE diminishes the marketing value of
> > > ANS-Forth --- if ANS-Forth were intended for writing Forth code, then
> > > working Forth code would be considered to be a positive
> > > contribution.
> 
> Well, I wrote a <SWITCH construct in ANS-Forth that compiles into a jump-table. This is not as good as what C has because the table entries can't share local variables.
> 
> Of course, I'm just tearing down what Elizabeth Rather has built up --- with my code that works I'm shining a spotlight on the stupidity of the CASE in ANS-Forth that became the standard --- maybe Julien Fondren will describe this as "hate coding" and make another death threat against me; that should be humorous!

This is the latest version of my <SWITCH construct:
----------------------------------------------------------------------------

\ ******
\ ****** This is a <SWITCH control-structure like in C that generates a jump-table.
\ ******

\ You can build a colon word called XXX that switches on targ values. This is how:
\ <SWITCH
\ :NONAME ... ;  targ SWOF
\ ...
\ :NONAME ... ;  FAST-SWITCH> xxx  ( selector -- )

\ The colon word XXX executes a table-entry corresponding to the targ value.
\ If there is no match, then the xt value prior to FAST-SWITCH> is executed as the default.
\ All of the table-entries and the default are given the selector value which they DROP if not needed.
\ It was HAA's suggestion that the selector value be provided --- I had dropped it internally previously.

\ The targ values don't have to be provided in any particular order --- they get sorted internally.
\ If a duplicate targ value is provided, SWOF will abort with an error message at compile-time.

\ This is pretty crude because, unlike in C, the table entries can't have common local variables.
\ I would have liked to use my rquotations, but they don't have an xt that is known at compile-time,
\ so it is not possible to build a jump-table at compile-time. They have a "continuation" that is only known at run-time.
\ My <SWITCH that I have here uses :NONAME for the table entries --- they can have common global variables.

\ FAST-SWITCH> uses the selector value as an index to do the table look up. This is very fast.
\ If the range is too large however, then FAST-SWITCH> will abort with an error message to save memory.
\ In this case, use SLOW-SWITCH> instead. This builds a smaller table and uses BSEARCH to look up the table-entry.

\ Set JT-LIMIT to the range that you want FAST-SWITCH> to support.
\ It is currently set at 2^16 so you can have jump-tables with up to 64K entries. These consume a lot of memory.
\ If memory usage is an issue, then set JT-LIMIT to a smaller value. Use SLOW-SWITCH> instead of FAST-SWITCH>.
\ If the jump-table is sparse, SLOW-SWITCH> might be faster because there is less data-cache thrashing.

\ <SWITCH is primarily provided for writing VM simulators.
\ JT-LIMIT is currently set at 2^16, so it supports simulating a micro-processor with 16-bit opcodes (such as the AVR).
\ SLOW-SWITCH> would be needed for a micro-processor with 32-bit opcodes (such as the ARM or MIPS).

\ Some micro-processors (or byte-code VMs) have 8-bit opcodes, but also have post-bytes on some of the opcodes.
\ These variable-sized opcodes could be done with nested FAST-SWITCH> constructs.

list
    w field .xt
    w field .targ
constant jt

: init-jt ( xt targ node -- node )
    init-list >r
    r@ .targ !
    r@ .xt !
    r> ;

: new-jt ( xt targ -- node )
    jt alloc
    init-jt ;

: kill-jt ( head -- )
    each[  dealloc  ]each ;

: show-jt ( head -- )
    each[  cr  .targ @ .  ]each ;

: jt> ( new-node node -- new-node flag )    \ used by INSERT-ORDERED to build an ascending list without duplicates
    .targ @  over .targ @
    2dup = abort" *** <SWITCH structures not allowed to have duplicate targ values ***"
    > ;

: <switch ( -- head )
    nil ;

: swof ( head xt targ -- new-head )
    new-jt                                  \ -- head node
    ['] jt> swap  insert-ordered drop ;

1 16 lshift  value jt-limit                 \ should be at least 256 so we can support byte-code simulators

\ JT-LIMIT is the index that is too big for the jump-table. This can be any reasonable size.
\ The jump-table size is limited so the programmer doesn't accidentally build a jump-table consuming megabytes.
\ I set it at 2^16 to support simulating a micro-processor with 16-bit opcodes.

: fast-switch> { head default | adr offset size -- }    \ stream: name
    align here  to adr
    head .targ @  to offset
    head tail .targ @  offset -  to size
    size jt-limit u> abort" *** FAST-SWITCH> has too large of a range. Use SLOW-SWITCH> instead. ***"
    offset  head each[  >r      \ -- targ
        begin  r@ .targ @  over <> while  default ,  1+  repeat
        r> .xt @ ,  1+  ]each  drop
    : ( selector -- )
        dup, offset lit, -,     \ -- selector index
        dup,  size lit,  u>,  if,  drop,  default lit, execute,  end,
        w lit, *,  adr lit, +,  @, execute,  ;,
    head kill-jt ;

: jt-direction ( target mid-element -- -1|0|1 )         \ for use by BSEARCH
    @                                   \ -- target mid-value
    2dup = if  2drop  0 end                             \ note for HAA: I used your END rather than EXIT THEN
    < if  -1  else  1  then ;

: slow-switch> { head default | adr size -- }           \ stream: name
    align here  to adr
    head length  to size
    head each[  dup .targ @ ,  .xt @ ,  ]each
    : ( selector -- )
        adr lit,  size lit,  rover,  d lit,  ['] jt-direction lit,  postpone bsearch
        0=,  if,  drop,  default lit, execute,  end,
        w lit, +,  @, execute,  ;,
    head kill-jt ;
    

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


#54322

FromGerry Jackson <gerry@jackson9000.fsnet.co.uk>
Date2017-01-23 21:04 +0000
Message-ID<o65r2g$vfm$1@dont-email.me>
In reply to#54308
On 23/01/2017 18:23, hughaguilar96@gmail.com wrote:
> On Monday, January 23, 2017 at 4:22:31 AM UTC-7, Gerry wrote:
>> On Sunday, January 22, 2017 at 10:30:17 PM UTC, hughag...@gmail.com wrote:
>>  > I don't understand why you waste your time defending crap like
>> ANS-Forth. Nobody uses ANS-Forth
>>
>> I don't defend all of it, many of your criticisms are valid e.g. PAD
>> moving around is stupid (but understandable in a historical context).
>> But then it is trivial to define a text buffer and use that ignoring PAD
>> totally.
>>
>> I use, and I suppose thereby sort of defend, ANS Forth because I can use
>> other people's code if I wish e.g. your String Stack, your Novice
>> package, the FFL, the Forth scientific Library. Some years ago I used
>> Anton Ertl's Gray parser generator 'out of the box' and extended it to
>> do what I wanted. I can use ANS standard code posted here if I wish. I
>> can write tools that others can use on different Forth systems. Sure ANS
>> Forth sometimes gets in the way but there are always ways round it.
>>
>> Is that enough reasons?
>
> This is a common rhetoric technique.

What! I simply explained why I use ANS Forth which, by the way, clearly 
refutes your claim that nobody uses it.

> The ANS-Forth cult say that
> anybody who opposes ANS-Forth is opposed to having a standard and
> wants a complete free-for-all.

Well I can't be a member of this cult then (if indeed it exists outside 
your imagination) as I don't say that


-- 
Gerry

[toc] | [prev] | [standalone]


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


csiph-web