Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Creating an...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 62 of 65 Topic 3945 of 4285
Post > Topic >>

Re: Creating and using arrays - again

by "Mark W. Humphries" <mwh@[EMAIL PROTECTED] > Mar 23, 2008 at 05:26 PM

On Mar 24, 6:55 am, Jonah Thomas <jethom...@[EMAIL PROTECTED]
> wrote:
> "Mark W. Humphries" <m...@[EMAIL PROTECTED]
> wrote:
>
> > I've always liked that the normal behavior of variable data in Forth
> > is to leave its address on the stack. In most cases I eventually end
> > up going back and refactoring a CREATE DOES> construct into two
> > separate words by naming the former DOES> part promoting it to a full-
> > fledged word on its own. I end up with two words, two names, for two
> > behaviors, which seems natural to me. I can of course add myriad other
> > behaviors by creating other words that take an address parameter.
>
> Say that CREATE normally makes a word that does   address noop .
> And DOES> substitutes an action for the noop.
>
> It sounds like you're saying you like doing
>
> : action .... ;
> CREATE address
>
> And where someone else would use a DOES> child
>
> CREATE address
> DOES> action ;
>
> .... address ....
>
> you instead just do
>
> .... address action ....

The basic factoring pattern of Forth is:  <noun> <verb>
Nouns that denote variable data push a data address onto the stack.
Nouns that denote constant values push a value onto the stack.
Verbs consume addresses and/or values.

In my experience practices that break this pattern, such as an over-
abundance of prefix words like TO, or overriding data behavior with
DOES> lead to messy factoring in the long run.

> So you need 2 commands in your code each time where DOES> uses only one.
> Do that a lot and you use some space. You save the space used by your
> parent word and you can save the extra space in all those CREATEs.
> (Except the CREATEs don't have to use extra space. In an
> indirect-threaded system they can call the code in the parent, which
> finds the address from the return stack and then executes the following
> code. You can rearrange the complexity various ways.) You have to use
> extra code and extra source code.
>
> In exchange for those disadvantages, you get to choose any action you
> like to act on your address, and it takes no extra machinery to set that
> up. You just do it. Ultimate flexibility at the cost of a little extra
> typing and a little extra code.

The size that ultimately matters is the compiled size of the overall
application. An approach that may result in extra code for a single
snippet, can lead to less code overall if it encourages better
factoring of the overall application.

> > My impression is that whether one perceives DOES> as a necessity in
> > Forth has more to do with one's factoring style than anything else.
>
> I can't imagine thinking of DOES> as a necessity. But it can be a nice
> convenience.
 




 65 Posts in Topic:
Creating and using arrays - again
Duke Normandin <dukeof  2008-03-21 15:54:28 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-21 11:49:44 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-21 18:51:11 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-21 15:16:05 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-21 20:37:06 
Re: Creating and using arrays - again
JK <jk.usenet@[EMAIL P  2008-03-21 14:59:30 
Re: Creating and using arrays - again
Albert van der Horst <  2008-03-22 12:19:21 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-22 21:53:06 
Re: Creating and using arrays - again
Jonah Thomas <jethomas  2008-03-21 12:14:43 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-21 18:57:07 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-22 12:55:51 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-22 17:35:49 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-22 13:58:37 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-22 14:02:28 
Re: Creating and using arrays - again
kenney@[EMAIL PROTECTED]   2008-03-23 14:37:59 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-21 10:20:33 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-21 18:36:16 
Re: Creating and using arrays - again
Jonah Thomas <jethomas  2008-03-21 15:28:15 
Re: Creating and using arrays - again
Krishna Myneni <krishn  2008-03-21 20:20:55 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-22 03:06:35 
Re: Creating and using arrays - again
Duke Normandin <dukeof  2008-03-22 17:32:04 
Re: Creating and using arrays - again
"Mark W. Humphries&q  2008-03-21 21:05:28 
Re: Creating and using arrays - again
Andrew Haley <andrew29  2008-03-22 14:33:04 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-22 06:01:33 
Re: Creating and using arrays - again
Jonah Thomas <jethomas  2008-03-22 10:29:43 
Re: Creating and using arrays - again
Andrew Haley <andrew29  2008-03-22 14:36:34 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-22 12:48:49 
Re: Creating and using arrays - again
<Montesquiou>   2008-03-22 19:23:19 
Re: Creating and using arrays - again
Andrew Haley <andrew29  2008-03-22 22:19:36 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-22 22:45:21 
Re: Creating and using arrays - again
Andrew Haley <andrew29  2008-03-23 12:13:19 
Re: Creating and using arrays - again
Coos Haak <chforth@[EM  2008-03-23 13:37:55 
Re: Creating and using arrays - again
Andrew Haley <andrew29  2008-03-23 13:06:36 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-23 09:10:08 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-23 10:50:39 
Re: Creating and using arrays - again
Andrew Haley <andrew29  2008-03-23 15:50:35 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-23 10:49:26 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-23 10:47:31 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-23 11:33:59 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-25 17:39:47 
Re: Creating and using arrays - again
Dennis Ruffer <druffer  2008-03-26 00:57:35 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-25 20:43:54 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-26 11:00:22 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-22 08:44:53 
Re: Creating and using arrays - again
"Mark W. Humphries&q  2008-03-22 11:16:58 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-22 12:05:35 
Re: Creating and using arrays - again
Jonah Thomas <jethomas  2008-03-22 17:02:25 
Re: Creating and using arrays - again
Josh Grams <josh@[EMAI  2008-03-23 13:18:16 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-23 08:53:42 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-22 16:03:57 
Re: Creating and using arrays - again
Jerry Avins <jya@[EMAI  2008-03-22 22:46:54 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-23 06:23:42 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-23 06:46:58 
Re: Creating and using arrays - again
Albert van der Horst <  2008-03-24 02:48:31 
Re: Creating and using arrays - again
"Mark W. Humphries&q  2008-03-23 08:40:13 
Re: Creating and using arrays - again
Jonah Thomas <jethomas  2008-03-23 12:32:11 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-23 12:02:17 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-23 14:17:56 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-23 17:48:14 
Re: Creating and using arrays - again
Jonah Thomas <jethomas  2008-03-23 18:55:28 
Re: Creating and using arrays - again
Elizabeth D Rather <er  2008-03-23 19:02:53 
Re: Creating and using arrays - again
"Mark W. Humphries&q  2008-03-23 17:26:40 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-23 21:13:31 
Re: Creating and using arrays - again
Albert van der Horst <  2008-03-24 15:51:05 
Re: Creating and using arrays - again
Bruce McFarling <agila  2008-03-24 09:27:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 13:51:03 CDT 2008.