Skip to content

Commit

Permalink
Remove some deprecated features. (#165)
Browse files Browse the repository at this point in the history
- Remove flag `split`.  See PRs #165, #131.  See issue #124.
- Remove flag `lax-naming`.  See PRs #165, #119.
- Remove command `sub-loop`.  See PRs #165, #130.  See issue #127.
- Remove obsolete alias `loopy-iter-command-keywords` for variable
  `loopy-iter-keywords`.  See PRs #165, #119.
  • Loading branch information
okamsn authored Sep 3, 2023
1 parent 420ed83 commit a337730
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 378 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ This document describes the user-facing changes to Loopy.
(list i '(4 5 6)))
```

#### Removals

- The deprecated flag `split` was removed ([#165], [#131], [#124]). Instead,
use named accumulation variables with the special macro argument `accum-opt`
as appropriate.

- The deprecated flag `lax-naming` was removed ([#165], [#119]). Instead, see
`loopy-iter-bare-commands` and `loopy-iter-bare-special-macro-arguments`.

- The deprecated command `sub-loop` was removed ([#165], [#130], [#127]). Use
the commands/macros `loopy` and `loopy-iter` instead. In `loopy`, `sub-loop`
acted like `loopy`. In `loopy-iter`, `sub-loop` acted like `loopy-iter`.

- The obsolete variable alias `loopy-iter-command-keywords` for the variable
`loopy-iter-keywords` was removed ([#165], [#119]).


#### Deprecations

- Using multiple conditions in `always`, `never`, and `thereis` is deprecated.
These commands will be changed to have call argument lists more like
accumulation commands, such as `(always [VAR] VAL &key into)`. This will
Expand Down Expand Up @@ -106,7 +125,7 @@ This document describes the user-facing changes to Loopy.
`set` command, which are allowed to occur in more than one command.

[#164]: https://github.com/okamsn/loopy/pull/164

[#165]: https://github.com/okamsn/loopy/pull/165

## 0.11.2

Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: tests

tests:
emacs -Q -batch -l ert -l tests/load-path.el -l tests/tests.el -f ert-run-tests-batch-and-exit

.PHONY: iter-tests

iter-tests:
emacs -Q -batch -l ert -l tests/load-path.el -l tests/iter-tests.el -f ert-run-tests-batch-and-exit
2 changes: 2 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ please let me know.
- =reduce= has been fixed. It now works like ~cl-reduce~ when the variable
starting value isn't explicitly given, storing the first value instead of
storing the result of passing the first value and ~nil~ to the function.
- The deprecated flags =lax-naming= and =split= were removed.
- The deprecated command =sub-loop= was removed.
- Versions 0.11.1 and 0.11.2: None. Bug fixes.
- Version 0.11.0:
- More incorrect destructured bindings now correctly signal an error.
Expand Down
2 changes: 1 addition & 1 deletion doc/loopy-doc.org
Original file line number Diff line number Diff line change
Expand Up @@ -4335,7 +4335,7 @@ accumulation itself must still occur within the loop =inner=.
;; => (1 2 3 4)
(loopy (named outer)
(array i [(1 2) (3 4)])
(sub-loop inner
(loopy inner
(list j i)
(at outer (collect coll j)))
(finally-return coll))
Expand Down
23 changes: 1 addition & 22 deletions loopy-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,6 @@ These commands affect other loops higher up in the call list."
(,target-loop
,@(loopy--parse-loop-commands commands))))))

;;;;;; Sub-Loop
(make-obsolete 'loopy--parse-sub-loop-command
(concat "use the `loopy' or `loopy-iter' commands instead."
" See the manual and change log.")
"2022-08")
(cl-defun loopy--parse-sub-loop-command ((_ &rest body))
"Parse the `sub-loop' command as (sub-loop BODY).
The sub-loop is a full call to the `loopy' macro, supporting
special macro arguments. In `loopy-iter', it is specially
handled to use `loopy-iter' instead.
The sub-loop is specially handled."
(warn (concat "The command `sub-loop' is deprecated."
" Use the commands `loopy' or `loopy-iter' instead."
" See the Info documentation and change log."))
`((loopy--main-body ,(macroexpand `(loopy ,@body)))))

;;;;;; Loopy
(cl-defun loopy--parse-loopy-command ((_ &rest body))
"Parse the `loopy' command as (loopy BODY).
Expand Down Expand Up @@ -1767,10 +1749,7 @@ accumulation variable. The default accumulation variable is
(signal 'loopy-wrong-number-of-command-arguments-or-bad-keywords
(list cmd)))
(let* ((into-var (plist-get opts :into))
(var (or into-var
(and loopy--split-implied-accumulation-results
(gensym (symbol-name name)))
'loopy-result))
(var (or into-var 'loopy-result))
(val (cl-first args)))
(ignore var val)

Expand Down
102 changes: 2 additions & 100 deletions loopy-iter.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,70 +48,12 @@
;; Iterate, but now it just defers to what Emacs already does when expanding
;; macros, such as in `macroexpand-all'.

;;;; Flags (obsolete)
(make-obsolete-variable
'loopy-iter--lax-naming
"Use `loopy-iter-bare-special-macro-arguments' or
`loopy-iter-bare-commands' instead. See the manual."
"2022-07")
(defvar loopy-iter--lax-naming nil
"Whether loop commands must be preceded by keywords to be recognized.
By default, `loopy-iter' requires loop commands to be preceded by
the keywords `for', `accum', or `exit', in order to distinguish
loop commands from other Emacs features.
The flag `lax-naming' disables this requirement, at the cost of
name collisions becoming more likely.")

(make-obsolete 'loopy-iter--enable-flag-lax-naming nil "2022-07")
(defun loopy-iter--enable-flag-lax-naming ()
"Set `loopy-iter--lax-naming' to t inside the loop."
(setq loopy-iter--lax-naming t))

(make-obsolete 'loopy-iter--disable-flag-lax-naming nil "2022-07")
(defun loopy-iter--disable-flag-lax-naming ()
"Set `loopy-iter--lax-naming' to nil inside the loop if active."
;; Currently redundant, but leaves room for possibilities.
(if loopy-iter--lax-naming
(setq loopy-iter--lax-naming nil)))

(let ((f #'(lambda ()
(warn (concat "loopy-iter: Flag `lax-naming' is now obsolete. "
"See manual or changelog.")))))

(dolist (flag '(lax-naming +lax-naming lax-names +lax-names))
(setf loopy--flag-settings
(map-insert loopy--flag-settings flag f)))

(dolist (flag '(-lax-naming -lax-names))
(setf loopy--flag-settings
(map-insert loopy--flag-settings flag f))))

;;;; Custom User Options
(defgroup loopy-iter nil
"Options specifically for the `loopy-iter' macro."
:group 'loopy
:prefix "loopy-iter-")

(make-obsolete-variable
'loopy-iter-ignored-names
"Use `loopy-iter-bare-special-macro-arguments' or
`loopy-iter-bare-commands' instead. See the manual."
"2022-07")
(defcustom loopy-iter-ignored-names '(let*)
"Names of commands, special macro arguments, and their aliases to be ignored.
Some aliases and command names can cause conflicts, such as `let*' as
an alias of the special macro argument `with'.
This option always applies to special macro arguments. This
option is used with commands when the `lax-naming' flag is
enabled."
:type '(repeat symbol))

(define-obsolete-variable-alias 'loopy-iter-command-keywords
'loopy-iter-keywords "2022-07")
(defcustom loopy-iter-keywords '(accum for exit arg)
"Keywords that `loopy-iter' can use to recognize loop commands.
Expand All @@ -129,33 +71,6 @@ Without these keywords, one must use one of the names given in
`loopy-iter-bare-special-macro-arguments'."
:type '(repeat symbol))



;;;; Miscellaneous Helper Functions
;; (defun loopy-iter--valid-loop-command (name)
;; "Check if NAME is a known command.
;;
;; This checks for NAME as a key in `loopy-aliases'
;; and `loopy-command-parsers', in that order."
;; (if (and loopy-iter--lax-naming
;; (memq name loopy-iter-ignored-names))
;; nil
;; (map-elt loopy-command-parsers (loopy--get-true-name name))))
;;
;; (defun loopy-iter--literal-form-p (form)
;; "Whether FORM is a literal form that should not be interpreted."
;; (or (and (consp form)
;; (memq (cl-first form) loopy-iter--literal-forms))
;; (arrayp form)))
;;
;; (defun loopy-iter--sub-loop-command-p (name)
;; "Whether command named NAME is a sub-loop."
;; (memq name (loopy--get-all-names 'sub-loop
;; :from-true t
;; :ignored loopy-iter-ignored-names)))



(def-edebug-spec loopy-iter--special-macro-arg-edebug-spec
;; This is the same as for `loopy', but without `let*'.
[&or ([&or "with" "init"] &rest (symbolp &optional form))
Expand Down Expand Up @@ -201,9 +116,6 @@ Without these keywords, one must use one of the names given in
listing
listing-index
listing-ref
;; TODO: Remove once we move to a new version number.
;; The `sub-loop' command has been deprecated.
looping
mapping
mapping-pairs
mapping-ref
Expand Down Expand Up @@ -239,18 +151,13 @@ Without these keywords, one must use one of the names given in
stringing
stringing-index
stringing-ref
;; TODO: Remove once we move to a new version number.
;; The `sub-loop' command has been deprecated.
sub-looping
thereis
summing
unioning
vconcating)
"Commands recognized in `loopy-iter' without a preceding keyword.
For special marco arguments, see `loopy-iter-bare-special-macro-arguments'.
This option replaces the flag `lax-naming', and is always in effect."
For special marco arguments, see `loopy-iter-bare-special-macro-arguments'."
:type '(repeat symbol)
:group 'loopy-iter)

Expand Down Expand Up @@ -332,8 +239,7 @@ in the expression with `loopy--optimized-accum-2'."
;;;;; Overwritten definitions

(defcustom loopy-iter-overwritten-command-parsers
'((at . loopy-iter--parse-at-command)
(sub-loop . loopy-iter--parse-sub-loop-command))
'((at . loopy-iter--parse-at-command))
"Overwritten command parsers.
This is an alist of dotted pairs of base names and parsers, as in
Expand Down Expand Up @@ -371,10 +277,6 @@ These commands affect other loops higher up in the call list."
nreverse
(apply #'append))))))))

(cl-defun loopy-iter--parse-sub-loop-command ((_ &rest body))
"Parse the `sub-loop' command in `loopy-iter'."
`((loopy--main-body ,(macroexpand `(loopy-iter ,@body)))))

;;;; For parsing special macro arguments

(defcustom loopy-iter-bare-special-macro-arguments
Expand Down
12 changes: 1 addition & 11 deletions loopy-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ Definition must exist. Neither argument need be quoted."
elements-ref))
(skip . (skipping continue continuing))
(skip-from . (skipping-from continue-from continuing-from))
(sub-loop . (sub-looping subloop sublooping loop looping))
(sum . (summing))
(union . (unioning))
(vconcat . (vconcating))
Expand Down Expand Up @@ -209,7 +208,6 @@ true names and lists of aliases.
(set-prev . loopy--parse-set-prev-command)
(skip . loopy--parse-skip-command)
(skip-from . loopy--parse-skip-from-command)
(sub-loop . loopy--parse-sub-loop-command)
(sum . loopy--parse-sum-command)
(thereis . loopy--parse-thereis-command)
(union . loopy--parse-union-command)
Expand Down Expand Up @@ -246,13 +244,6 @@ exist), one could do

;;;; Flags
;;;;; Variables that can be set by flags
(defvar loopy--split-implied-accumulation-results nil
"Whether implicit accumulation commands should use separate variables.
Nil means that each accumulation command without a named
accumulation variable should accumulate into the same variable,
by default named `loopy-result'.")

(defvar loopy--destructuring-for-with-vars-function nil
"The function used for destructuring `with' variables.
Expand Down Expand Up @@ -675,8 +666,7 @@ known to fall into the first group.")
;; -- Flag Variables --
loopy--destructuring-for-with-vars-function
loopy--destructuring-for-iteration-function
loopy--destructuring-accumulation-parser
loopy--split-implied-accumulation-results)
loopy--destructuring-accumulation-parser)
"These variables must be `let'-bound around the loop.
This list is mainly fed to the macro `loopy--wrap-variables-around-body'."))
Expand Down
48 changes: 2 additions & 46 deletions loopy.el
Original file line number Diff line number Diff line change
Expand Up @@ -130,40 +130,12 @@
(require 'loopy-vars)

;;;; Built-in flags
;;;;; Split
(make-obsolete 'loopy--enable-flag-split
(concat "use the `accum-opt' special macro argument."
" See the Info documentation.")
"2022-08")
(defun loopy--enable-flag-split ()
"Set `loopy-split-implied-accumulation-results' to t inside the loop."
(warn "The flag `split' is deprecated. Use `accum-opt' instead.")
(setq loopy--split-implied-accumulation-results t))

(make-obsolete 'loopy--disable-flag-split
(concat "use the `accum-opt' special macro argument."
" See the Info documentation.")
"2022-08")
(defun loopy--disable-flag-split ()
"Set `loopy-split-implied-accumulation-results' to t inside the loop."
(warn "The flag `split' is deprecated. Use `accum-opt' instead.")
;; Currently redundant, but leaves room for possibilities.
(if loopy--split-implied-accumulation-results
(setq loopy--split-implied-accumulation-results nil)))

(with-suppressed-warnings ((obsolete loopy--enable-flag-split
loopy--disable-flag-split))
(dolist (flag '(split +split))
(cl-callf map-insert loopy--flag-settings flag #'loopy--enable-flag-split))

(cl-callf map-insert loopy--flag-settings '-split #'loopy--disable-flag-split))

;;;;;; Default
;; It doesn't make sense to allow the disabling of this one.
(defun loopy--enable-flag-default ()
"Set `loopy' behavior back to its default state for the loop."
(setq loopy--split-implied-accumulation-results nil
loopy--destructuring-for-with-vars-function
(setq loopy--destructuring-for-with-vars-function
#'loopy--destructure-for-with-vars-default
loopy--destructuring-accumulation-parser
#'loopy--parse-destructuring-accumulation-command))
Expand Down Expand Up @@ -459,13 +431,7 @@ The function creates quoted code that should be used by a macro."
;; Be sure that the `cl-block' defaults to returning the
;; implicit return, which can be nil. This can be
;; overridden by any call to `cl-return-from'.
,(if (and loopy--split-implied-accumulation-results
loopy--implicit-return
(or loopy--after-do
loopy--final-do
loopy--final-return))
`(setq loopy-result ,loopy--implicit-return)
loopy--implicit-return))
,loopy--implicit-return)
;; Will always be a single expression after wrapping with
;; `cl-block'.
result-is-one-expression t)
Expand Down Expand Up @@ -511,16 +477,6 @@ The function creates quoted code that should be used by a macro."
(setq result `(let* ,loopy--accumulation-vars ,@(get-result))
result-is-one-expression t))

;; Bind `loopy-result' if using split accumulation variables.
;; In such case, no command requests this, so we do it here.
(when (and loopy--split-implied-accumulation-results
loopy--implicit-return
(or loopy--after-do
loopy--final-do
loopy--final-return))
(setq result `(let ((loopy-result nil)) ,@(get-result))
result-is-one-expression t))

;; Declare the With variables.
(when loopy--with-vars
(setq result `(,@(loopy--destructure-for-with-vars loopy--with-vars)
Expand Down
Loading

0 comments on commit a337730

Please sign in to comment.