Skip to content

Commit

Permalink
Obsolete more built-in aliases. (#207)
Browse files Browse the repository at this point in the history
- Make `command-do` the default name and `group` the obsolete alias.
  - Rename `loopy--parse-group-command` to `loopy--parse-command-do-command`.

- Obsolete `expr` and `exprs` for `set`.

- Obsolete `prev-expr` for `set-prev`.  Remove mention of the alias
  `prev` from the Org documentation, which should have been done in the
  previous round of obsoletions.

- Update Texinfo file.

See this PR #207 and issue #168, as well as previous obsoletions in
PR #206 and issue #126.
  • Loading branch information
okamsn authored Sep 6, 2024
1 parent 38126cc commit 264a382
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 122 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ This document describes the user-facing changes to Loopy.
- Remove the deprecated positional arguments to the `numbers` command ([#205]).

- To cut back on an over-abundance of choice and to simplify documentation, the
following built-in aliases have been made obsolete ([#126], [#206]). They can
still be added manually via `loopy-defalias`.
following built-in aliases have been made obsolete ([#126], [#168], [#206],
[#207]). They can still be added manually via `loopy-defalias`.
- `array`: `across`
- `array-ref`: `arrayf`, `arrayingf`, `stringf`, `stringingf`, `across-ref`
- `command-do`: `group`
- `cons`: `on`
- `list`: `in`
- `list-ref`: `listf`, `listingf`, `in-ref`
- `map-ref`: `mapf`, `mappingf`
- `numbers`: `num`, `nums`
- `numbers-down`: `nums-down`, `numdown`, `num-down`, `numsdown`
- `numbers-up`: `nums-up`, `numup`, `num-up`, `numsup`
- `set-prev`: `prev`
- `set`: `expr`, `exprs`
- `set-prev`: `prev`, `prev-expr`
- `sequence`: `elements`
- `sequence-index`: `sequencei`, `seqi`, `listi`, `arrayi`, `stringi`
- `sequence-ref`: `seqf`, `sequencef`, `sequencingf`, `elements-ref`
Expand All @@ -42,10 +44,12 @@ This document describes the user-facing changes to Loopy.


[#126]: https://github.com/okamsn/loopy/issues/126
[#168]: https://github.com/okamsn/loopy/issues/168
[#169]: https://github.com/okamsn/loopy/issues/169
[#203]: https://github.com/okamsn/loopy/pull/203
[#205]: https://github.com/okamsn/loopy/pull/205
[#206]: https://github.com/okamsn/loopy/pull/206
[#207]: https://github.com/okamsn/loopy/pull/207


## 0.13.0
Expand Down
42 changes: 15 additions & 27 deletions doc/loopy-doc.org
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,10 @@ is assigned a value from the list after collecting =i= into =coll=.
#+END_SRC

For convenience and understanding, the same command might have multiple names,
called {{{dfn(aliases)}}}. For example, the command =set= has an alias =expr=,
because =set= is used to /set/ a variable to the value of an /expression/.
Similary, the =array= command has the alias =string=, because the =array=
command can be used to iterate through the elements of an array or string[fn:1].
You can define custom aliases using the macro ~loopy-defalias~ ([[#custom-aliases][Custom Aliases]]).
called {{{dfn(aliases)}}}. Similary, the =array= command has the alias
=string=, because the =array= command can be used to iterate through the
elements of an array or string[fn:1]. You can define custom aliases using the
macro ~loopy-defalias~ ([[#custom-aliases][Custom Aliases]]).

Similar to other libraries, many commands have an alias of the
present-participle form (the "-ing" form). A few examples are seen in the table
Expand All @@ -682,7 +681,7 @@ command iterates through the elements in the list.
For simplicity, the commands are described using the following notation:

- If a command has multiple names, the names are separated by a vertical bar,
such as in =set|expr=.
such as in =array|string=.
- =VAR= is an unquoted symbol that will be used as a variable name, such as =i=
in =(list i my-list)=.
- =FUNC= is a quoted Lisp function name, such as ~#'my-func~ or ~'my-func~, a
Expand Down Expand Up @@ -1303,9 +1302,8 @@ value and do no affect how the loop iterates.
(do (message "%d" i)))
#+END_SRC

#+findex: group
#+findex: command-do
- =(group|command-do [CMDS])= :: Evaluate multiple loop commands, as if in a
- =(command-do [CMDS])= :: Evaluate multiple loop commands, as if in a
=progn=. This is similar to =do=, but runs commands instead of normal Lisp
expressions. Currently, this command is only useful when used within the
=if= command.
Expand All @@ -1314,15 +1312,6 @@ value and do no affect how the loop iterates.
;; Report whether an even number is found, or return the sum of
;; the list's elements. To be clear, this is not an idiomatic example.

;; Returns sum:
;; => 9
(loopy (list i '(1 3 5))
(if (cl-evenp i)
(group
(do (message "Even found."))
(return i))
(sum i)))

;; Returns the detected even number:
;; => 2
(loopy (list i '(1 3 2 5))
Expand All @@ -1337,11 +1326,11 @@ value and do no affect how the loop iterates.
#+findex: setting
#+findex: expr
#+findex: exprs
- =(set|expr VAR [EXPRS])= :: Bind =VAR= to each =EXPR= in order. Once the last
- =(set VAR [EXPRS])= :: Bind =VAR= to each =EXPR= in order. Once the last
=EXPR= is reached, it is used repeatedly for the rest of the loop. With no
=EXPR=, =VAR= is bound to ~nil~ during each iteration of the loop.

This command also has the aliases =setting= and =exprs=.
This command also has the aliases =setting=.

Unlike the Emacs Lisp function ~set~, the variable name should not be quoted.
Unlike the Emacs Lisp special form ~setq~, the command =set= only sets one
Expand All @@ -1366,17 +1355,16 @@ value and do no affect how the loop iterates.
#+findex: set-prev
#+findex: setting-prev
#+findex: prev-set
#+findex: prev-expr
#+findex: prev
- =(set-prev|prev-expr VAR VAL &key back)= :: Bind =VAR= to a value =VAL= from a
previous cycle in the loop. With =BACK= (default: 1), use the value from that
many cycles previous. _If not enough cycles have passed yet, then the value
of =VAR= is not modified._ This command /does not/ work like a queue for
- =(set-prev VAR VAL &key back)= :: Bind =VAR= to a value =VAL= from a previous
cycle in the loop. With =BACK= (default: 1), use the value from that many
cycles previous. _If not enough cycles have passed yet, then the value of
=VAR= is not modified._ This command /does not/ work like a queue for
recording =VAL=; it always uses the value from the =BACK=-th previous cycle,
regardless of when the command is run. The value used is always the value at
the end of the cycle.

This command also has the aliases =setting-prev=, =prev-set=, and =prev=.
This command also has the aliases =setting-prev= and, for typo tolerance,
=prev-set=.

#+begin_src emacs-lisp
;; => (nil 1 2 3 4)
Expand Down Expand Up @@ -4411,7 +4399,7 @@ options ~loopy-iter-bare-commands~ and
~loopy-iter-bare-special-macro-arguments~.

By default, the following commands are not recognized:
- =do= and =group=, which are not needed.
- =do= and =command-do=, which are not needed.

- Commands that exists only as a command version of an existing Lisp feature,
such as =if=, =cond=, =when=, and =unless=.
Expand Down
Loading

0 comments on commit 264a382

Please sign in to comment.