update the article on shuffle words to hide away the more troublesome ones

db4
Joe Groff 2009-10-29 11:36:06 -05:00
parent 2599993093
commit f21ba7a759
1 changed files with 23 additions and 11 deletions

View File

@ -821,10 +821,26 @@ HELP: assert=
{ $values { "a" object } { "b" object } }
{ $description "Throws an " { $link assert } " error if " { $snippet "a" } " does not equal " { $snippet "b" } "." } ;
ARTICLE: "shuffle-words" "Shuffle words"
"Shuffle words rearrange items at the top of the data stack. They control the flow of data between words that perform actions."
ARTICLE: "shuffle-words-complex" "Complex shuffle words"
"These shuffle words tend to make code difficult to read and reason about. Code that uses them should almost always be rewritten in terms of the " { $link "dataflow-combinators" } "."
$nl
"The " { $link "cleave-combinators" } ", " { $link "spread-combinators" } " and " { $link "apply-combinators" } " are closely related to shuffle words and should be used instead where possible because they can result in clearer code; also, see the advice in " { $link "cookbook-philosophy" } "."
"Duplicating stack elements deep in the stack:"
{ $subsections
dupd
tuck
}
"Permuting stack elements deep in the stack:"
{ $subsections
swapd
rot
-rot
spin
roll
-roll
} ;
ARTICLE: "shuffle-words" "Shuffle words"
"Shuffle words rearrange items at the top of the data stack. They provide simple data flow control between words. More complex data flow control is available through the " { $link "dataflow-combinators" } "."
$nl
"Removing stack elements:"
{ $subsections
@ -839,21 +855,17 @@ $nl
dup
2dup
3dup
dupd
over
2over
pick
tuck
}
"Permuting stack elements:"
{ $subsections
swap
swapd
rot
-rot
spin
roll
-roll
}
"There are additional, more complex stack shuffling words whose use is not recommended."
{ $subsections
"shuffle-words-complex"
} ;
ARTICLE: "equality" "Equality"