Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Bug or feature ?

 [1/3] from: marekw::tpg::com::au at: 11-Jan-2001 2:01


I'm not an expert, so you may help. Stragling with my little program, I came across this.
>>items: [i1 7 i2 555] ;ok >>items/i1 + 55 ; ok >>items/i1: 4 + 12 ; ERROR, (items/i1: 4) returns block, not integer
Should not > items/i1: 666 < behave like > items/i1 < ? Is this reported already, or is it needed for anything? What do you say?

 [2/3] from: al:bri:xtra at: 11-Jan-2001 6:59


> >>items: [i1 7 i2 555] ;ok > >>items/i1 + 55 ; ok > >>items/i1: 4 + 12 ; ERROR, (items/i1: 4) returns block, not integer > > Should not > items/i1: 666 < behave like > items/i1 < ? >> items: [i1 7 i2 555]
== [i1 7 i2 555]
>> items/i1 + 55
== 62 Note that items/i1 returns the value 7, which then gets added to 55.
>> items
== [i1 7 i2 555] and note that the original block (or series) _doesn't_ get altered.
>> items/i1: 4 + 12
== [i1 16 i2 555] Note that the intent is assignment at 'i1 in the block of the result of 4 + 12, and Rebol returns the result, which is the changed block, as shown here:
>> items
== [i1 16 i2 555]
>> items/i1: 666
== [i1 666 i2 555]
>> items
== [i1 666 i2 555]
>> items/i1
== 666
> Should not > items/i1: 666 < behave like > items/i1 < ?
The first is set at the position and return the value (block) for reuse, while the second is get at the position and return the value. It's neither bug or "feature", but a part of the design of Rebol. I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [3/3] from: arolls:bigpond:au at: 11-Jan-2001 14:28


> >>items: [i1 7 i2 555] ;ok > >>items/i1 + 55 ; ok > >>items/i1: 4 + 12 ; ERROR, (items/i1: 4) returns block, not integer > > Should not > items/i1: 666 < behave like > items/i1 < ?
When you set an element of a block, the element is changed, and then the block is returned (as Andrew said, for reuse.) When you get an element of a block, only the element is returned. In this line, items/i1: 4 + 12 This happens first; items/i1: 4 <- it returns the altered block. Then this; + 12 <- trying to add 12 to the block. Error. That's because rebol evaluates from left to right. To fix, use parentheses. items/i1: (4 + 12) Anton.