From b74dbfd2f0688cd9f48df04ee2e2cb219c28fbb0 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Fri, 26 Jun 2026 22:05:21 -0400 Subject: [PATCH] Symbols are IFn (invoke as a map lookup) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ('sym coll) / ('sym coll default) now do (get coll 'sym ...), like keywords — a symbol is IFn on the JVM. jolt threw "cannot be cast to clojure.lang.IFn". Pre-existing gap (not a regression), surfaced by honeysql's :checking mode, which does ('where dsl) to look up a clause. honeysql 623/13/8 -> 635/8/1. Corpus rows added. --- host/chez/seq.ss | 1 + test/chez/corpus.edn | 3 +++ 2 files changed, 4 insertions(+) diff --git a/host/chez/seq.ss b/host/chez/seq.ss index 7ac020a..98401ad 100644 --- a/host/chez/seq.ss +++ b/host/chez/seq.ss @@ -161,6 +161,7 @@ (cond ((procedure? f) (apply f args)) ((keyword? f) (apply jolt-get (car args) f (cdr args))) ; (:k m [d]) -> (get m :k [d]) + ((jolt-symbol? f) (apply jolt-get (car args) f (cdr args))) ; ('s m [d]) -> (get m 's [d]) ((jolt-coll? f) (apply jolt-get f args)) ; (coll k [d]) -> (get coll k [d]) ((jolt-transient? f) (apply jolt-get f args)) ; a transient vec/map/set is callable on the JVM ;; a record/reify implementing clojure.lang.IFn is callable: dispatch to its diff --git a/test/chez/corpus.edn b/test/chez/corpus.edn index 67b70b7..c880e4b 100644 --- a/test/chez/corpus.edn +++ b/test/chez/corpus.edn @@ -3293,4 +3293,7 @@ {:suite "seqs / lazy-seq interop" :label "empty? of an empty rest" :expected "true" :actual "(empty? (rest [1]))"} {:suite "seqs / lazy-seq interop" :label "cons onto a rest-seq" :expected "true" :actual "(= [0 2 3] (vec (cons 0 (rest [1 2 3]))))"} {:suite "seqs / lazy-seq interop" :label "into a set from a rest-seq" :expected "true" :actual "(= #{2 3} (into #{} (rest [1 2 3])))"} + {:suite "ifn / symbol as fn" :label "a symbol invokes as a map lookup" :expected "true" :actual "(= 5 ('a {(quote a) 5}))"} + {:suite "ifn / symbol as fn" :label "a symbol fn takes a not-found default" :expected "true" :actual "(= :d ('a {} :d))"} + {:suite "ifn / symbol as fn" :label "a symbol works as a mapping fn" :expected "true" :actual "(= [1 2] (vec (map (quote k) [{(quote k) 1} {(quote k) 2}])))"} ]