Created
December 13, 2009 14:45
-
-
Save crcx/255441 to your computer and use it in GitHub Desktop.
Refactoring of contrib_comnmentary.retro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original by docl: | |
| {{ | |
| variable tmp | |
| : nf whitespace dup @ tmp ! off ; | |
| : rf tmp @ whitespace ! ; | |
| ---reveal--- | |
| : ::: nf 10 accept rf ; | |
| }} | |
| I believe the filtering ("nf", "rf") could be done better. | |
| Given: | |
| variable tmp | |
| : nf whitepsace dup tmp ! off ; | |
| : rf tmp @ whitespace ! ; | |
| Since the stack won't be touched outside of ":::", we can eliminate "tmp" variable: | |
| : nf whitespace dup @ swap off ; | |
| : rf whitespace ! ; | |
| Taking it one step further, both definitions can be merged with "later": | |
| : filter ( - ) whitespace dup @ swap off later whitespace ! ; | |
| And then, adapting ":::" to use it: | |
| : ::: ( "- ) filter 10 accept ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment