The Artima Developer Community
Sponsored Link

Weblogs Forum
Dynamic Typing in C++

2 replies on 1 page. Most recent reply: Apr 6, 2005 6:56 PM by Christopher Diggins

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Dynamic Typing in C++ (View in Weblogs)
Posted: Apr 6, 2005 3:46 PM
Reply to this message Reply
Summary
I am working lately a lot on dynamic typing and functional programming in C++. I've recently hacked Kevlin Henney's cool boost::any type and introduced a variation, which allows referencing of values of any type without copying.
Advertisement
Recently I went in hacked up the boost::any type by Kevlin Henney for the OOTL. My variant is called ootl::Object but alongside of it is a new partner in crime called ootl::ObjectPtr. What ObjectPtr does is allow you to refer to just about any value-type without the overhead of a new operation.

The ObjectPtr implementation is a little tough to explain, and is based on the structural sub-typing mechanism I designed for my Interfaces proposal last year, and David Abraham's clever implementation which he posted on comp.std.c++. It essentially creates static function tables at compile-time, and stores a pointer to them along side the pointer to the value.

The code is posted at http://www.ootl.org/ootl/ootl_objects.hpp.htm, and some tests can be found at http://www.ootl.org/ootl/tests/ootl_test_objects.hpp.htm. I've tested the code using Visual C++ 7.1 and GCC 3.4. You can download the OOTL library ( which is now very compact because I have removed all references to Boost) at www.ootl.org

For those interested in the OOTL::ObjectPtr implementation, I recommend taking a look at the BIL Interfaces Library by Jonathan Turkanis. You can use his library to accomplish pretty much the same thing as follows:

BOOST_IDL_BEGIN(IObject)
BOOST_IDL_END(IObject)
typedef boost::manual_ptr ObjectPtr; 
Jonathan's library obviously does a heck of a lot more, and explores deeply the possibilities inherent of structural subtyping. The only drawback of Jonathan's library (if you can call it that) is that it requires Boost.

PS. Coming up soon, things you can do with comma operator overloading and dynamic typing in C++, that your parents don't want you to know about.


indranil banerjee

Posts: 38
Nickname: indranil
Registered: Nov, 2004

Re: Dynamic Typing in C++ Posted: Apr 6, 2005 5:51 PM
Reply to this message Reply
chris, I've seen your posts here and at boost and codeproject. I wish I had something more useful to say apart from I think you're a very creative thinker.

You're doing a great job. Keep going! I think OOTL will be a great project.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: Dynamic Typing in C++ Posted: Apr 6, 2005 6:56 PM
Reply to this message Reply
That was extremely nice of you to say Indranil! Thank you for the encouragement.

Flat View: This topic has 2 replies on 1 page
Topic: My Nerd Score: 99 Previous Topic   Next Topic Topic: The Vanishing Middle


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us