----- Original Message ----
From: John Siracusa <[EMAIL PROTECTED]>
To: rose-db-object@lists.sourceforge.net
Sent: Tuesday, May 30, 2006 9:02:39 AM
Subject: [RDBO] Sugared class setup proposal

How does everyone feel about the following bit of syntactic sugar?

Traditional:

    __PACKAGE__->meta->table(...);
    __PACKAGE__->meta->columns(...);
    __PACKAGE__->meta->unique_keys(...);
    __PACKAGE__->meta->foreign_keys(...);
    __PACKAGE__->meta->relationships(...);
    __PACKAGE__->meta->initialize;

Sugared:

    __PACKAGE__->meta->setup
    (
      table         => ...,
      columns       => [ ... ],
      unique_keys   => [ ... ],
      foreign_keys  => [ ... ],
      relationships => [ ... ],
    );

with the following differences:

1. setup() will only run once.  (An override will be available to
force it to run more than once.)

2. initialize() is implied (but may be specified as an 'initialize =>
[ ... ]' parameter if you want to pass arguments to initialize()).

3. Any class referenced in a foreign key or relationship will be
require()d automatically just before initialize() is called.

I think this will save some typing and eliminate the repeated
appearance of "__PACKAGE__->meta->" in class setups.  It's also a very
straightforward syntax that delegates everything to the "real"
methods.  The only part that requires consideration is that all
argument lists must now be wrapped in anonymous arrays, so each method
knows where its arguments begin and end.

So, opinions?  Suggestions?

-John
-------------------------------------------------------

Sounds good to me. I'm all for reducing the probability of typos by reducing 
the typing required.

One question though, may I assume the old syntax will still be valid?

Thanks and keep up the good work!





-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to