# HG changeset patch # User Steve Losh # Date 1639527153 18000 # Node ID c2970d9e6ea7ac201406df957989e0b928c65f67 # Parent 95393d6a522606340d21dc5f6e98b54fa7fb98a6# Parent 656f2f6975bcaecdcdd0efba6ee8fbec8fe96738 Merge diff -r 656f2f6975bc -r c2970d9e6ea7 DOCUMENTATION.markdown --- a/DOCUMENTATION.markdown Tue Dec 14 19:10:21 2021 -0500 +++ b/DOCUMENTATION.markdown Tue Dec 14 19:12:33 2021 -0500 @@ -1580,6 +1580,16 @@ Sugar for `(if-first-time expr nil)`. +### `WITH-RESULT` (macro) + + (WITH-RESULT SYMBOL = EXPR) + +Bind `expr` to symbol using `with`, and return it at the end. + + Equivalent to `(progn (with symbol = expr) (returning expr))`. + + + ## Package `LOSH.LISTS` Utilities for operating on lists. @@ -2594,7 +2604,7 @@ ### `PBCOPY` (function) - (PBCOPY OBJECT) + (PBCOPY &OPTIONAL (OBJECT *)) `pbcopy` the `aesthetic-string` of `object`. diff -r 656f2f6975bc -r c2970d9e6ea7 src/iterate.lisp --- a/src/iterate.lisp Tue Dec 14 19:10:21 2021 -0500 +++ b/src/iterate.lisp Tue Dec 14 19:12:33 2021 -0500 @@ -983,6 +983,16 @@ " `(finally (return (values ,@values)))) +(defmacro with-result (symbol = expr) + "Bind `expr` to symbol using `with`, and return it at the end. + + Equivalent to `(progn (with symbol = expr) (returning expr))`. + + " + (assert (eql = '=)) + `(progn (with ,symbol = ,expr) + (returning ,symbol))) + (defmacro-driver (FOR var-or-vars MATCHING regex AGAINST string &optional OVERLAP overlap? START start END end) "Iterate over the matches of `regex` in `string`, binding `var-or-vars`. diff -r 656f2f6975bc -r c2970d9e6ea7 src/package.lisp --- a/src/package.lisp Tue Dec 14 19:10:21 2021 -0500 +++ b/src/package.lisp Tue Dec 14 19:12:33 2021 -0500 @@ -348,6 +348,7 @@ :when-first-iteration :when-first-time :window + :with-result :within-radius ))