<div dir="ltr">Right, so the motivation of the proposal is to avoid the clutter of all that extra boilerplate / plumbing.  Same motivation as regular (function) lambdas.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 12, 2021 at 5:45 AM Scott Michaud &lt;<a href="mailto:scott@loosescrew.ca">scott@loosescrew.ca</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>Oh I just came up with a smelly hack for this.</p>
    <p>Godbolt: <a href="https://godbolt.org/z/xe5oEz" target="_blank">https://godbolt.org/z/xe5oEz</a><br>
    </p>
    <div>On 1/12/2021 12:25 AM, Andrew Tomazos
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>ie like below, see how argv is captured:</div>
        <div><br>
        </div>
        class ISomeInterface<br>
        {<br>
        public:<br>
            virtual void Function1() {}<br>
            virtual void Function2() {}<br>
        };<br>
        <br>
        void TestInterface(ISomeInterface&amp; inObject)<br>
        {<br>
            inObject.Function1();<br>
            inObject.Function2();<br>
        }<br>
        <br>
        int main(int argc, char** argv)<br>
        {<br>
            TestInterface([&amp;]: ISomeInterface {<br>
                void Function1() override<br>
                {<br>
                    std::cout &lt;&lt; &quot;One!&quot; &lt;&lt; <b>argv[0]</b>
        &lt;&lt; std::endl;<br>
                }<br>
        <br>
                virtual void Function2() override<br>
                {<br>
                    std::cout &lt;&lt; &quot;Two!&quot; &lt;&lt; <b>argv[1]</b>
        &lt;&lt; std::endl;<br>
                }<br>
        <br>
            });
        <div>}<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, Jan 12, 2021 at 5:20
          AM Andrew Tomazos &lt;<a href="mailto:andrewtomazos@gmail.com" target="_blank">andrewtomazos@gmail.com</a>&gt;
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">Right, but it doesn&#39;t have the lambda capture
            functionality.
            <div><br>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Tue, Jan 12, 2021 at
              5:18 AM Scott Michaud &lt;<a href="mailto:scott@loosescrew.ca" target="_blank">scott@loosescrew.ca</a>&gt;
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div>
                <p>Andrew,</p>
                <p>Wouldn&#39;t this be equivalent to a local, unnamed
                  class?</p>
                <p>Godbolt: <a href="https://godbolt.org/z/ezn8va" target="_blank">https://godbolt.org/z/ezn8va</a><br>
                </p>
                <p><br>
                </p>
                <div>On 1/11/2021 11:55 PM, Andrew Tomazos via
                  Std-Proposals wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">I have an idea for a language feature
                    we&#39;ll call Lambda Classes.
                    <div><br>
                    </div>
                    <div>As placeholder syntax let&#39;s say like:</div>
                    <div><br>
                    </div>
                    <div>    lambda-class:</div>
                    <div>        lambda-introducer :
                      base-specifier-list_opt { member-specification_opt
                      }</div>
                    <div><br>
                    </div>
                    <div>So for example:</div>
                    <div><br>
                    </div>
                    <div>    auto my_lambda_class = [cap1,cap2]: {</div>
                    <div>        void f() { /*...*/; }</div>
                    <div>        void g() { /*...*/; }</div>
                    <div>    };</div>
                    <div><br>
                    </div>
                    <div>A lambda class is to a normal class object as a
                      lambda function is to a normal function.</div>
                    <div><br>
                    </div>
                    <div>A lambda class is an expression that is
                      introduced with the usual capture sequence, but is
                      followed by a colon, a (possibly empty) base class
                      list, and then a class definition body.</div>
                    <div><br>
                    </div>
                    <div>It constructs a new anonymous class type in the
                      same fashion as a normal lambda, capturing any
                      variables as specified in the lambda-introducer,
                      derives the new class type from any bases in the
                      base-specifier-list, and adds any members given in
                      the member-specification, and the value of the
                      expression is the (singular) object of that new
                      class type.</div>
                    <div><br>
                    </div>
                    <div>The motivation is that there are many use cases
                      where an API asks for an object of a class type
                      that implements some interface - either
                      implementing a (virtual) polymorphic interface
                      (run-time polymorphism) in traditional OOP, or
                      that models a certain concept (compile-time
                      polymorphism) in template meta-programming - and
                      in many of both of those use case families, the
                      response is to create a single-use class is
                      created just to adapt to that API.  Like lambda
                      functions, lambda classes help remove a lot of the
                      boilerplate and indirection in such use cases.</div>
                    <div><br>
                    </div>
                    <div>Let me know if there is any enthusiasm for this
                      and I&#39;ll write up a proper draft.</div>
                    <div><br>
                    </div>
                  </div>
                  <br>
                  <fieldset></fieldset>
                </blockquote>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </div>

</blockquote></div>

