Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #9523 > unrolled thread
| Started by | "Ed" <nospam@invalid.com> |
|---|---|
| First post | 2012-02-13 21:24 +1100 |
| Last post | 2012-03-01 18:52 +0000 |
| Articles | 20 on this page of 141 — 26 participants |
Back to article view | Back to comp.lang.forth
Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-13 21:24 +1100
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-13 13:05 -0800
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-16 10:19 +1100
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-15 08:48 +0100
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-23 22:46 -0800
Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-24 08:07 +0100
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-24 15:00 +0100
Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-24 08:29 -1000
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-25 00:11 +0100
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-27 23:28 -0800
Re: Adding thousands separators Alex McDonald <blog@rivadpm.com> - 2012-02-28 01:37 -0800
Re: Adding thousands separators Ron Aaron <rambamist@gmail.com> - 2012-02-28 15:06 +0200
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-02-29 09:29 +0100
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-29 03:00 -0600
Re: Adding thousands separators The Beez <the.beez.speaks@gmail.com> - 2012-02-29 03:44 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-29 11:19 -0600
Re: Adding thousands separators hughaguilar96@yahoo.com - 2012-02-29 22:48 -0800
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-01 08:38 +0100
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-01 00:57 -0800
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-01 18:23 +0100
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-01 17:22 -0800
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-01 18:00 -0800
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-01 22:14 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-02 06:58 -0800
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-02 11:07 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-02 13:13 -0600
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-02 11:25 -0800
Re: Adding thousands separators Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-03 11:00 +0000
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 03:17 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-03 12:30 +0000
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 11:39 -0800
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-06 16:31 -0800
Re: Adding thousands separators mhx@iae.nl (Marcel Hendrix) - 2012-03-03 15:52 +0200
Re: Adding thousands separators Coos Haak <chforth@hccnet.nl> - 2012-03-03 16:23 +0100
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 10:19 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 12:35 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-03 11:02 -0600
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-03 17:25 +0000
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 10:14 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-03 14:14 -0600
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 14:52 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-04 03:39 -0600
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-04 15:02 +0000
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-03 14:11 -0600
Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-03 23:49 +0100
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-03 15:50 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-04 15:38 +0000
Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-04 18:08 +0100
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-04 11:20 -0600
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-04 17:45 +0000
Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-04 23:50 +0100
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-05 14:39 +0000
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-03-06 13:01 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-12 16:05 +0000
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-03 15:45 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 17:56 -0800
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-05 15:41 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-06 11:27 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-03 11:01 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-02 05:53 -0800
Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-03 01:49 +0100
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-29 17:20 +1100
Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-29 07:51 +0100
Re: Adding thousands separators hughaguilar96@yahoo.com - 2012-02-29 21:26 -0800
Re: Adding thousands separators "WJ" <w_a_x_man@yahoo.com> - 2012-03-03 03:45 +0000
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-04 20:49 +1100
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-04 15:16 +0100
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-06 15:06 +1100
Re: Adding thousands separators Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-06 08:32 +0100
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-05 15:06 -0800
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-06 15:03 +1100
Re: Adding thousands separators hwfwguy@gmail.com - 2012-03-06 20:29 -0800
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-06 23:18 -0800
Re: Adding thousands separators John Passaniti <john.passaniti@gmail.com> - 2012-03-07 06:07 -0800
Re: Adding thousands separators hwfwguy@gmail.com - 2012-03-07 06:36 -0800
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-07 16:19 -0800
Re: Adding thousands separators Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-08 10:51 +0000
Re: Adding thousands separators Doug Hoffman <glidedog@gmail.com> - 2012-02-15 20:18 -0500
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-17 12:29 +1100
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-17 09:42 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-20 15:24 +0000
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-20 20:41 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-21 16:46 +0000
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-21 12:23 -0600
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-21 11:32 -0800
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-22 12:46 +1100
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-22 10:08 +0000
Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-22 08:51 -1000
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 14:28 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-23 13:13 +0000
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-24 14:32 +1100
Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-23 19:53 -1000
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-03 12:47 +1100
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-03-02 22:26 -0800
Re: Adding thousands separators Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2012-03-03 14:32 +0000
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-04 21:31 +1100
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-03-04 10:07 -0800
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-06 15:31 +1100
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-03-05 22:26 -0800
Re: Adding thousands separators Josh Grams <josh@qualdan.com> - 2012-03-06 12:32 +0000
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-24 05:04 -0800
Re: Adding thousands separators "Elizabeth D. Rather" <erather@forth.com> - 2012-02-24 08:30 -1000
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-22 04:28 -0600
Re: Adding thousands separators stephenXXX@mpeforth.com (Stephen Pelc) - 2012-02-22 14:59 +0000
Re: Adding thousands separators stephenXXX@mpeforth.com (Stephen Pelc) - 2012-02-22 18:05 +0000
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 07:49 -0800
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-02-22 12:46 -0800
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 18:24 -0800
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-24 13:23 +1100
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-21 11:29 -0800
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-22 09:56 +0000
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-22 07:37 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-22 10:30 -0600
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-22 16:24 +0000
Re: Adding thousands separators Brad <hwfwguy@gmail.com> - 2012-02-23 07:44 -0800
Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-02-23 17:54 +0100
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-23 16:51 +0000
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-23 11:49 -0600
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-02-23 13:26 -0800
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-23 15:58 -0600
Re: Adding thousands separators Bernd Paysan <bernd.paysan@gmx.de> - 2012-02-26 02:25 +0100
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-26 03:24 -0600
Re: Adding thousands separators anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-02-26 13:40 +0000
Re: Adding thousands separators Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-02-26 11:06 -0600
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-23 15:02 -0800
Re: Adding thousands separators Doug Hoffman <glidedog@gmail.com> - 2012-02-16 13:21 -0500
Re: Adding thousands separators Paul Rubin <no.email@nospam.invalid> - 2012-02-16 20:44 -0800
Re: Adding thousands separators Coos Haak <chforth@hccnet.nl> - 2012-02-17 21:32 +0100
Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-17 22:41 +0100
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-17 18:52 -0800
Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-18 10:39 +0100
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-02-18 21:22 +1100
Re: Adding thousands separators "A. K." <akk@nospam.org> - 2012-02-18 13:12 +0100
Re: Adding thousands separators "Peter Knaggs" <pjk@bcs.org.uk> - 2012-02-18 16:30 +0000
Re: Adding thousands separators Jan Coombs <jan_2011-02@murray-microft.co.uk> - 2012-02-18 17:08 +0000
Re: Adding thousands separators BruceMcF <agila61@netscape.net> - 2012-02-18 14:46 -0800
Re: Adding thousands separators "Ed" <nospam@invalid.com> - 2012-03-04 20:47 +1100
Re: Adding thousands separators Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-28 17:03 -0800
Re: Adding thousands separators "WJ" <w_a_x_man@yahoo.com> - 2012-03-01 18:13 +0000
Re: Adding thousands separators Alex McDonald <blog@rivadpm.com> - 2012-03-01 12:46 -0800
Re: Adding thousands separators "WJ" <w_a_x_man@yahoo.com> - 2012-03-01 18:52 +0000
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
| From | "Ed" <nospam@invalid.com> |
|---|---|
| Date | 2012-02-13 21:24 +1100 |
| Subject | Adding thousands separators |
| Message-ID | <jhao81$cjj$1@news-01.bur.connect.com.au> |
No-frills code for adding thousands separators to a decimal
numeric string.
Assumes your Forth has some way of generating numeric
strings e.g. (D.) (F.) etc. If the source string lies in the PNO
buffer it will need copying elsewhere first. Customize for
your locale. If you can do it in less, let us know.
--
\ COMMAS.F
\
\ Add thousands separator to a decimal numeric string
\
\ version: 2012-02-13
\
\ - decimal input string must include a decimal point
\ - output string resides in the Forth pictured numeric
\ output buffer
\
\ This code is PUBLIC DOMAIN. Use at your own risk.
\ Extract character from end of string
: STRING/C ( a u -- a u-1 char )
1- 2dup chars + c@ ;
variable cnt
: COMMA$ ( a1 u1 -- a2 u2 )
<#
begin dup while
string/c dup hold [char] . =
until then
cnt off
begin dup while
string/c
dup [char] 0 - 10 u< cnt @ 3 = and
if [char] , hold cnt off then
hold 1 cnt +!
repeat
#> ;
[defined] DXFORTH [if] behead cnt cnt [then]
1 [if]
cr .( testing )
s" " comma$ cr type
s" -123." comma$ cr type
s" -1234.E-1000" comma$ cr type
s" -123456789.4500" comma$ cr type
s" +100000000.0000" comma$ cr type
s" $10000000" comma$ cr type
s" -INFINITY" comma$ cr type
s" NANS(32767)" comma$ cr type
s" !#$%'()*+-." comma$ cr type
[then]
--
[toc] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-02-13 13:05 -0800 |
| Message-ID | <ed900268-e28f-469c-b33a-75810a20f56b@ir9g2000pbc.googlegroups.com> |
| In reply to | #9523 |
On Feb 13, 3:24 am, "Ed" <nos...@invalid.com> wrote: > No-frills code for adding thousands separators to a decimal > numeric string. > > Assumes your Forth has some way of generating numeric > strings e.g. (D.) (F.) etc. If the source string lies in the PNO > buffer it will need copying elsewhere first. Customize for > your locale. If you can do it in less, let us know. > > -- > > \ COMMAS.F > \ > \ Add thousands separator to a decimal numeric string > \ > \ version: 2012-02-13 > \ > \ - decimal input string must include a decimal point > \ - output string resides in the Forth pictured numeric > \ output buffer > \ > \ This code is PUBLIC DOMAIN. Use at your own risk. > > \ Extract character from end of string > : STRING/C ( a u -- a u-1 char ) > 1- 2dup chars + c@ ; > > variable cnt > > : COMMA$ ( a1 u1 -- a2 u2 ) > <# > begin dup while > string/c dup hold [char] . = > until then > cnt off > begin dup while > string/c > dup [char] 0 - 10 u< cnt @ 3 = and > if [char] , hold cnt off then > hold 1 cnt +! > repeat > #> ; > > [defined] DXFORTH [if] behead cnt cnt [then] > > 1 [if] > cr .( testing ) > s" " comma$ cr type > s" -123." comma$ cr type > s" -1234.E-1000" comma$ cr type > s" -123456789.4500" comma$ cr type > s" +100000000.0000" comma$ cr type > s" $10000000" comma$ cr type > s" -INFINITY" comma$ cr type > s" NANS(32767)" comma$ cr type > s" !#$%'()*+-." comma$ cr type > [then] > > -- My novice package (http://www.forth.org/novice.html) has BIG. for doing that. I also generate engineering and scientific formats.
[toc] | [prev] | [next] | [standalone]
| From | "Ed" <nospam@invalid.com> |
|---|---|
| Date | 2012-02-16 10:19 +1100 |
| Message-ID | <jhhecc$p8c$1@news-01.bur.connect.com.au> |
| In reply to | #9535 |
Hugh Aguilar wrote: > On Feb 13, 3:24 am, "Ed" <nos...@invalid.com> wrote: > > No-frills code for adding thousands separators to a decimal > > numeric string. > > > > Assumes your Forth has some way of generating numeric > > strings e.g. (D.) (F.) etc. If the source string lies in the PNO > > buffer it will need copying elsewhere first. Customize for > > your locale. If you can do it in less, let us know. > > > > ... > > My novice package (http://www.forth.org/novice.html) has BIG. for > doing that. I also generate engineering and scientific formats. Yes. If processing [double] integers is all that's required then the approach you took can be more efficient. Another example can be found in FD 15/5 which adds #,S to the regular <# #> words.
[toc] | [prev] | [next] | [standalone]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-02-15 08:48 +0100 |
| Message-ID | <4f3b62ef$0$6947$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #9523 |
Ed wrote: > No-frills code for adding thousands separators to a decimal > numeric string. Hi Ed! Since I don't use the largely useless NOVICE package, I'd be happy to include this code in the next release of 4tH. Thanks, clean, portable code - it seems like a very nice addition! Hans
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-02-23 22:46 -0800 |
| Message-ID | <c29dc977-9744-493d-8d72-99fdd336fdad@c21g2000yqi.googlegroups.com> |
| In reply to | #9569 |
On Feb 22, 11:51 am, "Elizabeth D. Rather" <erat...@forth.com> wrote: > On 2/22/12 12:08 AM, Anton Ertl wrote: > > > "Ed"<nos...@invalid.com> writes: > >> I make no apology for comparison technique I used. It's cheap, > >> easy, and works. I baulk at the notion of having to support > >> non 2's-complement machines at the cost of efficiency or > >> complicated compile-time options. > > > Yes, I think we should standardize 2s-complement machines and the > > various properties that they have. If anyone ever does a Forth for a > > non-2s-complement machine, it would have some environmental > > restrictions. > > Well, that's one approach, but it's pretty easy to document your code as > dependent on 2's complement arithmetic and not worry about it further. > No one *has* to support non-2's complement arithmetic! > > I truly don't understand why everyone is so allergic to declaring > dependencies, as though it were a mark of shame. > > 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 90045http://www.forth.com > > "Forth-based products and Services for real-time > applications since 1973." > ================================================== This is one case in which I agree with Elizabeth Rather. All of this talk about ones-complement arithmetic is incredible foolishness. The needle on the common-senso-meter is not even twitching; you guys are at a rock-solid zero. AFAIK, nobody has built a ones-complement processor since the 1960s, and it was widely considered to be a dumb idea then too. I think that we are pretty safe in ignoring ones- complement processors in the year 2012. I have many times said that the problem with ANS-Forth is that it is trying to be everything to everybody. You heard that somebody somewhere is using ones-complement, so you supported ones-complement lest that that person should abandon Forth. As another example, you have both local variables and >R etc.. You also say that locals "may" be held on the return stack. Your frequent use of the word "may" is a red flag indicating that you don't know what you are talking about. Obviously, there is going to be a conflict here if the return stack is used for both. The ANS-Forth committee just wanted to please everybody. Some people were using locals on the return stack, so you said: "Sure! That is ANS-Forth compliant!" Other people were using >R etc., so you said: "Sure! That is ANS-Forth compliant!" You just wanted to please everybody. The fact that these solutions were in obvious conflict, didn't bother you at all. This reminds me of how Bill Clinton used to always tailor his speeches to his audience, and just tell them what they wanted to hear. His speeches would be in complete contradiction from one day to the next however, because he would be speaking to different audiences with different agendas. The ANS-Forth committee is ultra-liberal in the same way that Bill Clinton is ultra-liberal. It seems a bit late for Elizabeth Rather to realize that pleasing everybody everywhere (including the guy living in a cave running a ones-complement computer) is not a viable plan. ANS-Forth is an incredible mess because it tries to please everybody everywhere --- it is self-contradicting --- it is possibly the worst standard ever designed. Who are we supposed to blame for this other than you? On Feb 15, 12:48 am, Hans Bezemer <the.beez.spe...@gmail.com> wrote: > Ed wrote: > > No-frills code for adding thousands separators to a decimal > > numeric string. > > Hi Ed! > > Since I don't use the largely useless NOVICE package, I'd be happy to > include this code in the next release of 4tH. > > Thanks, clean, portable code - it seems like a very nice addition! > > Hans Beez, you are trying to get my goat, but you just make a fool of yourself. The guy's code was not clean. He is dismantling one string to make another string. What??? I just wrote a typical picture-number function that takes a double and generates a string using # and HOLD and all that. There was a chapter on this stuff in "Starting Forth" --- anybody who has read that book should be able to succeed at writing the BIG. function. It was trivial. Also, he wrote a really long function that badly needed factoring. This is very novice-level Forth. If you guys were the experts that you claim to be, you would be helping him to improve his Forth. Instead the Beez congratulates him on his "clean" code and says that it qualifies for inclusion in the 4TH compiler, and the whole crowd immediately launches into a discussion of ones-complement arithmetic. What??? The poor guy is not going to learn anything about Forth from you guys --- I predict that he is going to drop Forth pretty soon, just like everybody else who tries to learn it.
[toc] | [prev] | [next] | [standalone]
| From | "A. K." <akk@nospam.org> |
|---|---|
| Date | 2012-02-24 08:07 +0100 |
| Message-ID | <4f47373a$0$6630$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #9696 |
On 24.02.2012 07:46, Hugh Aguilar wrote: > On Feb 22, 11:51 am, "Elizabeth D. Rather"<erat...@forth.com> wrote: >> On 2/22/12 12:08 AM, Anton Ertl wrote: >> >>> "Ed"<nos...@invalid.com> writes: >>>> I make no apology for comparison technique I used. It's cheap, >>>> easy, and works. I baulk at the notion of having to support >>>> non 2's-complement machines at the cost of efficiency or >>>> complicated compile-time options. >> >>> Yes, I think we should standardize 2s-complement machines and the >>> various properties that they have. If anyone ever does a Forth for a >>> non-2s-complement machine, it would have some environmental >>> restrictions. >> >> Well, that's one approach, but it's pretty easy to document your code as >> dependent on 2's complement arithmetic and not worry about it further. >> No one *has* to support non-2's complement arithmetic! >> >> I truly don't understand why everyone is so allergic to declaring >> dependencies, as though it were a mark of shame. >> >> 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 90045http://www.forth.com >> >> "Forth-based products and Services for real-time >> applications since 1973." >> ================================================== > > This is one case in which I agree with Elizabeth Rather. All of this > talk about ones-complement arithmetic is incredible foolishness. The > needle on the common-senso-meter is not even twitching; you guys are > at a rock-solid zero. AFAIK, nobody has built a ones-complement > processor since the 1960s, and it was widely considered to be a dumb > idea then too. I think that we are pretty safe in ignoring ones- > complement processors in the year 2012. > > I have many times said that the problem with ANS-Forth is that it is > trying to be everything to everybody. You heard that somebody > somewhere is using ones-complement, so you supported ones-complement > lest that that person should abandon Forth. As another example, you > have both local variables and>R etc.. You also say that locals "may" > be held on the return stack. Your frequent use of the word "may" is a > red flag indicating that you don't know what you are talking about. > Obviously, there is going to be a conflict here if the return stack is > used for both. The ANS-Forth committee just wanted to please > everybody. Some people were using locals on the return stack, so you > said: "Sure! That is ANS-Forth compliant!" Other people were using>R > etc., so you said: "Sure! That is ANS-Forth compliant!" You just > wanted to please everybody. The fact that these solutions were in > obvious conflict, didn't bother you at all. This reminds me of how > Bill Clinton used to always tailor his speeches to his audience, and > just tell them what they wanted to hear. His speeches would be in > complete contradiction from one day to the next however, because he > would be speaking to different audiences with different agendas. The > ANS-Forth committee is ultra-liberal in the same way that Bill Clinton > is ultra-liberal. > > It seems a bit late for Elizabeth Rather to realize that pleasing > everybody everywhere (including the guy living in a cave running a > ones-complement computer) is not a viable plan. ANS-Forth is an > incredible mess because it tries to please everybody everywhere --- it > is self-contradicting --- it is possibly the worst standard ever > designed. Who are we supposed to blame for this other than you? > > On Feb 15, 12:48 am, Hans Bezemer<the.beez.spe...@gmail.com> wrote: >> Ed wrote: >>> No-frills code for adding thousands separators to a decimal >>> numeric string. >> >> Hi Ed! >> >> Since I don't use the largely useless NOVICE package, I'd be happy to >> include this code in the next release of 4tH. >> >> Thanks, clean, portable code - it seems like a very nice addition! >> >> Hans > > Beez, you are trying to get my goat, but you just make a fool of > yourself. > > The guy's code was not clean. He is dismantling one string to make > another string. What??? I just wrote a typical picture-number function > that takes a double and generates a string using # and HOLD and all > that. There was a chapter on this stuff in "Starting Forth" --- > anybody who has read that book should be able to succeed at writing > the BIG. function. It was trivial. Also, he wrote a really long > function that badly needed factoring. This is very novice-level Forth. > If you guys were the experts that you claim to be, you would be > helping him to improve his Forth. Instead the Beez congratulates him > on his "clean" code and says that it qualifies for inclusion in the > 4TH compiler, and the whole crowd immediately launches into a > discussion of ones-complement arithmetic. What??? The poor guy is not > going to learn anything about Forth from you guys --- I predict that > he is going to drop Forth pretty soon, just like everybody else who > tries to learn it. This was a rather hughly statement.
[toc] | [prev] | [next] | [standalone]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-02-24 15:00 +0100 |
| Message-ID | <4f4797d7$0$6935$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #9696 |
Hugh Aguilar wrote:
> The guy's code was not clean. He is dismantling one string to make
> another string. What??? I just wrote a typical picture-number function
> that takes a double and generates a string using # and HOLD and all
> that.
Oops! No floating point. Oops, another "function". I won't say that there
aren't drawbacks to Ed's word but it's pretty portable Forth and quite
flexible. Given the code size and possible application I think it's pretty
useful.
> Also, he wrote a really long function that badly needed factoring.
Says the man who wrote code like this:
: <big.> ( d -- adr cnt ) \ used for big numbers that need
commas for clarity
2dup d0< to sgn dabs
<#
# ?# ?# ?comma
?# ?# ?# ?comma
?# ?# ?# ?comma
?# ?# ?# ?comma
?# ?# ?# ?comma
?# ?# ?# ?comma
?#
#> ;
And this:
: <6array> { dim1 dim2 dim3 dim4 dim5 dim6 siz1 name | adr siz siz2 siz3
siz4 siz5 siz6 -- }
dim1 siz1 * to siz2 dim2 siz2 * to siz3 dim3 siz3 * to siz4
dim4 siz4 * to siz5 dim5 siz5 * to siz6 dim6 siz6 * to siz
align here to adr siz allot
name get-current :name \ runtime: x1 x2 x3
x4 x5 x6 -- element-adr
dim6 <check6>
siz6 lit*, swap, \ runtime: -- x1 x2
x3 x4 x6*s6 x5
dim5 <check5>
siz5 lit*, +, swap, \ runtime: -- x1 x2
x3 x6*s6+x5*s5 x4
dim4 <check4>
siz4 lit*, +, swap, \ runtime: -- x1 x2
x6*s6+x5*s5+x4*s4 x3
dim3 <check3>
siz3 lit*, +, swap, \ runtime: -- x1
x6*s6+x5*s5+x4*s4+x3*s3 x2
dim2 <check2>
siz2 lit*, +, swap, \ runtime: --
x6*s6+x5*s5+x4*s4+x3*s3+x2*s2 x1
dim1 <check1>
siz1 lit*, +, adr lit+, ;, \ runtime: --
x6*s6+x5*s5+x4*s4+x3*s3+x2*s2+x1*s1
c" ^" name get-current :2name \ runtime: -- adr
adr lit, ;,
c" lim-" name get-current :2name \ runtime: --
adr-past
adr siz + lit, ;,
name c" -zero" get-current :2name \ runtime: --
adr lit, siz lit, s" erase ; " evaluate
name c" -size" get-current :2name \ runtime: -- siz1
siz1 lit, ;,
name c" -dim" get-current :2name \ runtime: -- dim1
dim2 dim3 dim4 dim5 dim6
dim1 lit, dim2 lit, dim3 lit, dim4 lit, dim5 lit, dim6 lit, ;,
;
BTW, in Forth it isn't called a "function", but a "word". Any newbie knows
that. Unless he's been using a massive NOVICE.4TH perhaps.
> What??? The poor guy is not going to learn anything about Forth from you
> guys --- I predict that he is going to drop Forth pretty soon, just like
> everybody else who tries to learn it.
I think Ed has made his track record by providing some nice FP I/O words. I
don't always agree with every construct he uses, but he won't agree on mine
as well. And that's ok. I haven't dropped Forth in 20 years and I'm not
going to do it very soon. Neither is Ed, I guess. And why should he?
I rarely see Forth code I really, really like. Most often because it is
badly factored, uses locals or other C-stuff or is plain TOO LONG. Gee,
most of your code should be single line definitions, few variables and no
locals. Stack should be shallow.
For your entertainment, here is 4tH's version. Note I'm still thinking about
clobbering the NPO when you try to convert a number that already resides in
the NPO. But you'll have to agree, it is better factored:
[UNDEFINED] fs>comma [IF]
[UNDEFINED] is-digit [IF] include lib/istype.4th [THEN]
[UNDEFINED] string/c [IF] include lib/cstring.4th [THEN]
char . value dp-char \ decimal point character
char , value 1000-char \ separator character
: s>comma
0 >r \ setup counter
begin
dup \ end of string?
while
string/c dup is-digit dup \ is it a digit?
r@ 3 /mod 0<> swap 0= and and \ should we add a 1000 separator?
if 1000-char hold then \ if so, add 1000 separator
if r> 1+ >r then hold \ increment counter
repeat r> drop \ drop counter
[DEFINED] 4TH# [IF] drop [THEN] \ 4tH expects a single number
;
\ with a decimal point
: fs>comma ( a1 u1 -- a2 u2 )
<# \ setup number generation
begin \ find decimal point
dup \ end of string?
while
string/c dup hold dp-char = \ decimal point found?
until s>comma \ if not, continue
#>
;
\ without a decimal point
: ds>comma <# s>comma #> ; ( a1 u1 -- a2 u2 )
[DEFINED] 4TH# [IF]
hide s>comma
[THEN]
[THEN]
Hans Bezemer
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2012-02-24 08:29 -1000 |
| Message-ID | <Z-6dnTDTmqWQStrSnZ2dnUVZ_oadnZ2d@supernews.com> |
| In reply to | #9700 |
On 2/24/12 4:00 AM, Hans Bezemer wrote: > For your entertainment, here is 4tH's version. Note I'm still thinking about > clobbering the NPO when you try to convert a number that already resides in > the NPO. But you'll have to agree, it is better factored: Nicely factored. But I wish you'd use stack comments with your definitions. 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]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-02-25 00:11 +0100 |
| Message-ID | <4f4818f5$0$6913$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #9702 |
Elizabeth D. Rather wrote:
> On 2/24/12 4:00 AM, Hans Bezemer wrote:
>> For your entertainment, here is 4tH's version. Note I'm still thinking
>> about clobbering the NPO when you try to convert a number that already
>> resides in the NPO. But you'll have to agree, it is better factored:
>
> Nicely factored. But I wish you'd use stack comments with your
Oops, did I forget one for a private word? Ok, here it is:
s>comma ( 4tH: a1 n1 -- n2)
( ANS: a1 n1 -- d1)
The typing may be a bit off, but that's how it is with a no-type language.
Hans Bezemer
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-02-27 23:28 -0800 |
| Message-ID | <9fe52002-9e51-48db-bbe8-f8576dc935f0@j8g2000yqm.googlegroups.com> |
| In reply to | #9700 |
On Feb 24, 7:00 am, Hans Bezemer <the.beez.spe...@gmail.com> wrote:
> Hugh Aguilar wrote:
> > The guy's code was not clean. He is dismantling one string to make
> > another string. What??? I just wrote a typical picture-number function
> > that takes a double and generates a string using # and HOLD and all
> > that.
>
> Oops! No floating point. Oops, another "function". I won't say that there
> aren't drawbacks to Ed's word but it's pretty portable Forth and quite
> flexible. Given the code size and possible application I think it's pretty
> useful.
When working with numeric data, it is best to work with it as a
number. Working with numeric data as a string is cumbersome --- that
is the kind of thing that a Perl programmer would do!
My SCIENTIFIC and ENGINEERING do work with floats. I could have easily
added commas to ENGINEERING (they wouldn't make sense for SCIENTIFIC).
The reason why I didn't was so that these strings I am generating can
be fed back into a Forth interpreter as source-code and/or given to
>FLOAT to be converted back into floats, or even interpreted by
another language other than Forth. All of this work on generating
string representations of floats came about because I wanted the slide-
rule program to generate ascii files of raw data that another program
could input. One guy did write a program that input my raw-data files
and made a slide-rule emulator out of them. I think he wrote his
program in JavaScript and converted my raw-data into SVG, but I don't
know as I never looked at his source-code (I don't have any interest
in slide-rule emulators, as I am only interested in building physical
slide-rules).
Everything in the novice package is portable to any ANS-Forth system
(I've tested Gforth, SwiftForth and Win32Forth).
> > Also, he wrote a really long function that badly needed factoring.
>
> Says the man who wrote code like this:
>
> : <big.> ( d -- adr cnt )
> 2dup d0< to sgn dabs
> <#
> # ?# ?# ?comma
> ?# ?# ?# ?comma
> ?# ?# ?# ?comma
> ?# ?# ?# ?comma
> ?# ?# ?# ?comma
> ?# ?# ?# ?comma
> ?#
> #> ;
That looks like beautiful well-factored Forth code to me. It is longer
than 7 lines (according to "Thinking Forth," functions should
generally be 7 lines or less), but it follows a simple pattern so it
is quite readable despite its length.
Ask Anton Ertl what he thinks of it --- he is the professor.
> And this:
>
> : <6array> { dim1 dim2 dim3 dim4 dim5 dim6 siz1 name | adr siz siz2 siz3
> siz4 siz5 siz6 -- }
> ...
I have already said many times that some of the code in the novice
package is low-level. The implementation of an array definer is very
low-level --- the important goal with arrays is execution speed ---
rules for readability that apply to high-level code get waived for low-
level code.
Also, all of those meta-definers that use :NAME were originally
written and tested as several ordinary colon words. After I got them
to work, I made them into meta-definers. See WBUF for an example in
which I provided the original testing words in a separate file so the
user could see how this development process is done.
> BTW, in Forth it isn't called a "function", but a "word". Any newbie knows
> that. Unless he's been using a massive NOVICE.4TH perhaps.
I use the word "function" just like everybody else in the programming
world. It was a mistake for Chuck Moore to use "word" to mean a
function, because "word" is more commonly used to mean a single-
precision integer. He most likely did that because in an indirect-
threaded-code system, functions do get compiled as single-precision
integers. That was in the 1970s though --- that is no longer true, and
it is irrelevant to the user what the internal representation is
anyway --- using "word" like that now is just confusing.
> > What??? The poor guy is not going to learn anything about Forth from you
> > guys --- I predict that he is going to drop Forth pretty soon, just like
> > everybody else who tries to learn it.
>
> I think Ed has made his track record by providing some nice FP I/O words. I
> don't always agree with every construct he uses, but he won't agree on mine
> as well. And that's ok. I haven't dropped Forth in 20 years and I'm not
> going to do it very soon. Neither is Ed, I guess. And why should he?
I don't want Ed or anybody else to drop Forth. But I see people show
up on comp.lang.forth filled with enthusiasm for learning Forth, and
then they disappear after a few weeks. It is because you guys don't
offer any support for novices. This thread is a good example of how
you fail to support novices. Talking about ones-complement arithmetic
makes us look like idiots --- that is not helping to convince anybody
to stick with Forth.
I'm not aware of Ed's "track record" providing FP I/O words. In my
novice package I provide GET-FLOAT for input and SCIENTIFIC and
ENGINEERING for output. Did he write something like that?
This kind of stuff is trivial. It is useful, which is why I provided
it in the novice package, but it is pretty basic. There is a lot more
important code in the novice package than this stuff.
I'm not aware of anybody on comp.lang.forth who is in my league. The
only person who is capable of writing something comparable to the
novice package is Anton Ertl, but he spends all of his time dinking
around with Gforth which is just a toy interpreter, and he seems to
have no interest in supporting application programming. You know,
there is a reason why so few applications have been written in Forth
--- it is because the Forth experts aren't providing libraries of code
that would be useful for application programming.
[toc] | [prev] | [next] | [standalone]
| From | Alex McDonald <blog@rivadpm.com> |
|---|---|
| Date | 2012-02-28 01:37 -0800 |
| Message-ID | <8289f24b-476c-4038-8986-ce124597aca9@w4g2000vbc.googlegroups.com> |
| In reply to | #9730 |
On Feb 28, 7:28 am, Hugh Aguilar <hughaguila...@yahoo.com> wrote: > > I'm not aware of anybody on comp.lang.forth who is in my league. There's a truth in that somewhere.
[toc] | [prev] | [next] | [standalone]
| From | Ron Aaron <rambamist@gmail.com> |
|---|---|
| Date | 2012-02-28 15:06 +0200 |
| Message-ID | <jiijgh$2h3$1@dont-email.me> |
| In reply to | #9731 |
On 02/28/2012 11:37 AM, Alex McDonald wrote: > On Feb 28, 7:28 am, Hugh Aguilar <hughaguila...@yahoo.com> wrote: > >> >> I'm not aware of anybody on comp.lang.forth who is in my league. > > There's a truth in that somewhere. The deepest truths are often stated in simplest terms.
[toc] | [prev] | [next] | [standalone]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-02-29 09:29 +0100 |
| Message-ID | <4f4de1aa$0$6928$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #9730 |
Hugh Aguilar wrote: > When working with numeric data, it is best to work with it as a > number. Working with numeric data as a string is cumbersome --- that > is the kind of thing that a Perl programmer would do! I'd say it's just an additional formatter that can be added to an already generated FP or double number. I don't see anything wrong with that. As a matter of fact, adding an entirely new formatter would duplicate a lot of code (especially in FP). > That looks like beautiful well-factored Forth code to me. It is longer > than 7 lines (according to "Thinking Forth," functions should > generally be 7 lines or less), but it follows a simple pattern so it > is quite readable despite its length. I don't say it's not readable: it just could be factored even more. > Ask Anton Ertl what he thinks of it --- he is the professor. I tend to be on Chuck's side a lot of the time. Why? That's a good one.. Lemme think.. Oh yeah, I remember: he invented the language! > I have already said many times that some of the code in the novice > package is low-level. The implementation of an array definer is very > low-level --- the important goal with arrays is execution speed --- > rules for readability that apply to high-level code get waived for low- > level code. I agree that library grade code has to follow slightly different rules than user programs. Still, this is a monster. > I use the word "function" just like everybody else in the programming > world. It was a mistake for Chuck Moore to use "word" to mean a > function, because "word" is more commonly used to mean a single- > precision integer. He most likely did that because in an indirect- > threaded-code system, functions do get compiled as single-precision > integers. That was in the 1970s though --- that is no longer true, and > it is irrelevant to the user what the internal representation is > anyway --- using "word" like that now is just confusing. You're entitled to an opinion, but everybody still uses the accepted Forth nomenclature. > I don't want Ed or anybody else to drop Forth. But I see people show > up on comp.lang.forth filled with enthusiasm for learning Forth, and > then they disappear after a few weeks. It is because you guys don't > offer any support for novices. This thread is a good example of how > you fail to support novices. Talking about ones-complement arithmetic > makes us look like idiots --- that is not helping to convince anybody > to stick with Forth. There is no separate group for Forth experts, so the discussions can get as high level as they get. And I think it's required to have such discussions, even if they go nowhere or just confirm the (sometimes uncomfortable) status quo. > I'm not aware of Ed's "track record" providing FP I/O words. In my > novice package I provide GET-FLOAT for input and SCIENTIFIC and > ENGINEERING for output. Did he write something like that? Better. I've worked with Ed on several occasions and I'm more than happy with his contributions > This kind of stuff is trivial. It is useful, which is why I provided > it in the novice package, but it is pretty basic. There is a lot more > important code in the novice package than this stuff. Sorry, I don't see it. Wrappers to ALLOCATE, lots of stuff to treat the stack as an array, lists (is this LISP?), duplicates of Forth200x words, etc. I've seen most and usually better. > I'm not aware of anybody on comp.lang.forth who is in my league. The > only person who is capable of writing something comparable to the > novice package is Anton Ertl, but he spends all of his time dinking > around with Gforth which is just a toy interpreter, and he seems to > have no interest in supporting application programming. You have a lot of respect for your guru, so much is clear. Where's your ultimate Forth compiler Hugh? > You know, > there is a reason why so few applications have been written in Forth > --- it is because the Forth experts aren't providing libraries of code > that would be useful for application programming. 4tH comes with 270+ libraries, totaling 500+ kB of code. Hans Bezemer
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-02-29 03:00 -0600 |
| Message-ID | <S9udnaaKz6GudNDSnZ2dnUVZ_hydnZ2d@supernews.com> |
| In reply to | #9745 |
Hans Bezemer <the.beez.speaks@gmail.com> wrote: > I agree that library grade code has to follow slightly different rules than > user programs. Still, this is a monster. How do you make the distinction? This is Forth, where everybody is a systems programmer; there is no class system, no priesthood that gets to write library code. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | The Beez <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-02-29 03:44 -0800 |
| Message-ID | <53978a58-0f49-492b-a27d-77e76bc0ef84@w19g2000vbe.googlegroups.com> |
| In reply to | #9746 |
On 29 feb, 10:00, Andrew Haley <andre...@littlepinkcloud.invalid> wrote: > How do you make the distinction? This is Forth, where everybody is a > systems programmer; there is no class system, no priesthood that gets > to write library code. In 4tH it's quite simple to see what is library code: its in the /lib subdirectory. I cannot speak for others. Of course, that's kind of oversimplification: library files in 4tH have some special constructs that makes them suitable for library files. Note that Chuck also made that distinction, he called them "files with compiler words" contrary to "application (user) words". I think it is good factoring when you see some code repetition across files to upgrade that code to "library files" and include it. On the other hand Chuck doesn't really believe in "reusuable code", he rather rewrites the code so that it is better suited for a sopecific application. I guess I'm much lazier than Chuck ;-) Hans Bezemer
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-02-29 11:19 -0600 |
| Message-ID | <EJSdnaxZIvK7w9PSnZ2dnUVZ_qCdnZ2d@supernews.com> |
| In reply to | #9748 |
The Beez <the.beez.speaks@gmail.com> wrote: > On 29 feb, 10:00, Andrew Haley <andre...@littlepinkcloud.invalid> > wrote: >> How do you make the distinction? ?This is Forth, where everybody is a >> systems programmer; there is no class system, no priesthood that gets >> to write library code. > In 4tH it's quite simple to see what is library code: its in the /lib > subdirectory. I cannot speak for others. > > Of course, that's kind of oversimplification: library files in 4tH > have some special constructs that makes them suitable for library > files. Note that Chuck also made that distinction, he called them > "files with compiler words" contrary to "application (user) words". Ah, okay. I'm perfectly happy with that distinction; after all, it's easy to determine which files contain compiler words. > I think it is good factoring when you see some code repetition across > files to upgrade that code to "library files" and include it. Fair enough. I just don't think that library code is a different kind of thing. It's all Forth... Andrew.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@yahoo.com |
|---|---|
| Date | 2012-02-29 22:48 -0800 |
| Message-ID | <16979769.880.1330584491726.JavaMail.geo-discussion-forums@ynlt17> |
| In reply to | #9745 |
On Wednesday, February 29, 2012 1:29:30 AM UTC-7, The Beez wrote: > Hugh Aguilar wrote: > > When working with numeric data, it is best to work with it as a > > number. Working with numeric data as a string is cumbersome --- that > > is the kind of thing that a Perl programmer would do! > I'd say it's just an additional formatter that can be added to an already > generated FP or double number. I don't see anything wrong with that. As a > matter of fact, adding an entirely new formatter would duplicate a lot of > code (especially in FP). Of course anybody who writes a function to convert a float into a string is duplicating code --- F. certainly has this code buried inside of it --- the problem is that we can't get access to that buried code. > > That looks like beautiful well-factored Forth code to me. It is longer > > than 7 lines (according to "Thinking Forth," functions should > > generally be 7 lines or less), but it follows a simple pattern so it > > is quite readable despite its length. > I don't say it's not readable: it just could be factored even more. > > > Ask Anton Ertl what he thinks of it --- he is the professor. > I tend to be on Chuck's side a lot of the time. Why? That's a good one.. > Lemme think.. Oh yeah, I remember: he invented the language! You're just name-dropping. I doubt that you have ever met Chuck Moore. I haven't. You are not the only person that name-drops Chuck Moore's name --- Elizabeth Rather endlessly brags about the fact that she knew Chuck Moore in the 1970s, and plasters this all over the Forth Inc. website --- strangely enough though, Chuck Moore doesn't brag about the fact that he knew her. Similarly, lot of people (including myself) invoke Chuck Moore's name on comp.lang.forth, but Chuck Moore hasn't visited comp.lang.forth in many years --- apparently because he thinks that c.l.f. is a big waste of time, and that there is nothing to be learned on c.l.f. (I would give him credit for being perceptive!). > > I have already said many times that some of the code in the novice > > package is low-level. The implementation of an array definer is very > > low-level --- the important goal with arrays is execution speed --- > > rules for readability that apply to high-level code get waived for low- > > level code. > I agree that library grade code has to follow slightly different rules than > user programs. Still, this is a monster. Most likely you don't understand how <6ARRAY> works, but have just noticed its length. It is actually generating several colon words using :NAME --- those are distinct functions, each of which is fairly short --- it is not a monolithic function. > > I don't want Ed or anybody else to drop Forth. But I see people show > > up on comp.lang.forth filled with enthusiasm for learning Forth, and > > then they disappear after a few weeks. It is because you guys don't > > offer any support for novices. This thread is a good example of how > > you fail to support novices. Talking about ones-complement arithmetic > > makes us look like idiots --- that is not helping to convince anybody > > to stick with Forth. > There is no separate group for Forth experts, so the discussions can get as > high level as they get. And I think it's required to have such discussions, > even if they go nowhere or just confirm the (sometimes uncomfortable) > status quo. A discussion of ones-complement arithmetic is neither low-level nor high-level --- it is just dumb. Besides that, doesn't everybody claim to be a Forth expert? Almost every time that I have mentioned that I am a Forth programmer (such as in a job interview), the person that I was talking to has informed me that he is a Forth expert. This claim is almost always based on the fact that he once implemented a Forth interpreter in C (or Perl for Passaniti). He expects me to be highly impressed, assuming that I am a mere application programmer and believe that compiler-writers are demi-gods. Invariably, in the next breath the self-proclaimed expert will tell me that Forth is too inefficient and too lacking in basic features to be used for application programming, but that implementing a Forth interpreter in C is a mildly fun C project. > > This kind of stuff is trivial. It is useful, which is why I provided > > it in the novice package, but it is pretty basic. There is a lot more > > important code in the novice package than this stuff. > Sorry, I don't see it. Wrappers to ALLOCATE, lots of stuff to treat the > stack as an array, lists (is this LISP?), duplicates of Forth200x words, > etc. I've seen most and usually better. Those wrappers for ALLOCATE are extremely useful, because they allow ALLOCATION to work (which I tried to get into Forth-200x to no avail). This is useful for cloning data-structures when the nodes are of various types and of various sizes. Also, I have compatibility between heap and dictionary allocation, so I can have data structures that contain some nodes in the heap and some in the dictionary. If I deallocate a node that is in the dictionary, it doesn't crash the computer (nothing happens). This allows me to shift some processing over to compile-time (putting the data-structure in the dictionary) that had previously been done at run-time (putting the data-structure in the heap), without having to modify the code that works with those data-structures. Go over that stuff again --- you might learn something. Read the file (http://www.forth.org/novice.pdf) for a discussion of what this stuff does. Your other comments were just nonsense. For example, saying that I have "lots of stuff to treat the stack as an array" isn't true. I have THIRD and all that, but those are just a handful of functions. I only use them when speed is an issue, but otherwise I use local variables. And what is wrong with lists? I was impressed by how Factor used "sequences" as its primary data-structure. My lists are my answer to Factor's sequences. Every language needs some kind of data-structure to use primarily (lists for Lisp, tables for Lua, sequences for Factor, etc.). > > I'm not aware of anybody on comp.lang.forth who is in my league. The > > only person who is capable of writing something comparable to the > > novice package is Anton Ertl, but he spends all of his time dinking > > around with Gforth which is just a toy interpreter, and he seems to > > have no interest in supporting application programming. > You have a lot of respect for your guru, so much is clear. Where's your > ultimate Forth compiler Hugh? I think Anton Ertl is a good Forth programmer. I also think that he has allowed himself to become a stooge of Forth Inc. and MPE. For example, he standardized BUFFER: in Forth-200x because both SwiftForth and VFX have it. That is ridiculous! He is dinking around with Gforth only because it is slower than SwiftForth and hence doesn't represent a threat to Forth Inc. --- he should be writing a library comparable to my novice package in order to support application programming --- he is supposed to be a teacher, and a library of code is the best way to teach students how to write applications. I have abandoned ANS-Forth and Forth-200x. I'm writing my own Forth, which I will call Straight Forth (my slogan will be: "Don't be gay --- program Straight"). It is coming --- there is a lot of work involved in writing a compiler (I should know, as I've done it professionally once before). Maybe I will just forget about Forth altogether. Imagine what a happy day that would be for Elizabeth Rather --- she would be dancing in the streets! Nobody in the real world cares about Forth. People graduate from college as computer programmers without ever hearing of Forth (when I have said that I'm a Forth programmer, the most common response is for people to think that I'm mispronouncing "Fortran"). Forth is a complete failure --- it is a waste of time. I'm one of a tiny handful of people who have worked professionally as a Forth programmer --- when I quit Testra in the late 1990s, I may have been the last of the Mohicans --- the last professional Forther on the planet (I don't consider Elizabeth Rather to be a programmer, so she doesn't count). > > You know, > > there is a reason why so few applications have been written in Forth > > --- it is because the Forth experts aren't providing libraries of code > > that would be useful for application programming. > 4tH comes with 270+ libraries, totaling 500+ kB of code. > > Hans Bezemer I'm somewhat interested in your 4TH. Is it ANS-Forth compliant? Does it generate machine-code, or is it just a threaded system?
[toc] | [prev] | [next] | [standalone]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-03-01 08:38 +0100 |
| Message-ID | <4f4f2729$0$6877$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #9764 |
hughaguilar96@yahoo.com wrote: > On Wednesday, February 29, 2012 1:29:30 AM UTC-7, The Beez wrote: >> Hugh Aguilar wrote: > You're just name-dropping. I doubt that you have ever met Chuck Moore. I > haven't. No, I never met Chuck, but I've read just about anything he wrote on Forth. It highly influenced my own compiler. I don't have to shake hands with a person and say "pleased to meet you" to know what he's saying. We invented writing a few thousand years ago for that. > Similarly, lot of people (including myself) invoke Chuck Moore's name on > comp.lang.forth, but Chuck Moore hasn't visited comp.lang.forth in many > years --- apparently because he thinks that c.l.f. is a big waste of time, > and that there is nothing to be learned on c.l.f. (I would give him credit > for being perceptive!). Chuck moved on - and I agree with him on that, yes. I think modern Forth is a travesty of what it should be. Maybe not for the same reasons you have, but still. > Most likely you don't understand how <6ARRAY> works, but have just noticed > its length. It is actually generating several colon words using :NAME --- > those are distinct functions, each of which is fairly short --- it is not > a monolithic function. Given the length I still doubt whether it's a good concept or a good design. > Besides that, doesn't everybody claim to be a Forth expert? Almost every > time that I have mentioned that I am a Forth programmer (such as in a job > interview), the person that I was talking to has informed me that he is a > Forth expert. This claim is almost always based on the fact that he once > implemented a Forth interpreter in C (or Perl for Passaniti). He expects > me to be highly impressed, assuming that I am a mere application > programmer and believe that compiler-writers are demi-gods. Invariably, in > the next breath the self-proclaimed expert will tell me that Forth is too > inefficient and too lacking in basic features to be used for application > programming, but that implementing a Forth interpreter in C is a mildly > fun C project. Like I've said all my life: gimme your criteria and I'll tell you what I am. If I agree with your criteria I agree with you what I am. Very much fun in a bar, when a guy calls you a $%&^@# and goes nuclear when you pose him that question. ;-) > Those wrappers for ALLOCATE are extremely useful, because they allow > ALLOCATION to work (which I tried to get into Forth-200x to no avail). > This is useful for cloning data-structures when the nodes are of various > types and of various sizes. Also, I have compatibility between heap and > dictionary allocation, so I can have data structures that contain some > nodes in the heap and some in the dictionary. If I deallocate a node that > is in the dictionary, it doesn't crash the computer (nothing happens). > This allows me to shift some processing over to compile-time (putting the > data-structure in the dictionary) that had previously been done at > run-time (putting the data-structure in the heap), without having to > modify the code that works with those data-structures. Go over that stuff > again --- you might learn something. Read the file > (http://www.forth.org/novice.pdf) for a discussion of what this stuff > does. I wrote my own wordset. ALLOCATION is called ALLOCATES there. My style of programming doesn't find much use for it. You knew it when you defined it and now you forgot? Cute, just like istype() with OO. > Your other comments were just nonsense. For example, saying that I have > "lots of stuff to treat the stack as an array" isn't true. I have THIRD > and all that, but those are just a handful of functions. You got up to the fifth level and that's just BAD! > I think Anton Ertl is a good Forth programmer. He is dinking around with > Gforth only because it is slower than SwiftForth and hence doesn't > represent a threat to Forth Inc. --- he should be writing a library > comparable to my novice package in > order to support application programming --- he is supposed to be a > teacher, and a library of code is the best way to teach students how to > write applications. Speed is only one quality of a compiler/interpreter. There are others. > I have abandoned ANS-Forth and Forth-200x. I'm writing my own Forth, which > I will call Straight Forth (my slogan will be: "Don't be gay --- program > Straight"). It is coming --- there is a lot of work involved in writing a > compiler (I should know, as I've done it professionally once before). Just do it! I've always said that the quality of Forth is that it can emerge in so many concepts. And even I hate Forth200x / ANS a lot, it offers the possibility to exchange code. E.g. I tried to port my stackoptimizer to ANS and in minutes it ran. I pinched DSQRT from NOVICE.4TH (yes, BSD licence + proper credits) and it ran. Good thing! > Maybe I will just forget about Forth altogether. Imagine what a happy day > that would be for Elizabeth Rather --- she would be dancing in the > streets! I think you overestimate the emotions concerning your person. Although you tend to irritate, I must admit, but that's how it is with nerds ;-) > Nobody in the real world cares about Forth. People graduate from > college as computer programmers without ever hearing of Forth (when I have > said that I'm a Forth programmer, the most common response is for people > to think that I'm mispronouncing "Fortran"). All too true. Still, I have used Forth in the real world (and still use it) and tend to outperform most common languages. > I'm somewhat interested in your 4TH. Is it ANS-Forth compliant? Does it > generate machine-code, or is it just a threaded system? Neither. It's a bytecode compiler - and a real one for that. It doesn't feature a dictionary, but uses a symboltable. It's even got a preprocessor. See: http://code.google.com/p/4th/wiki/Short4tHreview Hans Bezemer
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-03-01 00:57 -0800 |
| Message-ID | <c00cddcd-5a7e-46c3-b107-d5fa7cf8d7af@j8g2000yqm.googlegroups.com> |
| In reply to | #9765 |
On Mar 1, 12:38 am, Hans Bezemer <the.beez.spe...@gmail.com> wrote: > hughaguila...@yahoo.com wrote: > > Most likely you don't understand how <6ARRAY> works, but have just noticed > > its length. It is actually generating several colon words using :NAME --- > > those are distinct functions, each of which is fairly short --- it is not > > a monolithic function. > > Given the length I still doubt whether it's a good concept or a good design. It is just multiplication --- I didn't invent arrays --- they have been around for many decades. If you don't like multiplication, try ARY instead --- it uses arrays of pointers to effect multiple dimensions. > > Those wrappers for ALLOCATE are extremely useful, because they allow > > ALLOCATION to work (which I tried to get into Forth-200x to no avail). > > This is useful for cloning data-structures when the nodes are of various > > types and of various sizes. Also, I have compatibility between heap and > > dictionary allocation, so I can have data structures that contain some > > nodes in the heap and some in the dictionary. If I deallocate a node that > > is in the dictionary, it doesn't crash the computer (nothing happens). > > This allows me to shift some processing over to compile-time (putting the > > data-structure in the dictionary) that had previously been done at > > run-time (putting the data-structure in the heap), without having to > > modify the code that works with those data-structures. Go over that stuff > > again --- you might learn something. Read the file > > (http://www.forth.org/novice.pdf) for a discussion of what this stuff > > does. > > I wrote my own wordset. ALLOCATION is called ALLOCATES there. My style of > programming doesn't find much use for it. You knew it when you defined it > and now you forgot? Cute, just like istype() with OO. I often have types derived from other types. The data-structure contains a mixture of parent and child type nodes. Also, I use lists for almost everything. ALLOCATION is a half-step toward istype; all it provides is the size. If all the nodes in the data-structure are derived from each other however, then it is impossible for any of them to have the same size, so obtaining the size is just as good as obtaining the type. Mostly ALLOCATION is used for cloning a data-structure. See CLONE-LIST in LIST.4TH. In the slide-rule program, a lot of the scales are just slightly modified clones of each other (DI and DF are modified versions of D, for example). What I have is not as powerful as OOP, but it is extremely fast executing. I don't have any of the housekeeping that is normally involved in OOP (especially polymorphism), but I have inheritance which is the important aspect of OOP. In my experience, most programs don't need polymorphism or any of that other stuff --- what I provide is adequate for even large programs. If I had had this when I wrote my dxf-to-gcode program at Testra, it would have been much simpler --- and it would have still been just as fast. > > I have abandoned ANS-Forth and Forth-200x. I'm writing my own Forth, which > > I will call Straight Forth (my slogan will be: "Don't be gay --- program > > Straight"). It is coming --- there is a lot of work involved in writing a > > compiler (I should know, as I've done it professionally once before). > > Just do it! I've always said that the quality of Forth is that it can emerge > in so many concepts. And even I hate Forth200x / ANS a lot, it offers the > possibility to exchange code. E.g. I tried to port my stackoptimizer to ANS > and in minutes it ran. I pinched DSQRT from NOVICE.4TH (yes, BSD licence + > proper credits) and it ran. Good thing! Other than Mark Willis' ongoing encouragement, that is the first encouragement I've heard. Thanks! I don't mind if people borrow from the novice package --- that is why I made it BSD license. DSQRT is a rather trivial function though --- there is a lot better stuff in there than that. Steal big! > > Nobody in the real world cares about Forth. People graduate from > > college as computer programmers without ever hearing of Forth (when I have > > said that I'm a Forth programmer, the most common response is for people > > to think that I'm mispronouncing "Fortran"). > > All too true. Still, I have used Forth in the real world (and still use it) > and tend to outperform most common languages. Has anybody ever written an application program in 4TH that was used in the real world? By the "real world" I mean everything that exists beyond the edges of your desk. > > I'm somewhat interested in your 4TH. Is it ANS-Forth compliant? Does it > > generate machine-code, or is it just a threaded system? > > Neither. It's a bytecode compiler - and a real one for that. It doesn't > feature a dictionary, but uses a symboltable. It's even got a preprocessor. > See:http://code.google.com/p/4th/wiki/Short4tHreview It looks like you need to learn how to write a cross-compiler. You shouldn't have different names for host and targ words --- such as your [*] and * words --- the cross-compiler should be smart enough to know that a word used in interpretive mode is host and a word used inside of a colon definition is targ. What you have got reminds me a lot of my first cross-compiler (for the 65c02). I used different names like that. Later on when I wrote MFX at Testra for the MiniForth however, I figured out how to do it correctly. I remember that I was totally baffled by the concept of cross-compilation. Just putting the host and targ words in separate vocabularies isn't enough. I went on long bicycle rides to clear my head. One evening while riding near Papago Park I suddenly had a revelation --- I knew the trick for writing a cross-compiler! --- after that everything was easy. Don't worry though --- you aren't the only person who doesn't know how to write a cross-compiler. Stephen Pelc has publicly stated that a cross-compiler needs to simulate the target processor at compile-time. Really! He said that! If he would just ask me how to write a cross- compiler, I would tell him --- but he hasn't asked --- so he still doesn't know. I've never met anybody who knew. BTW, do you know about STAAPL? It similar to what you've got, except that its preprocessor code is written in Scheme. That is not much different from using [*] for multiplication --- a different syntax for host code!
[toc] | [prev] | [next] | [standalone]
| From | Hans Bezemer <the.beez.speaks@gmail.com> |
|---|---|
| Date | 2012-03-01 18:23 +0100 |
| Message-ID | <4f4fb05c$0$6894$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #9767 |
Hugh Aguilar wrote: > It is just multiplication --- I didn't invent arrays --- they have > been around for many decades. We're talking a novice package with 6(!!) dimensional arrays. I don't think newbies need 6-dimensional arrays. If you're fluent in Forth, you should be able to write your own 6-dimensional addressing word. > Other than Mark Willis' ongoing encouragement, that is the first > encouragement I've heard. Thanks! I don't use StrongForth myself, but I think it is a welcome addition to the family. Like yours: it sounds like an interesting concept. Just go for it, man! > I don't mind if people borrow from the novice package --- that is why > I made it BSD license. DSQRT is a rather trivial function though --- > there is a lot better stuff in there than that. Steal big! I'm not done with NOVICE.4TH yet.. ;-) > Has anybody ever written an application program in 4TH that was used > in the real world? By the "real world" I mean everything that exists > beyond the edges of your desk. Man, I don't know what my users are up to. Most stuff they send me are quite useful, quite elaborate libraries > It looks like you need to learn how to write a cross-compiler. You > shouldn't have different names for host and targ words --- such as > your [*] and * words --- the cross-compiler should be smart enough to > know that a word used in interpretive mode is host and a word used > inside of a colon definition is targ. I'm not sure about that. 4tH has a Harvard architecture, that's why it shares some resemblance with a cross compiler. You can't add [*] anywhere, just when two literals have to be multiplied at compiletime (since you don't know the contents of the variables or stack values yet). 4tH has a tiny peephole optimizer that optimizes instructions like "4 +", which it transforms into "self adding constants". However, if you would probe DEEPER, you could recognize expressions like "2 4 +" and make 4tH do it for you. However, that would have several implications and break lots of code. So for the time being, I left it that way, which means you have to write "2 4 [+]". > Don't worry though --- you aren't the only person who doesn't know how > to write a cross-compiler. When I designed 4tH I didn't know a bit about writing compilers or interpreters. Later I found out about parsers, tokenizers, virtual machines, token-threading, etc. Good for me, because otherwise I don't think the design would have been the same. Sometimes you know just a little too much to do it right. > BTW, do you know about STAAPL? It similar to what you've got, except > that its preprocessor code is written in Scheme. That is not much > different from using [*] for multiplication --- a different syntax for > host code! Well, STAAPL has a different basic architecture than 4tH. My preprocessor is a very conventional one, simply a programmable "rewriter" (like CPP, M4). And the resulting code is not stored in a dictionary, but a bytecode image. But sure, there are similarities. Hans Bezemer
[toc] | [prev] | [next] | [standalone]
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
Back to top | Article view | comp.lang.forth
csiph-web