Naive Forth questions 
Author Message
 Naive Forth questions

I am not a newbie, per se, although I am by no means an expert.  I played
around a little with MUCK Forth many years ago, then got deeper into it when I
found that it was the best (for my needs, anyway) language for writing Palm
programs.  But having recently (2 or 3 years ago) jumped into it on my own,
and never having studied it formally (although Neal Bridges' Quartus page is
MOST educational), I have a few questions.

I realize that these questions have no right or wrong answers, and rest
assured, all I'm asking for is opinions on style, not actual help with
concrete Forth problems.

What are the (very general) usage differences between the following words?
[Yes, I'm aware that you can name any word anything you want, but there lies
madness.]

foo    Guess:  Random word, can return or do anything.
(foo)
[foo]
foo?   Guess:  Returns boolean flag.
foo:

In fact, I'll save my other questions for later.  That's the important one.

-Jeffy

--



Wed, 17 Sep 2003 06:53:35 GMT  
 Naive Forth questions

Quote:
> I am not a newbie, per se, although I am by no means an expert.  I played
> around a little with MUCK Forth many years ago, then got deeper into it when I
> found that it was the best (for my needs, anyway) language for writing Palm
> programs.  But having recently (2 or 3 years ago) jumped into it on my own,
> and never having studied it formally (although Neal Bridges' Quartus page is
> MOST educational), I have a few questions.

> I realize that these questions have no right or wrong answers, and rest
> assured, all I'm asking for is opinions on style, not actual help with
> concrete Forth problems.

> What are the (very general) usage differences between the following words?
> [Yes, I'm aware that you can name any word anything you want, but there lies
> madness.]

> foo    Guess:  Random word, can return or do anything.

Right.  Ideally the name should be a simple (i.e. not concatenated or abbreviated)
word that conveys the purpose of the function.

Quote:
> (foo)

Non-user support word that does the principle work of FOO.  FOO may provide some
user interface, error-checking, or other wrapping around (foo).

Quote:
> [foo]

an IMMEDIATE, compile-time only word similar to FOO (e.g., CHAR and [CHAR], ' and
['])

Quote:
> foo?   Guess:  Returns boolean flag.

Yep, normally true if successful.  An extremely common and useful companion is
-FOO, which returns a boolean which is negative-true (e.g., true if there was an
error, in which case its value can be the specific error condition).

Quote:
> foo:

Specialized FOO-ish version of : (a defining word).

<commercial> My "Forth Application Techniques" book contains a list of similar
naming conventions, along with many style advisories, in its last chapter.
</commercial>

Quote:
> In fact, I'll save my other questions for later.  That's the important one.

> -Jeffy

Cheers,
Elizabeth
--
================================================
Elizabeth D. Rather   (US & Canada)       800-55-FORTH
FORTH Inc.                                      +1 310-491-3356
5155 W. Rosecrans Ave. #1018  Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

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



Wed, 17 Sep 2003 07:42:08 GMT  
 Naive Forth questions


My style only but I think used in some other places too.

Quote:
> foo    Guess:  Random word, can return or do anything.

   I generally use this as the top level or only word of it's genre.

Quote:
> (foo)

   A machine coded primitive component of the word "foo" and fulfilling
   the majority of the task. Most times used thus:-

         : foo (S * -- *' )
           (foo) ;

Quote:
> [foo]

  Rarely used form but when used is a component form as in machine coded
  but maybe using active arrays.

Quote:
> foo?   Guess:  Returns boolean flag.

  Yes.

  You could have also mentioned ?foo which expects a boolean flag on the
  stack and will perform either of two related functions.

Quote:
> foo:

  A compiling word with specific action (DOES> part) to be performed.

Quote:
> In fact, I'll save my other questions for later.  That's the important one.

--
********************************************************************

Forth based HIDECS Consultancy .....<http://www.amleth.demon.co.uk/>
Mob: +44 (0)7811-639972 .........NOW AVAILABLE:- HIDECS COURSE......
Tel: +44 (0)1235-814586 .... see http://www.feabhas.com for details.
Going Forth Safely ..... EBA. www.electric-boat-association.org.uk..
********************************************************************


Wed, 17 Sep 2003 17:46:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. naive type checking II (not so naive?)

2. Questions from a naive user

3. Questions from a naive st programmer

4. Extremely naive (and probably stupid) question

5. (Yet another) naive question

6. Naive question

7. Naive question

8. Another naive question

9. Naive Number Question

10. Naive Number Question

11. Naive newbie question.

12. Naive Dylan question

 

 
Powered by phpBB® Forum Software