<div dir="ltr">There hasn&#39;t been a major Lens thread on the list so far, but I&#39;m intrigued by the idea and was tinkering with a related proposal until I stumbled across Brandon William&#39;s &quot;Lenses in Swift&quot; video and discovered that Lenses cover everything I wanted to do and more.<br><br>The one thing that stuck with me, though, is the question of syntax. If Lenses are to be a native part of the Swift language, how would one declare them?<br><br>We&#39;ve currently got not-so-secret methods at the type level of Structs and Classes for every member function:<br><br>class Example {<div>    func action() {}</div><div>}</div><div><br></div><div>let example = Example()</div><div>example.action // () -&gt; Void</div><div>Example.action // (Example) -&gt; Void<br><br>That looks a lot like a Lens on the member function, though if I understand correctly the current plan is for those to go away in a future version.<br><br>We also have to deal with Type-level members and functions:<br><br>class Example {</div><div>   static action() {}</div><div>   static name: String</div><div>}</div><div><br></div><div>Example.action() // () -&gt; Void<br>Example.name // String<br><br>So, using a dot-operator as the way to get a Lens could be problematic due to name collisions.<br><br>The Proposal:<br><br>Use the &#39;#&#39; character in place of the dot operator to retrieve a Lens for a Type/member pair:<br><br>Example#action() // (Example) -&gt; Void<br>Example#name    // Lens&lt;Example,String&gt;, autogenerated to work on the &#39;name&#39; member</div><div><br>Member function names should be fully-specified with the mechanism from Doug Gregor&#39;s method naming proposal.<br><br>Some notes:<br>* A specific operator stands out and is easier to scan for as a code reader.</div><div>* The octothorpe seems to be available in Swift.<br></div><div>* It also has a current meaning in a technology familiar to most everyone - the Document Fragment in HTML - which could make the idea easier to explain to newcomers, by analogy.<br><br>What about Lenses on Type-level members? My first thought is that we don&#39;t have to support that because they&#39;re more like namespaced globals rather than parts of a data type. They can always be referenced directly. That might be a vacuous observation to people more familiar with the Lens concept, but I noted it for completeness.<br><br>Mike</div></div>