<div dir="ltr">Thanks for your feedback David....<div><br></div><div>Yes, the intention is to support duck-typing.  In my code example,</div><div><br></div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">a.attrB1 = 5            .... is probably more accurately stated as .....</span><br>
</div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">a.</span><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"> attr1.attrB1 = 5 </span></div>
<div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div>
<div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">Certainly this would be an unsafe call because we would not know that </span><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">attrB1 is an attribute of </span><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">attr1 until runtime.  I believe this type of call is valid in a language like Python.</span></div>
<div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">Are there any references out there that would help me implement something like this?</span></div>
<div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">thanks,</span></div>
<div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">frank</span></div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div>
<div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span class="" style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><br></span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 25, 2013 at 4:16 AM, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 24 Apr 2013, at 23:13, Frank White <<a href="mailto:frankwhite1003@gmail.com">frankwhite1003@gmail.com</a>> wrote:<br>

<br>
> Hello everyone, I would like to implement functionality something like the following in my sample language.....<br>
><br>
<br>
</div>{snipped not very informative C++ pseudocode.}<br>
<div class="im"><br>
<br>
> I assume that I will need:<br>
><br>
> - some type of runtime lookup table to store the class structure of Class A and B.<br>
<br>
</div>That depends on your type system, which isn't clear from your language snippets.  Are you doing static type inference?  If so, this only needs to be stored in the AST, if not then you will need run-time type information.<br>

<br>
Does your language support duck typing?  If so, then you will need some form of dynamic lookup in a runtime library, if not then you will be able to just generate vtables and jump to constant offsets into them.<br>
<div class="im"><br>
> - some way of encoding and storing an object's attribute type information<br>
<br>
</div>Yes, if your language exposes these.<br>
<div class="im"><br>
> - a means of retrieving this information at runtime so that in the event that an object's attribute is itself an object, attributes from the latter can be accessed as well.<br>
<br>
</div>Correct.<br>
<div class="im"><br>
> I have looked at the LLVM API but didn't see any straightforward way to do this.<br>
<br>
</div>Correct.  These are highly dependent on your object model and your ABI.  For example, Clang supports Objective-C with two Apple and three GNU-like Objective-C runtimes.  This includes four (I think, possibly more now) ways of representing class structures and at least four ways of doing message sending.<br>

<br>
You choice is to either define a new object model and ABI, or follow the approach of LanguageKit and reuse an existing one (in our case, the GNUstep Objective-C runtime).  These choices are orthogonal to your choice to use LLVM for code generation.<br>

<span class="HOEnZb"><font color="#888888"><br>
David<br>
<br>
</font></span></blockquote></div><br></div>