Calling method by name.

Jacob Carlborg doob at me.com
Sat Feb 5 14:01:46 PST 2011


On 2011-02-04 17:17, Adam Ruppe wrote:
> Jacob Carlborg wrote:
>> The class "Post" maps to the database table "posts", no configuration is
>> necessary. Then you can use the column names in the table as fields to
>> set and get data, like this:
>>
>> post = Post.new
>> post.title = "some title"
>> post.body = "the body"
>> post.save # will update the database
>
> Note that you can do this kind of thing with D's compile time
> reflection and CTFE as well. That particular example works
> in my own DataObject class (except I called it "commitChanges"
> instead of "save").

Yeah, I tried to do the same. But in this case the static type system 
was kind of in the way of what I wanted to do. This is so much easier 
with a dynamic type system.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list