<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 20, 2017, at 1:16 AM, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div></div></div></blockquote>&lt;snip&gt;</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Moreover, Ruby allows classes to have instance variables with the same name as methods:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">class Foo</font><div class=""><font face="Menlo" class="">&nbsp; def&nbsp;initialize()<br class="">&nbsp; &nbsp;&nbsp;@bar&nbsp;=&nbsp;5<br class="">&nbsp;&nbsp;end</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><font face="Menlo" class="">&nbsp; def bar()</font><div class=""><font face="Menlo" class="">&nbsp; &nbsp; puts “Hello"</font></div><div class=""><font face="Menlo" class="">&nbsp; end</font></div><font face="Menlo" class="">end</font></div><div class=""><br class=""></div><div class="">In that case, how would one implement&nbsp;<font face="Menlo" class="">DynamicMemberLookupProtocol</font> for the lookup of <font face="Menlo" class="">bar</font>,&nbsp;and what would the return value be? Its entirely context sensitive.</div></div></div></blockquote><div><br class=""></div>I do not believe Ruby does not give you direct external access to variables. Everything with a ‘.’ is a function call.</div><div><br class=""></div><div>You would use e.g.</div><div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Foo.new.instance_variable_get("@bar”) // =&gt; 5</span></div></div><div><br class=""></div><div>attr :bar exposes a variable @bar through functions bar() and bar=() &nbsp; (and also optimizes storage in some implementations)</div><div><br class=""></div><div>-DW</div></body></html>