Let's say that I want to write several programs that use a particular file, so I want to package up all the code that refers to that file in a reusable module that I can "do" from the various programs that use that file. To make the source code of the various programs easier to understand, I want to apply some naming conventions to the data items in that common file. I personally like prefixes, for reasons not relevant at this time. So, I could do something like this: PROPMAST-ID: "" PROPMAST-ADDRESS: "" PROPMAST-OWNER: "" etc. OR, I could do something like this: PROPMAST: make object! [ ID: "" ADDRESS: "" OWNER: "" etc. ] and then refer to the items as PROPMAST/ID, PROPMAST/ADDRESS, etc. I believe I understand HOW to do this (I have done it in at least one situation), but I don't understand WHY I might choose one approach over the other. Is there some reason why one way might be preferred/recommended/better? Thank you.
It's easier to pass an object to a function than a bunch of variables It reduces name space pollution by having the single global
Interesting. I didn't even know you COULD pass an object to a function. Not only that, it never would have OCCURRED to me to do so. I am so deep in the third-generation-programming box I don't know if I ever will get out. REBOL is like therapy.
I'm not a fan of objects, but it avoids words variable to be overwritten. Remember that object can contains: variable functions objects look here: Code: >> a: make object! [ test1: "Hello" test2: $2 test3: func [] [print "Hi"] ] >> b: make object! [ test5: 10:00 test6: a ] >> ? b B is an object of value: test5 time! 10:00 test6 object! [test1 test2 test3]