Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Doesn't that just push the reflection out to the class builder?

No. Or at least, not necessarily.

I wrote a (primitive) 'ORM' using C and Embedded SQL against DB2 15 or more years ago. The objects were simply c-structs constructed from table schemas queried from system tables. Assessors were simply functions addresses through a dispatch table. The constructors queried the table, performed any necessary data conversions on the fields before allocating a struct and populating it. Each 'class' is written out as a C-source and compiled to an object library against which application were statically linked.

About the only thing that could even vaguely be termed "run-time refletion" was a binary hack to bypass a hardcoded, statically allocated limitation on the number of cursors available. Part of the C compile-time generated Embedded SQL. And that amounted to simply patching an address in a library generated struct to bypass the statically allocated cursor table to an enlarged one allocated at run-time. Until such times as the stick-in-the-muds on the DB2 development team wrapped their heads around the idea of dynamic memory allocation.

There was no reflection involved in either the generator, the 'classes' or the user applications. Though I suppose you could term querying the system tables for schemas, a form of reflection, but it's a bit of a stretch.

but also of how CDBI::Loader benefits from reflection to build its model -- if it does, in fact.

From a brief foray into the CDBI::Loader::Generic source, it appears to eval the generated classes into existance. And that's where the flexibility (or fuzziness if you prefer) of what consititutes 'compile-time' in Perl arises. The code is generated at run-time for the CDBI::L::G. But it is evaled into a different package space, so there is no self-modification aspect going on. And the resulting classes are just bog-standard Perl that could be generated to a file once (per schema change) and the loaded in the normal way.

Whether you can consider that 'run-time reflection' depends upon your goals I suppose. In keeping with my goal of supporting my premise, I going to say no :)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^6: Runtime introspection: What good is it? by BrowserUk
in thread Runtime introspection: What good is it? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found