[REBOL] Re: binary problem
From: dockimbel:free at: 3-Mar-2001 14:50
Hi Will,
Will Arp wrote:
> >> a: read/binary %callmov.r
> == #{
> 23212F7573722F6C6F63616C2F62696E2F7265626F6C2F7265626F6C202D6373
> 0A5245424F4C205B5D0A0A613A206C6F61642025767262696E320A633A20...
> >> same? a read/binary %callmov.r
> == false
> >>
>
> Hello 8)
> Well I was expecting a true result..
> Can please someone help ?
Try with 'equal? instead of 'same? :
>> equal? a read/binary %callmov.r
== true
'same? will return 'true only if the two arguments refer (or point) to the
same memory space.
Basically, 'same? applied on immutable values should work as you expected.
For example with an integer! (immutable):
>> a: 5
== 5
>> b: a
== 5
>> same? a b
== true
>> c: 5
== 5
>> same? a c
== true ; true !
>> equal? a c
== true
but, with a string! (mutable):
>> a: "foo"
== "foo"
>> b: a
== "foo"
>> same? a b
== true
>> c: "foo"
== "foo"
>> same? a c
== false ; false !
>> equal? a c
== true
> Is append a good way to join two binaries ?
Sure, it's a good way. You can also use 'join (should be a little bit faster).
HTH,
DocKimbel.