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.