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

[REBOL] Re: Core 2.5.5 Beta Versions

From: lmecir:mbox:vol:cz at: 24-Feb-2003 13:02

Hi Gabriele, you wrote:
> LM> I don't know your proposal, but I suspect, that its feasibility was > LM> questionable (for the current interpreter implementation). > > On the contrary, I think it would be very easy to implement. I > just think the interpreter should reset out-of-range series values > to the series tail when they are evaluated. > > I.e.: > > a: "12345" > b: skip a 2 > clear a ; nothing happens to b here > index? b ; == 1 (b is reset to tail b as soon as it is evaluated) > insert a "12345" > index? b ; == 1
it is as I guessed. The functionality you suggested is not compatible with the current implementation. The series index attribute isn't implemented as volatile, therefore the INDEX? function isn't able to change B (even if implemented natively). Your proposed behaviour would require a change of the series implementation.
> (as out-of-range > series are not useful, so I don't need that concept in the > language)
1) Out-of-range series are products of the current implementation and there is no way, how we can get rid of them without changing the implementation. 2) The current implementation of series allows the implementor to define three natives INT-INDEX? INT-PICK and INT-SKIP with the following properties: a) for any series S holds, that int-index? :s yields identical result as insert tail :s #"1" int-index? :s (This is a definition of the INT-INDEX? function.) b) for any series S and any integer I holds, that int-index? int-skip :s i always yields identical result as (int-index? :s) + i (This is a definition of the INT-SKIP function.) c) for any series S and any integer I holds, that int-pick :s i yields identical result as int-pick int-skip head :s (int-index? :s) + i - 1 (This is a main property of the INT-PICK function.) Moreover, I propose, that the INT-PICK function should fire an error for the "out of range" references, i.e. for such situations, where: any [ ((int-index? :s) + i - 1) > (length? head :s) ((int-index? :s) + i - 1) < 1 ] yields TRUE. 3) Compatibility: with a help of the above natives it is easy to define mezzanines like: INDEX?-PRE255, INDEX?-255, SKIP-PRE255, SKIP-255, PICK-PRE255, PICK-255, LENGTH?-PRE255, LENGTH?-255 etc. 4) Usefulness: a) see sub 3), with a help of the three proposed natives we can implement many different "index models". b) Some "index models" don't need any new mezzanines at all. E.g. a zero-based indexing: a: "123456789" a0: int-skip a 1 int-pick a0 0 ; == #"1" Or a 3-based indexing: a3: int-skip a 1 - 3 int-pick a3 3 ; == #"1" 5) Advantages: a) We will get rid of "second class/unuseful/strange" series, the previously "out of range" series will become I-based series for some I. b) We will have a flexible indexing system. c) No series reimplementation necessary. d) This indexing system will be simpler. e) This indexing system will be faster. 6) Disadvantages: we need three new natives.