Comments on Refutable Patterns proposal

Axel Rauschmayer axel at rauschma.de
Wed Mar 20 16:04:25 PDT 2013


http://wiki.ecmascript.org/doku.php?id=harmony:refutable_matching

- Would love to see examples for arrays. Especially if there are more element patterns (lhs) than array elements (rhs).

- Possible future extensions: Make pattern after "..." optional, allow "..." in the middle of an array. Examples:
    let [...front, last] = someArray;
    let [..., last] = someArray;
    let [first, ...] = someArray;

- Missing parameter in third-last line?
Match(ElementPatterns, value, index, soft) =
   assert IsObject(value)
   case ElementPatterns of
      ElementPattern =>
         Match(ElementPattern, value, index, soft)
      ElementPattern "," ElementPatterns =>
         if Match(ElementPattern, value, index, soft) = SUCCESS then
            Match(ElementPatterns, value, soft)   (* Missing? index+1 *)
         else
            FAILURE

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130321/638822e3/attachment.html>


More information about the es-discuss mailing list