Skip to content

Commit

Permalink
Deprecate some aliases.
Browse files Browse the repository at this point in the history
- To cut back on an over-abundance of choice and to simplify documentation, the
  following built-in aliases have been made obsolete.  They can still be added
  manually via `loopy-defalias`.
  - `array`: `across`
  - `array-ref`: `arrayf`, `arrayingf`, `stringf`, `stringingf`, `across-ref`
  - `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`
  - `seq`: `elements`
  - `seq-index`: `sequencei`, `seqi`, `listi`, `arrayi`, `stringi`
- Document the aliases `mapping-ref`, `listing-ref`, `arraying-ref`,
  `stringing-ref`, and `sequencing-ref`.
  • Loading branch information
okamsn committed Sep 2, 2024
1 parent 455c14b commit bbc0dde
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 49 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ 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. They can still be added
manually via `loopy-defalias`.
- `array`: `across`
- `array-ref`: `arrayf`, `arrayingf`, `stringf`, `stringingf`, `across-ref`
- `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`
- `seq`: `elements`
- `seq-index`: `sequencei`, `seqi`, `listi`, `arrayi`, `stringi`
- `seq-ref`: `seqf`, `sequencef`, `sequencingf`, `elements-ref`


[#169]: https://github.com/okamsn/loopy/issues/169
[#203]: https://github.com/okamsn/loopy/pull/203
[#205]: https://github.com/okamsn/loopy/pull/205
Expand Down
4 changes: 4 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ please let me know.
a warning. In the future, they will signal an error.
- The positional arguments to the =numbers= command have been removed,
being deprecated since version 0.12.0.
- Some built-in aliases have been made obsolete and will be removed from the
list of built-in aliases in the future. They can still be added to the
list of known aliases using ~loopy-defalias~. See the changelog for more
information.
- Version 0.13.0:
- The deprecated =:init= keyword argument has been removed. Use the =with=
special macro argument instead.
Expand Down
41 changes: 17 additions & 24 deletions doc/loopy-doc.org
Original file line number Diff line number Diff line change
Expand Up @@ -2365,17 +2365,13 @@ they also have an =index= keyword, which names the variable used to store
the accessed index during the loop.

#+findex: array-ref
#+findex: arrayf
#+findex: string-ref
#+findex: stringf
#+findex: arraying-ref
#+findex: arrayingf
#+findex: stringing-ref
#+findex: stringingf
#+findex: across-ref
- =(array-ref|arrayf|string-ref|stringf VAR EXPR &key KEYS)= :: Loop
through the elements of the array =EXPR=, binding =VAR= as a ~setf~-able
place.
- =(array-ref|string-ref VAR EXPR &key KEYS)= :: Loop through the elements of
the array =EXPR=, binding =VAR= as a ~setf~-able place.

This command also has the aliases =arraying-ref= and =stringing-ref=.

=KEYS= is one or several of =from=, =upfrom=, =downfrom=, =to=, =upto=,
=downto=, =above=, =below=, =by=, and =index=. =index= names the variable
Expand Down Expand Up @@ -2404,12 +2400,11 @@ the accessed index during the loop.

#+findex: list-ref
#+findex: listing-ref
#+findex: listf
#+findex: listingf
#+findex: in-ref
- =(list-ref|listf VAR EXPR &key by)= :: Loop through the elements of
the list =EXPR=, binding =VAR= as a ~setf~-able place. Optionally, update
the list via function =by= instead of ~cdr~.
- =(list-ref VAR EXPR &key by)= :: Loop through the elements of the list =EXPR=,
binding =VAR= as a ~setf~-able place. Optionally, update the list via
function =by= instead of ~cdr~.

This command also has the aliases =listing-ref=.

#+BEGIN_SRC emacs-lisp
;; => (7 7 7)
Expand Down Expand Up @@ -2439,11 +2434,11 @@ the accessed index during the loop.

#+findex: map-ref
#+findex: mapping-ref
#+findex: mapf
#+findex: mappingf
- =(map-ref|mapf VAR EXPR &key key unique)= :: Loop through the values of
map =EXPR=, binding =VAR= as a ~setf~-able place. Like the command =map=,
this command uses the =map.el= library.
- =(map-ref VAR EXPR &key key unique)= :: Loop through the values of map =EXPR=,
binding =VAR= as a ~setf~-able place. Like the command =map=, this command
uses the =map.el= library.

This command also has the aliases =mapping-ref=.

=key= is a variable in which to store the current key for the ~setf~-able
place referred to by =VAR=. This is similar to the =index= keyword parameter
Expand Down Expand Up @@ -2492,16 +2487,14 @@ the accessed index during the loop.
#+end_src

#+findex: seq-ref
#+findex: seqf
#+findex: sequence-ref
#+findex: sequencing-ref
#+findex: sequencef
#+findex: sequencingf
#+findex: elements-ref
- =(sequence-ref|sequencef|seq-ref|seqf VAR EXPR &key KEYS)= :: Loop
- =(sequence-ref|seq-ref VAR EXPR &key KEYS)= :: Loop
through the elements of the sequence =EXPR=, binding =VAR= as a
~setf~-able place.

This command also has the aliases =sequencing-ref=.

=KEYS= is one or several of =from=, =upfrom=, =downfrom=, =to=, =upto=,
=downto=, =above=, =below=, =by=, =test=, and =index=. =index= names the
variable used to store the index being accessed. For others, see the
Expand Down
65 changes: 40 additions & 25 deletions loopy-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,39 @@ Definition must exist. Neither argument need be quoted."
;; Add the alias for the new target name.
(push alias (map-elt loopy-aliases true-name)))))))

