World: r3wp
[Core] Discuss core issues
older newer | first last |
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 ? |
[unknown: 5] 23-Mar-2008 [9570x2] | b: [[1] [[[1]]] [1]] |
how do you replace/all the 1's in that with 2's? | |
BrianH 23-Mar-2008 [9572] | I'd probably use parse, or Gabriele's rewrite function. How did you do it? |
[unknown: 5] 23-Mar-2008 [9573] | Mine is strictly a replace/all function it is much more tasking on the system but if made native could probably be cool |
BrianH 23-Mar-2008 [9574] | Will you only be replacing literal values, or doing general pattern replacement? |
[unknown: 5] 23-Mar-2008 [9575] | any occurrence even in embedded series |
BrianH 23-Mar-2008 [9576] | I got that :) I was wondering what kind of things you were searching for, to be replaced. Just literal values? Blocks? |
[unknown: 5] 23-Mar-2008 [9577] | practically anything |
BrianH 23-Mar-2008 [9578] | Interesting. How do you check for equality? Do you go by reference or structural equivalence? |
[unknown: 5] 23-Mar-2008 [9579x3] | well that is where it gets a little of a concern. Currently, I only check for equal? |
>> b: [[1] [[[1]]] [1]] == [[1] [[[1]]] [1]] >> replace-all b [1] [2] == [2] >> b == [[2] [[[2]]] [2]] | |
Can also do this: >> b: [[1] [[[1]]] [1]] == [[1] [[[1]]] [1]] >> replace-all b 1 2 == 2 >> b == [[2] [[[2]]] [2]] | |
BrianH 23-Mar-2008 [9582] | That is structural equivalence. Nice. |
[unknown: 5] 23-Mar-2008 [9583x2] | >> b: [[1] [[[1]]] [1]] == [[1] [[[1]]] [1]] >> replace-all [1] "1" ** Script Error: replace-all is missing its newval argument ** Near: replace-all [1] "1" >> replace-all b [1] "1" == "1" >> b == ["1" [["1"]] "1"] |
It works very well | |
BrianH 23-Mar-2008 [9585x2] | I would call it replace-deep, but cool. |
Is it recursive? | |
[unknown: 5] 23-Mar-2008 [9587x2] | yes |
Doesn't take much | |
older newer | first last |