On Oct 3, 2006, at 3:45 PM, Frank Condello wrote:

You could use a dictionary. First, store your values from your config file into a dictionary, and then copy them to your local variables, if you so desire.
...

I don't see how this will save me much work. I still have to create code for every possible value it seems. I mean I already have objects with named properties, there has to be some smart way to take something like car.maxspeed = 248 from a config file and get it into a car object with a maxspeed property. This would be simple in javascript.

You can use Operator_Lookup to create "properties" at runtime using a dictionary as storage, but it can't be used to shadow real properties. The Operator_Lookup approach isn't ideal for performance critical reads/writes but does provide a lot of flexibility - e.g. once set up, you can add a new key pair to your config and automatically use it in your code with no further effort. It does have the side effects of no autocomplete and never catching undefined errors (though you can generate runtime errors for the later).

FWIW, I'm having great success using Operator_Lookup as the basis of an Object-Relational mapping framework. I can point a generic database table wrapper class at a database table, and then just start referring to the fields of the table as properties of the objects without further ado. I'm also able to use the deferred access to track which fields have been modified so I can write them back to the database, and so on.

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to