(defvar loopy--obsolete-aliases
'((array across)
(array-ref arrayf arrayingf stringf stringingf across-ref)
(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)
(seq elements)
(seq-index sequencei seqi listi arrayi stringi)
(seq-ref seqf sequencef sequencingf elements-ref))
"Aliases to be removed from the documentation.")

;;;###autoload
(defcustom loopy-aliases
;; TODO: Is there a faster way to search for aliases?
;; Would using a hash table with a flatter structure be better?
;; Using `map-do' on a hash table seemed to be a bit slower for what
;; we want?
'((accumulate . (callf2 accumulating))
'((accumulate . (accumulating callf2))
(adjoin . (adjoining))
(after-do . (else after else-do))
(append . (appending))
(array . (arraying string stringing across))
(array-ref . ( arraying-ref arrayf arrayingf
stringf stringingf
string-ref stringing-ref
across-ref))
(array . (arraying string stringing))
(array-ref . (arraying-ref string-ref stringing-ref))
(at . (atting))
(before-do . (initially-do initially before))
(collect . (collecting))
(concat . (concating))
(cons . (conses consing on))
(cons . (conses consing))
(count . (counting))
(cycle . (cycling repeat repeating))
(finally-do . (finally))
Expand All @@ -103,22 +116,20 @@ Definition must exist. Neither argument need be quoted."
(iter . (iterating))
(leave . (leaving))
(leave-from . (leaving-from))
(list . (listing each in))
(list-ref . (listf listingf listing-ref in-ref))
(list . (listing each))
(list-ref . (listing-ref))
(map . (mapping map-pairs mapping-pairs))
(map-ref . (mapf mappingf mapping-ref))
(map-ref . (mapping-ref))
(max . (maximizing maximize maxing))
;; Unlike "maxing", there doesn't seem to be much on-line about the word
;; "minning", but the double-N follows conventional spelling rules, such as
;; in "sum" and "summing".
(min . (minimizing minimize minning))
(multiply . (multiplying))
(nconc . (nconcing))
(numbers . (num nums number numbering))
(numbers-down . ( nums-down numdown number-down num-down numsdown
numbering-down))
(numbers-up . ( nums-up numup number-up num-up numsup
numbering-up))
(numbers . (number numbering))
(numbers-down . (number-down numbering-down))
(numbers-up . (number-up numbering-up))
(nunion . (nunioning))
(opt-accum . (accum-opt))
(prepend . (prepending))
Expand All @@ -128,16 +139,14 @@ Definition must exist. Neither argument need be quoted."
(return-from . (returning-from))
(set . (setting exprs expr))
(set-accum . (setting-accum))
(set-prev . (setting-prev prev prev-expr prev-set))
(seq . (seqing sequence sequencing elements))
(seq-index . ( sequence-index seqing-index sequencing-index
sequencing-index sequencei seqi list-index listing-index
listi array-index arraying-index arrayi
string-index stringing-index stringi))
(seq-ref . ( seqf seqing-ref
sequencef sequencingf sequence-ref
sequencing-ref
elements-ref))
(set-prev . (setting-prev prev-expr prev-set))
(seq . (seqing sequence sequencing))
(seq-index . ( seqing-index
sequence-index sequencing-index
list-index listing-index
array-index arraying-index
string-index stringing-index))
(seq-ref . (seqing-ref sequence-ref sequencing-ref))
(skip . (skipping continue continuing))
(skip-from . (skipping-from continue-from continuing-from))
(stream . (streaming))
Expand Down Expand Up @@ -781,6 +790,12 @@ This predicate checks for presence in the list
(when (memq name v)
(cl-return-from loopy--get-true-name k)))
loopy-aliases)
(map-do (lambda (k v)
(when (memq name v)
(warn "`loopy': `%s' is an obsolete built-in alias of `%s'. It will be removed in the future. To add it as a custom alias, use `loopy-defalias'."
name k)
(cl-return-from loopy--get-true-name k)))
loopy--obsolete-aliases)
nil)
name))

Expand Down

0 comments on commit bbc0dde

Please sign in to comment.