<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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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><snip></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=""> def initialize()<br class=""> @bar = 5<br class=""> end</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><font face="Menlo" class=""> def bar()</font><div class=""><font face="Menlo" class=""> puts “Hello"</font></div><div class=""><font face="Menlo" class=""> end</font></div><font face="Menlo" class="">end</font></div><div class=""><br class=""></div><div class="">In that case, how would one implement <font face="Menlo" class="">DynamicMemberLookupProtocol</font> for the lookup of <font face="Menlo" class="">bar</font>, 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”) // => 5</span></div></div><div><br class=""></div><div>attr :bar exposes a variable @bar through functions bar() and bar=() (and also optimizes storage in some implementations)</div><div><br class=""></div><div>-DW</div></body></html>