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

Objects

 [1/6] from: ptretter::charter::net at: 20-Aug-2000 16:05


What benefit is there to make object!. I have not discovered the usefulness of this yet unless its just to access, thru refinements, the individual values within. Is there a bigger picture that I am missing? Paul Tretter

 [2/6] from: carlos:revistaeletronica at: 20-Aug-2000 20:45


Hi friends, As a regular programmer not used to OOP I'd like to know the answer to this question too to get more about REBOL. Lorenz

 [3/6] from: bhandley:zip:au at: 21-Aug-2000 11:15


Objects provide a way to group a set of values into a context that can be passed around as a whole and treated as a single value. This is useful for dealing with structures that are more complex in nature, as they allow the data and code to be kept together (encapsulated). Once created, an object can be treated as a single value. It can be passed to a function as an argument, returned from a function as a result, or set to a word. The values within the object are accessed by name. That was from the user guide. Objects help to structure scripts. Think of how useful local variables are in functions. You create a local variable, use it and know that it will not clash with words outside of the function*. Objects give you local variables and local functions packaged together into one blob. Now that is useful. The local functions can see the local variables and the other local functions and be like a mini-program embedded inside a bigger one. Before I get clouted for using confusing terminology - the guide refers to these as "fields" or "instance variables" and "object functions". Here's an example, when I've been programming using the parse function, I can end up with quite a few parse rules and other variables related to parsing. It might be that I want my parsing functionality to be part of a bigger script - so it would be good to put everything related to parsing (rules, flags, functions) in one spot - an object. Doing this makes my overall script more readable since I know that everything in that particular object relates to the parsing functionality. Also, it simplifies the my naming of words and prevents naming clashes with global words. It sort of like having work areas of a factory floor painted with coloured safety lines in order to separate hazardous machines or processes. As the guide mentions another use for objects is for structuring your data. You can create a special data structure with functions to manipulate it and put these in an object. So you can have object functions that add and remove values from your data structure and be comforted to know that the object is making sure the structure is always mainted properly. Brett. * Unless you have done something quite tricky - but let's leave that for now.

 [4/6] from: carlos:lorenz at: 20-Aug-2000 22:54


Thanks for the explanation Brett. I can't wait no more my Official Guide. I hope I can find easy examples on this matter inside it! Carlos Lorenz

 [5/6] from: ptretter:charter at: 20-Aug-2000 21:39


Brett your a blessing to this list. Thanks for the great explanation. I have the Official Guide and hope to cover that topic more as progress. I didnt want to get ahead of myself in the book. Thanks again. Paul Tretter

 [6/6] from: alex:pini:mclink:it at: 22-Aug-2000 21:02


>- Open Your Mind -<
Quoting from [ptretter--charter--net's] message (20-Aug-00 23:05:13). p> What benefit is there to make object!. I have not discovered the usefulness p> of this yet unless its just to access, thru refinements, the individual p> values within. Is there a bigger picture that I am missing? Encapsulation/protection in a private context? Alessandro Pini ([alex--pini--mclink--it]) Such as?.. "I don't know, I'm not a tailor." (Garak & Quark)