World: r3wp
[Core] Discuss core issues
older newer | first last |
[unknown: 5] 23-Mar-2008 [9496x2] | Skip+ does it find BrianH and I don't have to catch any errors. |
And it returns a none datatype if out of range. I don't have to check for "out of range" as the none being returned tells me that. | |
BrianH 23-Mar-2008 [9498] | Sorry, I don't get something. Are you saying that EXTRACT is returning the word 'none rather than the value #[none], or that you are using the word 'none in your series for something else? |
[unknown: 5] 23-Mar-2008 [9499x2] | It is returning the none in the block when I could actually already be using the word none in the block |
So if I'm using 'none in the block and it is returning #[none] then I have to check to determine if the value returned is a none! or a 'none. | |
BrianH 23-Mar-2008 [9501x2] | Let's make a distinction here: The word 'none, the value #[none]. EXTRACT returns the value #[none]. What are you using 'none for? |
Sorry, AltMe is locking up on me again. I wrote that message 2 minutes ago. | |
[unknown: 5] 23-Mar-2008 [9503] | Sometime I use the value none to specify that position in the series doesn't currently have a value. I'm sure many have done this. |
BrianH 23-Mar-2008 [9504] | That is how EXTRACT treats #[none], every time. |
[unknown: 5] 23-Mar-2008 [9505] | Brian did you create the EXTRACT function or something as I can't see how anyone would prefer its return value over a simple return for general use. |
BrianH 23-Mar-2008 [9506] | So your problem isn't with EXTRACT treating #[none] as no value, it's with it treating out-of-bounds as a non-error. |
[unknown: 5] 23-Mar-2008 [9507x2] | Both |
Did you try the skip+ function from above? | |
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 [9544x2] | Yes I can. |
The series doesn't have to conform to the an even multiple with skip+ | |
older newer | first last |