World: r3wp
[Core] Discuss core issues
older newer | first last |
BrianH 23-Mar-2008 [9509] | I looked at skip+ above and could see from the code what it does. |
[unknown: 5] 23-Mar-2008 [9510x2] | Notice here: >> a == [1 2 3 4 5 6 7 8 9 10] >> skip+ a 2 1 == [1 3 5 7 9] >> skip+ a 2 11 == none |
Simple from its output I can tell that the index was out of range by the none that was returned. Can't tell that from extract. | |
BrianH 23-Mar-2008 [9512] | Re "Both": You said that you treat #[none] as no value, even in the middle of a series, and that is what EXTRACT does, so no, that is not your problem. |
[unknown: 5] 23-Mar-2008 [9513] | BrianH did you create the Extract function? |
BrianH 23-Mar-2008 [9514x2] | As an aside, whenever someone posts a message to AltMe my client locks up for 30 seconds to a minute, making it impossible for me to type replies. I am frequently unable to answer a question until much later because of this. Please wait until I have answered before asking the next question, or I won't be able to type the answer. |
Now in answer to your question, EXTRACT was created by the whole REBOL 3 group, though I wrote it. The changes to it were very intentional and the result of much debate. Please see the reasoning I wrote above. | |
[unknown: 5] 23-Mar-2008 [9516] | Well at least I got my skip+ function. |
BrianH 23-Mar-2008 [9517] | Under what circumstances are you using out-of-bounds values? |
[unknown: 5] 23-Mar-2008 [9518x2] | Does /base include mezzanines? |
I don't Brian. But I might want to know if the series was out of range to my request. | |
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. |
older newer | first last |