[REBOL] Extract applied to binary!
From: rudolf::meijer::telenet::be at: 16-Mar-2008 21:27
To quote change.txt included in the 2.7.6 SDK distribution: "Note that
<w>EXTRACT now returns a series of the same type as the source series." This
is technically true for binary series, but it still does not work as one
should have the right to expect intuitively. Let us take a simple binary
series, created by to-binary "1 2 3 ", thus #{312032203320}. One should
expect <extract #{312032203320} 2> to result in #{313233} just like <extract
1 2 3
2> results in "123". However this is not the case: the result is
#{343935303531}. This is because each element of a binary series is of type
integer, and although the first element of #{312032203320} is 49, the result
of <append #{} 49> is not #{31} but #{3439}, in other words 49 is implicitly
converted to string! before the append. However, if one computes <copy/part
#{312032203320} 1>, one gets #{31}, and <append #{} #{31}> yields #{31} as
it should. In other words, in the source of extract, it suffices to replace
<pick block pos> by <copy/part at block pos 1>, in order to obtain a result
which is similar to that for strings.
What do you think?
Rudolf W. MEIJER
mailto:rudolf.meijer-telenet.be
http://users.telenet.be/rwmeijer/