Welcome, Guest. Please login or register.
Kingdoms of Ahln
Pages: [1]
  Print  
Author Topic: Info and object attributes.  (Read 451 times)
Saffire
Citizen
***
Posts: 136


View Profile
« on: March 02, 2009, 08:22:30 pm »

Quick question: What is the difference between using info to store data and using attributes? Are there upsides and downsides to both, is one better in some situations, or all the time, or what?
Logged
Justin
Administrator
Citizen
*****
Posts: 189



View Profile
« Reply #1 on: March 02, 2009, 09:44:37 pm »

With the recent changes, there are fewer differences, but...let's see...

Using info:
+ Returns nil if the info does not exist (e.g, gameobj.info.something will always return -something-, instead of raising an error)
+ Easier to add/remove at runtime (because you do not have to create attribute accessors), no need to write code
+ AINFO is nicer than ASET? Maybe?
- More typing (obj.info.something instead of obj.something)
- Doesn't work with ALIST (yet)

Using attributes:
+ Less typing (just obj.something)
- Have to define accessors if you want to use them outside the class
- Raises errors if accessors are not defined (currently, the ASET command will not create attribute accessors for you)

That's all I can think of.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2006-2009, Simple Machines
Terra97 design by Bloc