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

World: r3wp

[!REBOL3-OLD1]

Pavel
10-Feb-2009
[10954]
Steeve small typo in your idx.r missing " in the end of line 266 
starting with  "; (notice that binary data.. otherwise works!
Steeve
10-Feb-2009
[10955]
ah ! thanks
Kaj
10-Feb-2009
[10956x2]
Thanks, Brian. Thatīs important info for my optimisation considerations
When surplus memory is preallocated for a block, is the block still 
initialised at the start of the memory or somewhere in the middle?
Steeve
10-Feb-2009
[10958]
one more question: when a value is removed inside the block. Is always 
the tail which is moved, or the head can be also ? (depending of 
the nearest one)
Pavel
10-Feb-2009
[10959x3]
Theoreticaly empty space may be in the middle, that is question of 
implementation with influence to performance of course (and diference 
betwen block, hash, list, map etc.)
diference= performance difference
ie shuffle data or pointers only
Steeve
10-Feb-2009
[10962]
Pavel, i'm talking about the new implementaion of blocks in R3 (it 
was addressed to Brian). There is no empty space in the middle of 
a block, never.
Pavel
10-Feb-2009
[10963]
I have no clue about low level implementation of blocks, but if it 
would be double linked list (from C algorithm POV) it wpould be possible, 
but you are right, doesnt mention it
Steeve
10-Feb-2009
[10964]
The double linked lists was used to implement list! type in R2, not 
blocks.
Pavel
10-Feb-2009
[10965]
OK
BrianH
10-Feb-2009
[10966]
I'm afraid I don't know more about R3's blocks than I've already 
said here - for more, ask Carl. That optimization sounds sensible, 
Steeve, but I don't know whether it is implemented, or what the performance 
tradeoff would be.
Pavel
11-Feb-2009
[10967x2]
Brian, Vector datatype can't be expanded or appended, ie the size 
is fixed in the moment of creation, for use as fix lookup maybe good, 
practically not, it is kind of series and should behave similarly
IMO
Steeve
11-Feb-2009
[10969x2]
there is lot of missing features related to vectors (find, mold, 
to binary!, etc...) It should have the same capabitilies than other 
series...
they are clearly not finished, it's not bugs
Rebolek
11-Feb-2009
[10971x2]
Some are missing features, some are bugs. For example, this one:

>> v: make vector! [- decimal! 32 100]
== vector!

>> v/0: 0
== 0

>> v/0
== 49151558502227733
Or this one:

>> v: make vector! [+ integer! 16 100]
== vector!

>> v/0: 20
== 20

>> v/1: 100
== 100

>> first v
== 100


See? I said that introducing zero based series in REBOL is not good 
idea :)
Pekr
11-Feb-2009
[10973x2]
I don't like Zero based indexing too. We are imo opening can of worms 
here.
I really don't understand, how guys might like new 'pick behaviour. 
The example given looks like very bad desicion was made. Why was 
it added? To enable various forms of loops over series?
Henrik
11-Feb-2009
[10975]
Pekr, read my response in the blog post.
Rebolek
11-Feb-2009
[10976]
Yes Pekr, this has nothing to do with zero based indexing. Series 
are still one based:
>> b: [a b c d e]
== [a b c d e]

>> b/1
== a

>> b/0
== none
Henrik
11-Feb-2009
[10977]
What we need to worry about is clarity of how each series type behaves 
with the series functions (as uniformly as possible) and fixing the 
bugs for AT on blocks and PICK on strings.
Pekr
11-Feb-2009
[10978]
Rebolek - but that is weird, isn't it? So b/-1 will return some word, 
while pick b -1 will return another?
Henrik
11-Feb-2009
[10979]
Pekr, both kinds behave identically here.
Pekr
11-Feb-2009
[10980]
Henrik - I am referring to Carl's proposed change to 'pick. Is it 
already implemented?
Henrik
11-Feb-2009
[10981]
Yes, it's been like this for some time, I believe.
Pekr
11-Feb-2009
[10982]
I will accept anything, as I hope Carl, BrianH etc. are very clever 
guys :-) I would just like things to be consistent. So when blog 
introduced some change, I would like to know also how functions like 
index? etc will behave ...
Rebolek
11-Feb-2009
[10983]
Pekr, [pick b 1] behaviour is not changed:

>> b: [a b c d e]
== [a b c d e]
>> b: skip b 3
== [d e]
>> b/0
== c
>> pick b 0
== c
>> b/1
== d
>> pick b 1
== d
>> b/-1
== b
>> pick b -1
== b
Pekr
11-Feb-2009
[10984]
You are right, those functionalities behave consistently. I probably 
need some "rebol philosophy" explanation for such stuff. Why e.g. 
head is at first series element, and why tail occupies one past last 
series element, etc.
Rebolek
11-Feb-2009
[10985]
the change is that -1 from R2 is now 0. This is logical imo.
Pekr
11-Feb-2009
[10986]
Rebolek - the thing is, that with REBOL, there is no 0th position.
Henrik
11-Feb-2009
[10987]
But there is in math.
Rebolek
11-Feb-2009
[10988]
the indexes in R2 were ...-3,-2,-1,1,2,3... now it's -3,-2,-,1,0,1,2,3
Henrik
11-Feb-2009
[10989x2]
When zero is added, the math for calculating offsets becomes simpler. 
Less code.
(but this is not zero-based indexing. it's not the same thing.)
Pekr
11-Feb-2009
[10991]
I have to think and come up with example, when you use index? something, 
to get your position, I think that then the change shifts the calculation 
in such a case...
Rebolek
11-Feb-2009
[10992]
Exactly, Henrik.
Henrik
11-Feb-2009
[10993x2]
Pekr, I don't know if it makes a difference, because INDEX? seems 
to be used only on positive values. Can INDEX? return negative values?
From what I see here, it can't, so it won't make a difference.
Pekr
11-Feb-2009
[10995x4]
I remember, in the past, to use index? heavily. But back then something 
like blk/:value was not possible. Can't find any example or use case 
where it could fail ... so it might mean, that current behaviour 
will not harm any code ...
btw - one question - in above Rebolek's example - why when we reassing 
(reference) a block ('b in his example), index? refers to original 
block, whereas functions like 'length? behave locally to new referenced 
block? Just a question :-)
... is it just because it is usefull this way, even if not consistent?
'b is a block! type, so no excuse here that it just "points to original 
block at certain position" applies here :-)
Henrik
11-Feb-2009
[10999x3]
It's perfectly consistent and useful for subblocks. If INDEX? was 
local to the block in use, a lot of things wouldn't be possible.
You would not be able to recall the position of the subblock. You 
would have to recalculate it every time.
If you want index to be zero, copy the block.
BrianH
11-Feb-2009
[11002x2]
Petr, I have been proposing that new PICKZ and POKEZ functions be 
added to do a 0-based PICK/POKE, instead of having vector! be 0-based. 
This would give us 0-based referencing abilities for all series, 
not just vectors, then we could make vectors 1-based like the rest. 
There are real advantages to 0-based indexing so it would be good 
to have it, but consistency is better here.


Carl was not proposing to make a change to PICK and POKE in his blog: 
he already (half) made the change. He was asking us in his blog if 
he should change it  *back* to the old, buggy R2 behavior. I think 
he should finish fixing PICK, POKE and AT instead.


Henrik, INDEX? returns a 1-based index from the *head* of the series 
- that's why it's always positive.
Indexes are calculated by adding the base to the offset. The new 
behavior for PICK and POKE makes that consistent, though AT should 
be fixed as well as it is the only index-based native left (unless 
I've forgotten something). I've added bug tickets for all of this.