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: A Brief Loo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3928 of 4173
Post > Topic >>

Re: A Brief Look at History

by Bruce McFarling <agila61@[EMAIL PROTECTED] > Mar 18, 2008 at 09:46 PM

On Mar 18, 11:13 pm, Doug Hoffman <no.spam> wrote:
> It isn't the reordering of stack arguments that I object to (for the
> most part).  It's the use of different line drawing primitives.  That
> *totally* changes the comparison.



> Further, often one is "stuck", for whatever reasons, with a certain
> order of stack arguments.  So it seems to me that one is best off to be
> prepared to handle that.  Regardless, one can eliminate the stack order
> constraint (which I still maintain one shouldn't do here) and that still
> was clearly an apples to oranges comparison.  With locals I showed how
> one can effortlessly change the input order.  Leo Brodie mentions this
> advantage as well in Thinking Forth: page 204 "Third, all of your work
> becomes useless when a design change becomes necessary, and the order of
> the arguments changes on the stack."

> Would you agree that Andrew *did* use stack manipulation, counter to his
> claim?  I'm not knocking stack manipulation, I actually use it myself
> when needed.  Just wanting to get the facts right.

To use those primitives with the BOX2 stack order would require stack
manipulation in the word or factors to factor it out.

2VARIABLE turtle-pt0
2VARIABLE turtle-pt-target

: AT ( x y -- ) 2DUP turtle-pt0 2! turtle-pt-target 2! ;
: >X ( x -- ) turtle-pt-target CELL+ ! ;
: >Y ( y -- ) turtle-pt-target ! ;
: DRAW ( -- ) turtle-pt0 2@[EMAIL PROTECTED]
 turtle-pt-target 2@[EMAIL PROTECTED]
 LINE ;

Of course, it can't be localized to the scope of a word and those
words it called without:
: PUSH-TURTLE ( -- pt0 pt-target ) turtle-pt0 2@[EMAIL PROTECTED]
 turtle-pt-target 2@[EMAIL PROTECTED]
 ;

: start-line ( pt1 pt2 -- pt1 pt2 ) 2OVER AT ;
: draw-corner ( x2 y2 ) SWAP >X DRAW >Y DRAW ;

: BOX ( x1 y1 x2 y2 ) start-line draw-corner draw-corner ;

Is it something along those lines?

Of course, drawing an aligned rectangular corner is something that
could well be optimized with its own primitive, since there are
simplifications available when you know that you are heading
horizontally then vertically.
 




 1 Posts in Topic:
Re: A Brief Look at History
Bruce McFarling <agila  2008-03-18 21:46:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri Jul 25 22:27:17 CDT 2008.