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

feat: support map application #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat: support map application #84

wants to merge 1 commit into from

Conversation

phrohdoh
Copy link
Contributor

@phrohdoh phrohdoh commented Jul 7, 2021

Similar to #85.


Clojure 1.10.3 behavior:

({:k :v})                         ;; => Execution error (ArityException) at user/eval1 (REPL:1). Wrong number of args (0) passed to: clojure.lang.PersistentArrayMap
({:k :v} :k)                      ;; => :v
({:k :v} :x :not-found)           ;; => :not-found
({:k :v} :x :not-found :too-many) ;; => Execution error (ArityException) at user/eval1 (REPL:1). Wrong number of args (3) passed to: clojure.lang.PersistentArrayMap
({:k :v} ((fn [] :k)))            ;; => :v
bash command to generate above via the clj command-line tool

one-liner:

for src in '({:k :v})' '({:k :v} :k)' '({:k :v} :x :not-found)' '({:k :v} :x :not-found :too-many)' '({:k :v} ((fn [] :k)))'; do printf "%s ;; => " "$src"; clj -e "(prn $src)"; done

in a more human-friendly form:

for src in \
  '({:k :v})' \
  '({:k :v} :k)' \
  '({:k :v} :x :not-found)' \
  '({:k :v} :x :not-found :too-many)' \
  '({:k :v} ((fn [] :k)))' \
; do
  printf "%s ;; => " "$src";
  clj -e "$src";
done

ClojureRS prior to this PR:

({:k :v})                         ;; => #Condition["Execution Error: clojure.lang.PersistentListMap cannot be cast to clojure.lang.IFn"]
({:k :v} :k)                      ;; => #Condition["Execution Error: clojure.lang.PersistentListMap cannot be cast to clojure.lang.IFn"]
({:k :v} :x :not-found)           ;; => #Condition["Execution Error: clojure.lang.PersistentListMap cannot be cast to clojure.lang.IFn"]
({:k :v} :x :not-found :too-many) ;; => #Condition["Execution Error: clojure.lang.PersistentListMap cannot be cast to clojure.lang.IFn"]
({:k :v} ((fn [] :k)))            ;; => #Condition["Execution Error: clojure.lang.PersistentListMap cannot be cast to clojure.lang.IFn"]

ClojureRS with the changes in this PR applied:

({:k :v})                         ;; => #Condition["Wrong number of arguments given to function (Given: 0, Expected: [1, 2])"]
({:k :v} :k)                      ;; => :v
({:k :v} :x :not-found)           ;; => nil (todo: should be :not-found see https://github.com/clojure-rs/ClojureRS/issues/86)
({:k :v} :x :not-found :too-many) ;; => #Condition["Wrong number of arguments given to function (Given: 3, Expected: [1, 2])"]
({:k :v} ((fn [] :k)))            ;; => :v
bash command to generate above via the ClojureRS REPL

one-liner:

for src in '({:k :v})' '({:k :v} :k)' '({:k :v} :x :not-found)' '({:k :v} :x :not-found :too-many)' '({:k :v} ((fn [] :k)))'; do printf "%s ;; => " "$src"; cargo run -- -e "$src"; done

in a more human-friendly form:

for src in \
  '({:k :v})' \
  '({:k :v} :k)' \
  '({:k :v} :x :not-found)' \
  '({:k :v} :x :not-found :too-many)' \
  '({:k :v} ((fn [] :k)))' \
; do
  printf "%s ;; => " "$src";
  cargo run -- -e "$src";
done

src/value.rs Outdated Show resolved Hide resolved
@phrohdoh phrohdoh changed the title feat: support map in function position feat: support map application Jul 8, 2021
    ({:k :v})                         ;; => arity error
    ({:k :v} :k)                      ;; => :v
    ({:k :v} :x :not-found)           ;; => nil (todo: should be :not-found see todo)
    ({:k :v} :x :not-found :too-many) ;; => arity error
    ({:k :v} ((fn [] :k)))            ;; => :v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant