r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

BrianH
23-Mar-2008
[9520x2]
I mean out-of-bounds indexes. No, /Base doesn't include most mezzanines 
- you have to load them yourself.
If you need to know id the indexes were out of range, why don't you 
check if the indexes are out of range?
[unknown: 5]
23-Mar-2008
[9522x2]
I don't have to Brian.  Skip+ automatically tells me if they are.
Let's put it this way.  If I was using /base why would I ever use 
EXTRACT over SKIP+?
BrianH
23-Mar-2008
[9524]
That is what I mean. Under what circumstances would the indexes you 
are using ever be out of range, without you checking?
[unknown: 5]
23-Mar-2008
[9525x2]
Yeah if your checking Brian, But EXTRACT doesn't do checking.  SKIP+ 
does.
You have to use additional code to check if your series will be out 
of range if your going to use EXTRACT.  I don't have to with SKIP+.
BrianH
23-Mar-2008
[9527]
I am not asking to be snide, I am asking because we can change EXTRACT 
if the change makes sense.
[unknown: 5]
23-Mar-2008
[9528]
I'm hoping that is your position Brian because if it wasn't then 
REBOL could be in danger of becoming very less appealling.
BrianH
23-Mar-2008
[9529]
It always has been.
[unknown: 5]
23-Mar-2008
[9530x3]
Glad to hear Brian.
SKIP+ is less taxing on the stats/evals also.
SKIP+ wouldn't even exist had I known about extract (my lack of programming 
in REBOL for sometime)
BrianH
23-Mar-2008
[9533]
SKIP+ is a lot more taxing on the stats/evals, actually. There is 
more code in EXTRACT but that code is mostly error checking code 
that is run only once per call. The code that actually does the extract 
is more efficient:

    forskip block width [append/only new any [pick block pos value]]
versus
    series: at series start
    while [not tail? series][

        if (index? series) = start [insert tail blk first series start: start 
        + interval]
        series: next series
    ]
    series: head series
[unknown: 5]
23-Mar-2008
[9534]
That's true but as is the skip+ is more efficient.
BrianH
23-Mar-2008
[9535]
Wait, you may be right. It turns out that forskip is a mezzanine 
in R2, where it is native in R3.
[unknown: 5]
23-Mar-2008
[9536]
Yes that is true which is why I used while.
BrianH
23-Mar-2008
[9537]
That slowdown can be fixed.
[unknown: 5]
23-Mar-2008
[9538]
Even if the slowdown is fixed it will still return [none none none 
none ....] which is a feature of extract I don't particularly find 
as useful as just returning none!
BrianH
23-Mar-2008
[9539]
Now, back to the question, rephrased: What kind of code is generating 
indexes that are out of bounds?
[unknown: 5]
23-Mar-2008
[9540]
Brian if the block supplied as the series argument to EXTRACT is 
allocated dynamically it could easily create an out of bounds situation.
BrianH
23-Mar-2008
[9541]
I mean, the biggest problem I saw in SKIP+ was that start parameter. 
By using a seperate index you are just asking for out-of-bounds errors. 
Remember, series references include a position - you can just generate 
another series reference in the new position by using AT.
[unknown: 5]
23-Mar-2008
[9542]
Give me an example of what you mean with skip+.
BrianH
23-Mar-2008
[9543]
EXTRACT is generally used with series of lengths that are even multiples 
of the width parameter. Are you using incomplete series?
[unknown: 5]
23-Mar-2008
[9544x3]
Yes I can.
The series doesn't have to conform to the an even multiple with skip+
That is another reason to go with skip+ in my opinion.
BrianH
23-Mar-2008
[9547x2]
The only circumstance where you can get an out-of-bounds reference 
in EXTRACT is if the initial series position is out-of-bounds, which 
is definitely an error. EXTRACT is record-based, like skip+, so missing 
data is recorded with #[none].
The only difference between SKIP+ and EXTRACT related to bounds checking 
is that you can generate out-of-bounds references with SKIP+ using 
the start parameter, where with EXTRACT you would not be able to.
[unknown: 5]
23-Mar-2008
[9549]
I see other problem potentials for extract.   If the position value 
could ever be user supplied it causes a major problem.
BrianH
23-Mar-2008
[9550]
How so, and what do you mean?
[unknown: 5]
23-Mar-2008
[9551]
maybe not really as it does seem to truncate to the values
BrianH
23-Mar-2008
[9552]
You are using fixed-length records, right? Are there circumstances 
where the last record might be less than the fixed length? If so, 
what does that mean? Are the values considered missing?
[unknown: 5]
23-Mar-2008
[9553x2]
Not sure fixed length records
sure = using
BrianH
23-Mar-2008
[9555]
EXTRACT and SKIP+ extract values at fixed intervals, so that means 
you use them with series that are formatted in fixed intervals. Thus, 
fixed-length records.
[unknown: 5]
23-Mar-2008
[9556]
Well skip+ is not designed to need a fixed set of records towards 
its interval
BrianH
23-Mar-2008
[9557]
Yes, it is. Only the last record can be variable length.
[unknown: 5]
23-Mar-2008
[9558]
I assume you mean by fixed length that the series will be fixed to 
an even distribution of whatever the skip interval is.
BrianH
23-Mar-2008
[9559]
No, I mean the interval itself.
[unknown: 5]
23-Mar-2008
[9560]
Skip+ doesn't require is series to be fixed to the interval.
BrianH
23-Mar-2008
[9561x2]
>> blk: [1 2 3 4 5 6 7 8 9 10]
== [1 2 3 4 5 6 7 8 9 10]
>> skip+ blk 2 1
== [1 3 5 7 9]

You are treating the series as a series of records of length 2.
That is what the interval does, just like EXTRACT.
[unknown: 5]
23-Mar-2008
[9563x2]
I don't look at it that way.  I look at that I have a variable length 
of records in blk and I want to return every second one.
Probably just in how we relate to it.
BrianH
23-Mar-2008
[9565x2]
If the values in the series are themselves variable-length records, 
that's nice, but it doesn't affect what skip+ or extract does.
I'm only concerned with how you are treating the series itself.
[unknown: 5]
23-Mar-2008
[9567x2]
Ok Brian.  Hey the rebol community has extract and at least I have 
extract and skip+ so I'm happy.
I almost brought up my replace-all function.  Could have been here 
for the next year discussing that one.
BrianH
23-Mar-2008
[9569]
How is it different from replace/all ?