<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    (Just realised I forgot to reply all! Whoops!)<br>
    <br>
    Can't we just use destructuring defaults for this, given it seems
    that both V8 and SpiderMonkey lazily invoke functions in this
    context? I haven't corroborated this with the spec though, so I
    could be wrong.<br>
    <br>
    <span class="icon" title="Log"></span><font face="Courier New"><span
        class="message-body-wrapper"><span class="message-flex-body"><span
            class="message-body devtools-monospace"><span
              class="cm-keyword">const log = name => fn =>
              (...args) => console.log('Calling', name) ||
              fn(...args);<br>
              const getFirst = log('getFirst')(() => 'manual
              first!');<br>
              const getSomeObject = () => ({ second: 'second' });<br>
              const getFullObject = () => ({ first: 'real first!',
              second: 'second' });<br>
            </span></span></span></span></font><br>
    <font face="Courier New"><span class="message-body-wrapper"><span
          class="message-flex-body"><span class="message-body
            devtools-monospace"><span class="cm-keyword"><span
                class="message-body-wrapper"><span
                  class="message-flex-body"><span class="message-body
                    devtools-monospace">(() => {<br>
                      // first is already defined, thus getFirst() isn't
                    called<br>
                      let { first = getFirst(), second } =
                    getFullObject();<br>
                    })();<br>
                  </span></span></span></span></span></span></span></font><br>
    <font face="Courier New"><span class="message-body-wrapper"><span
          class="message-flex-body"><span class="message-body
            devtools-monospace"><span class="cm-keyword"><span
                class="message-body-wrapper"><span
                  class="message-flex-body"><span class="message-body
                    devtools-monospace"><font face="Courier New"><span
                        class="message-body-wrapper"><span
                          class="message-flex-body"><span
                            class="message-body devtools-monospace"><span
                              class="cm-keyword"><span
                                class="message-body-wrapper"><span
                                  class="message-flex-body"><span
                                    class="message-body
                                    devtools-monospace">(() => {<br>
                                      // logs 'Calling getFirst'...<br>
                                      let { first = getFirst(), second }
                                    = getSomeObject();<br>
                                    })();<br>
                                    <br>
                                  </span></span></span></span></span></span></span></font></span></span></span></span></span></span></span></font><span
      class="message-body-wrapper"><span class="message-flex-body"><span
          class="message-body devtools-monospace"><span
            class="cm-keyword"><span class="message-body-wrapper"><span
                class="message-flex-body"><span class="message-body
                  devtools-monospace"><span class="message-body-wrapper"><span
                      class="message-flex-body"><span
                        class="message-body devtools-monospace"><span
                          class="cm-keyword"><span
                            class="message-body-wrapper"><span
                              class="message-flex-body"><span
                                class="message-body devtools-monospace">We
                                can prove this with a simpler example:</span></span></span></span></span></span></span></span></span></span></span></span></span></span><font
      face="Courier New"><span class="message-body-wrapper"><span
          class="message-flex-body"><span class="message-body
            devtools-monospace"><span class="cm-keyword"><span
                class="message-body-wrapper"><span
                  class="message-flex-body"><span class="message-body
                    devtools-monospace"><font face="Courier New"><span
                        class="message-body-wrapper"><span
                          class="message-flex-body"><span
                            class="message-body devtools-monospace"><span
                              class="cm-keyword"><span
                                class="message-body-wrapper"><span
                                  class="message-flex-body"><span
                                    class="message-body
                                    devtools-monospace"><br>
                                    <br>
                                  </span></span></span></span></span></span></span></font></span></span></span></span></span></span></span></font><span
      class="message-body-wrapper"><span class="message-flex-body"><span
          class="message-body devtools-monospace"><span class="objectBox
            objectBox-undefined"><font face="Courier New">const getThing
              = () => {<br>
                console.log('called');<br>
                return 1;<br>
              };<br>
              <br>
              (() => {<br>
                let { x = getThing() } = { x: 1 };<br>
              })();<br>
              // Logs nothing<br>
              // <= undefined<br>
              <br>
              (() => {<br>
                let { x = getThing() } = {};<br>
              })();<br>
              // Logs 'called'<br>
              // <= undefined<br>
              <br>
            </font></span></span></span></span><br>
    <span class="message-body-wrapper"><span class="message-flex-body"><span
          class="message-body devtools-monospace"><span class="objectBox
            objectBox-undefined">I appreciate that one could pipe <font
              face="Courier New"><i><font face="Times New Roman, Times,
                  serif">n</font></i></font> functions with your
            proposal, but personally I'm not sure this necessitates new
            syntax.<br>
            <br>
          </span></span></span></span>
    <div class="moz-cite-prefix">On 18/11/2019 15:44, Artem Kobzar
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAKUhy4vUPcc3m-tz_uvhAVcTkPs1psfr7kOjp2c54RtOC-msBA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">When we need to me destruction from array or object
        and change value then we need make something like this<br>
        <br>
        ```js<br>
        let { first, second } = getSomeObject();<br>
        first = computeFirst(first);<br>
        <br>
        // Or create temporary useless variable<br>
        <br>
        const obj = getSomeObject();<br>
        const second = obj.second;<br>
        const first = computeFirst(obj.first);<br>
        ```<br>
        <br>
        I propose to make operator which will give ability to us to
        apply some function to property inside destruction-syntax
        without mutable or temporary variables<br>
        <br>
        ```js<br>
        const { first | computeFirst, second } = getSomeObject();<br>
        ```<br>
        <br>
        <div>I think that syntax should be discussed, but it seems lie
          pipe-symbol is well-known operator in bash and in
          AngularJS/Vue community.</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
es-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a>
<a class="moz-txt-link-freetext" href="https://mail.mozilla.org/listinfo/es-discuss">https://mail.mozilla.org/listinfo/es-discuss</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>