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

[REBOL] Re: object funnies

From: gchiu:compkarori at: 21-Oct-2001 17:18

Hi Chris,
> Maybe because although you would like to encapsulate some > variables in an > object, you still want it to be able to define global > words through its > methods. Hence what is not declared as local is global.
Yes, but no, I don't want any globals.
> I've looked at your code, have you noticed you call the > initialise functions > twice, and one as such (if I understand your indenting) : > > o: make object! [ > init-vars: func [][ ... ] > > do-something: func [][ > init-vars > reduce [ something > ] > ] > > init-vars > ] > > now the last init-vars will be called upon the creation > of the object... > maybe that's what you're trying to achieve... but maybe > it's something you > have overlooked...
No that's correct. Init-variables sets the value of all the variables which are dependent upon the value of cellsize. When the board is resized, it is called again - in the resize-board function which you call 'do-something.
> Finally, it's not unusual to take something procedural > and making > object-oriented. However I personnally don't think it > should be as easy as > adding make object! [ ... ]. If you want to make your > code oop'ed, redesign
Haha. From what I read, it was just a matter of wrapping my procedural code into a separate context :)
> it all for this. I strongly suggest you to use self to > refer to the > properties or methods within the object, this help > understand the code... >
Yes, I agree.
> But more on the subject of objects pretty soon... >
And I shall look forward to your How-to on objects :) -- Graham Chiu