Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: On ordinal and cardinal numbers...

From: joel:neely:fedex at: 7-Jul-2001 10:58

Hello, again, Jeff, Jeff Kreis wrote:
> > I assumed that the other option that had been raised > > (having some sort of global flag that would switch all > > existing words between 1- and 0-origin behavior) was not > > acceptable/feasible. > > A setting verses replicating all the series actions for zero > based indexing. > > If you globally set your base you'll break at least half the > scripts you DO, pretty much forever. Some algorithms will be > agnostic to the base, but many will not (as Joel Neely has > been showing). Programmers shouldn't have to write their > code twice for each base that your REBOL might be running > under. >
I don't proposing doing so (either having the flag or writing scripts twice). That said, this kind of global switch setting does occur in other languages. One standard technique for managing the effects is to make the switch read/write, not write-only. A routine that has some reason to twiddle a global switch accepts responsibility for saving the state of the global, doing its own thing, then restoring the state before exiting. It is, of course, much simpler simply to do without features that affect the global state. Just imagine the chaos that could ensue if, for example, we allowed a function to change the current directory, close a file, or modify a global variable... The mind boggles! ;-)
> On second thought, replicating all the series actions is > sounding much more preferable... >
We can certainly agree on that. -jn- --------------------------------------------------------------- There are two types of science: physics and stamp collecting! -- Sir Arthur Eddington joel-dot-neely-at-fedex-dot-com