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

NOT a bug - Bug! - 'second ... Re:

 [1/3] from: joel:neely:fedex at: 6-Oct-2000 0:09

I don't think this is a bug. See below. [Al--Bri--xtra--co--nz] wrote:
> Bug! - 'second on object containing ONE hash! has TWO hash! !! >
Consider this transcript:
>> o: make object! [
[ a: "fee" [ b: "fie" [ c: "foe" [ d: "fum" [ ] (no fancy structures ;-)
>> print mold first o
[self a b c d] That was a list of words bound in the context of o ...
>> print mold second o
[ make object! [ a: "fee" b: "fie" c: "foe" d: "fum" ] "fee" "fie" "foe" "fum"] ...and those are their bindings in o (as I understand it). So the make object!... part is just the value of self in o .
> REBOL/View 30-Sep-2000 > Copyright 2000 REBOL Technologies. All rights reserved.
<<quoted lines omitted: 6>>
> h: make hash! [] > ] make hash! [...]]
Where the TWO values in the last response (block) are the values corresponding to [self h] in o. -jn-

 [2/3] from: al:bri:xtra at: 6-Oct-2000 0:15

Everyone is right in saying this is not a bug! I agree too!
> >> print mold second o > [
<<quoted lines omitted: 4>>
> d: "fum" > ] "fee" "fie" "foe" "fum"]
The first thing in: second o is the 'self word, which points to the object itself. That's this part: make object! [
> a: "fee" > b: "fie" > c: "foe" > d: "fum" > ]
The values of o/a, o/b, o/c and o/d are the next four things in second o: "fee" "fie" "foe" "fum" I thought it was a bug, because I have never before looked at what second returns from an object and because at the time, I was writing a object cloner which automatically copies an object, without having to have special code for the hash! data type. Here's what I've got for this: [ Rebol [ Name: 'Clone Title: "Clone" File: %Clone.r Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 6/October/2000 Enhancement: 'Clone Acknowledgements: "Erin A. Thomas" Purpose: { Clone objects by copying objects inside. } Example: [ New_object Clone Original_Object [] ] ] Clone: function [[catch] {Clones all sub-objects and hashes, so there are no multiple references.} Object [object!] "The object to clone." Block [block!] "Extra code for this object." ][ Cloned Member ][ Cloned: make Object Block foreach Word next first Object [ Member: get in Cloned :Word if same? Member get in Object :Word [ set in Cloned :Word either object? Member [ Clone Member [] ][ either any [ series? Member port? Member bitset? Member ][ copy/deep Member ][ Member ] ] ] ] Cloned ] ] When I was checking the cloned objects, I thought something had gone hideously wrong with my 'Clone function. Thanks everyone for pointing it out! Andrew Martin ICQ: 26227169

 [3/3] from: joel::neely::fedex::com at: 6-Oct-2000 7:08

[Al--Bri--xtra--co--nz] wrote:
> Everyone is right in saying this is not a bug! I agree too! >
> Thanks everyone for pointing it out! >
I thought you'd say "Thanks everyone for DOSing my mail server" ;-) I don't know how many of us hit "Reply" at the same time, and how many of us are Dopey (like me) and foreach through our incoming mail with zero lookahead! Sorry for the spam! -jn-

  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted