Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify PICK behavior #243

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/hissp/macros.lissp
Original file line number Diff line number Diff line change
Expand Up @@ -2622,9 +2622,7 @@ except ModuleNotFoundError:pass"
``/`` DROP (term)
Removes expression (at depth).
``&`` PICK (term)
Copies expression (at depth) and pushes. Non-literal expressions
are extracted to a local first (using `let`), and the resulting
symbol is copied instead.
Copies expression (at depth) and pushes.
``@`` ROLL (term, default depth 2)
Pops expression (at depth) and pushes.
``>`` MARK (term, default depth 0)
Expand Down Expand Up @@ -2764,23 +2762,13 @@ except ModuleNotFoundError:pass"
control-word? X#(my.startswith? X ":")
module-handle? X#(&& (my.str? X) (.endswith X "."))
method? X#(my.startswith? X ".")
symbol? X#(&& (my.str? X) (.isidentifier (.replace X "." "")))
G None
exprs (list exprs)
arity (.count suffix "^")
mark (getattr unittest.mock..sentinel "hissp.>"))
(attach my
: iexprs (iter my.exprs)
obj (next (.reads my.reader (.replace cmd "`" "")))
arity+1 (op#add 1 my.arity))
(when (&& (op#eq "&" cmd)
(not (my.literal? (set@ my.target (op#getitem exprs my.arity))))
(not (hissp.reader..is_lissp_string my.target))
(not (my.control-word? my.target))
(not (my.symbol? my.target))
(not (my.quotation? my.target)))
(set@ my.G (.format "{}{}" `$#G (hissp.reader..gensym_counter)))
(op#setitem my.exprs my.arity my.G))
(set@ my.result
(case cmd (@ (if-else (|| (my.literal? my.obj)
(.startswith suffix ",")
Expand All @@ -2805,9 +2793,6 @@ except ModuleNotFoundError:pass"
: ()))
(set@ my.result
(._rewrite _macro_ program : :* my.result :* my.iexprs))
(when my.G
(set@ my.result
`(let (,my.G ,my.target) ,my.result)))
my.result)))

.#`(progn ,@(map X#(let (args (get#(slice X) `($#x $#y $#z $#w))
Expand Down
Loading