Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/acid.unary-plus-list-fix/readme

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Unary + appends zero to lists.

Example:

  acid: +{}
  {0x00000000}

  acid: +{1}
  {0x00000001, 0x00000000}

  acid: defn x() { return {1} ; }
  acid: +x()
  {0x00000001, 0x00000000}

Cause:

  The parser converts '+x' to 'x+0'.  Such is reasonable for
  numeric arguments and has no effect on strings.  Unfortunately
  for lists, it results in a zero being appended.

This patch:

  The parser converts '+x' to 'x+ZN' and oadd() handles the ZN
  rhs when the expression is evaluated.

Patched:

  acid: +{}

  acid: +{1}
  {0x00000001}

  acid: defn x() { return {1} ; }
  acid: +x()
  {0x00000001}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].