<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 11, 2017, at 10:36 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Would it make sense to push the value retrieval down into DWARFFormValue to separate getting the value from a DIE from getting the value into some particular type - they seem pretty orthogonal & it's odd that DWARFDie handles the type handling side of that rather than an attribute/form abstraction.<br class=""><br class="">Perhaps it'd be a bit abusive, but we could even overload op[](dwarf::Attribute) on DWARFDie for easy map-like attribute lookup. Maybe 'find' would be a better name, though.<br class=""><br class="">I'm OK omitting the 'attribute' part of the name entirely if everyone's OK with overloading in this context & if the callsites tend to be pretty self documenting. (mostly if you're searching for a particular attribute you've probably got the attribute name in a literal at the callsite anyway, right?)<br class=""><br class="">So code like this, perhaps:<br class=""><br class="">  x = Die.find(DW_AT_name).asString();<br class=""><br class="">or perhaps:<br class=""><br class="">  x = asString(Die.find(DW_AT_name));<br class=""><br class="">(so that find/findAttr/[] whatever we call it can continue to return Optional<DWARFFormValue> which asString can pass along as NOne if it's passed None (or passed a non-string value), and otherwise decompose into a string, etc)<br class=""><br class=""></div></div></blockquote></div><div class=""><br class=""></div>We basically have find already in:<div class=""><span style="font-size: 11px;" class=""><br class=""></span></div><div class=""><span style="font-size: 11px;" class="">Optional<DWARFFormValue> </span>DWARFDie::<span style="font-size: 11px;" class="">getAttributeValue(dwarf::Attribute);</span></div><div class=""><br class=""></div><div class="">We can easily rename it.</div><div class=""><br class=""></div><div class=""><div class="">If find returns an optional then your first code example would need to be:</div><div class=""><br class=""></div><div class="">x = Die.<span style="font-size: 11px;" class="">find</span>(DW_AT_name).getValueOr(DWARFFormValue()).asString();</div><div class=""><br class=""></div><div class="">The second form could be made to work b<span style="font-size: 11px;" class="">ut it doesn’t look as natural IMHO. </span></div><div class=""><span style="font-size: 11px;" class=""><br class=""></span></div><div class="">Because of the first is awkward and the second seems less clear than just asking the DIE for the value I do think there is value in having the calls on DWARFDie. Let me know what you think.</div><div class=""><br class=""></div><div class="">Greg</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; min-height: 13px;" class=""><br class=""></div></div></body></html>