1    Introduction

1.1    Overview

std.lib.foundation provides basic predicates, constructors, and helpers used across the foundation libraries.

2    Walkthrough

2.1    Constants and combinators

T, F, and NIL are constant functions. U and Z are classic fixed-point combinators, useful for anonymous recursion.

constant functions and combinators

^{:refer std.lib.foundation/T :added "3.0"}
(T 1 2 3)
=> true

^{:refer std.lib.foundation/F :added "3.0"}
(F 1 2 3)
=> false

^{:refer std.lib.foundation/Z :added "3.0"}
(let [factorial (fn [f]
                  (fn [n]
                    (if (zero? n)
                      1
                      (* n (f (dec n))))))]
  ((Z factorial) 5))
=> 120

2.2    Identifiers and time

Generate short IDs, UUIDs, and timestamps.

create identifiers and instants

^{:refer std.lib.foundation/sid :added "3.0"}
(sid)
=> string?

^{:refer std.lib.foundation/uuid :added "3.0"}
(uuid)
=> #(instance? java.util.UUID %)

^{:refer std.lib.foundation/instant :added "3.0"}
(instant 0)
=> #inst "1970-01-01T00:00:00.000-00:00"

2.3    Coercion helpers

strn, keyword, and string coerce values to common types.

coerce values

^{:refer std.lib.foundation/strn :added "3.0"}
(strn :hello)
=> "hello"

^{:refer std.lib.foundation/keyword :added "3.0"}
(keyword "hello")
=> :hello

^{:refer std.lib.foundation/string :added "3.0"}
(string (.getBytes "Hello"))
=> "Hello"

3    Constants and Combinators



^

[& args]
Added 3.0

returns `false` for any combination of input `args`

v 3.0
(defn F
  ([& args]
   false))
link
(F) => false (F :hello) => false (F 1 2 3) => false

NIL ^

[& args]
Added 3.0

returns `nil` for any combination of input `args`

v 3.0
(defn NIL
  ([& args]
   nil))
link
(NIL) => nil (NIL :hello) => nil (NIL 1 2 3) => nil

^

[& args]
Added 3.0

returns `true` for any combination of input `args`

v 3.0
(defn T
  ([& args]
   true))
link
(T) => true (T :hello) => true (T 1 2 3) => true 1 => (capture odd?)

^

[f]
Added 3.0

u Combinator

v 3.0
(defn U
  ([f] (fn [x] ((f f) x))))
link
(let [factorial (fn [f] (fn [n] (if (zero? n) 1 (* n ((f f) (dec n))))))] ((U factorial) 5)) => 120

^

[f]
Added 3.0

z combinator

v 3.0
(defn Z
  ([f] (let [A (fn [x] (f (U x)))] (A A))))
link
(let [factorial (fn [f] (fn [n] (if (zero? n) 1 (* n (f (dec n))))))] ((Z factorial) 5) => 120) ;; The body of Z can be defined as (defn- U1 ([f] (fn [x] (f (U x))))) ;; For the record, the Y combinator ;; can be defined as follows (defn- U0 ([f] (fn [x] (f (x x))))) (defn Y ([f] (let [A (U0 f)] (A A))))

xor ^

[] [a] [a b]
Added 3.0

performs xor comparison

v 3.0
(defmacro xor
  ([] nil)
  ([a] a)
  ([a b]
   `(let [a# ~a
          b# ~b]
      (if a#
        (if b# nil a#)
        (if b# b# nil)))))
link
(xor true false) => true (xor true true) => nil (xor false false) => nil

4    Identifiers

sid, uuid, and flake generate short and unique identifiers.



flake ^

[]
Added 3.0

returns a unique, time incremental id

v 3.0
(defn flake
  ([]
   (str (Flake/flake))))
link
(flake) ;; "4Wv-T47LftnVlHhhh00JYuU15NCuNLcr" => string?

sid ^

[]
Added 3.0

returns a short id string

v 3.0
(defn sid
  ([]
   (clojure.core/-> (str (java.util.UUID/randomUUID))
                    (.getBytes)
                    (java.nio.ByteBuffer/wrap)
                    (.getLong)
                    (Long/toString Character/MAX_RADIX))))
link
(sid) ;; "t8a6euzk9usy" => string?

uuid ^

[] [id] [msb lsb]
Added 3.0

returns a `java.util.UUID` object

v 3.0
(defn uuid
  ([] (java.util.UUID/randomUUID))
  ([id]
   (cond (string? id)
         (java.util.UUID/fromString id)

         (instance? (Class/forName "[B") id)
         (java.util.UUID/nameUUIDFromBytes id)

         (keyword? id)
         (java.util.UUID. (.hashCode ^Object id)
                          (.hashCode (name id)))

         :else
         (throw (ex-info (str id " can only be a string or byte array")))))
  ([^Long msb ^Long lsb]
   (java.util.UUID. msb lsb)))
link
(uuid) => #(instance? java.util.UUID %) (uuid "00000000-0000-0000-0000-000000000000") => #uuid "00000000-0000-0000-0000-000000000000"

uuid-nil ^

[]
Added 4.0

constructs a nil uuid

v 4.0
(defn uuid-nil
  ([]
   (java.util.UUID/fromString "00000000-0000-0000-0000-000000000000")))
link
(uuid-nil) => #uuid "00000000-0000-0000-0000-000000000000"

5    Constructors

Construct common Java and Clojure values.



counter ^

[] [n]
Added 3.0

creates a counter

v 3.0
(defn counter
  ([] (counter -1))
  ([n]
   (Counter. n)))
link
(pr-str (counter)) => "#counter{-1}"

date ^

[] [t]
Added 3.0

creates a new date

v 3.0
(defn date
  ([]  (Date.))
  ([^long t] (Date. t)))
link
(date 1000) => #inst "1970-01-01T00:00:01.000-00:00"

instant ^

[] [val]
Added 3.0

returns a `java.util.Date` object

v 3.0
(defn instant
  ([] (java.util.Date.))
  ([^Long val] (java.util.Date. val)))
link
(instant) => #(instance? java.util.Date %) (instant 0) => #inst "1970-01-01T00:00:00.000-00:00"

uri ^

[path]
Added 3.0

returns a `java.net.UrI` object

v 3.0
(defn uri
  ([path]
   (java.net.URI/create path)))
link
(uri "http://www.google.com") => java.net.URI

url ^

[path]
Added 3.0

retruns a `java.net.URL` object

v 3.0
(defn url
  ([path]
   (java.net.URL. path)))
link
(url "http://www.google.com") => java.net.URL

6    Coercion



edn ^

[obj]
Added 3.0

prints then reads back the string

v 3.0
(defn edn
  ([obj]
   (read-string (pr-str obj))))
link
((juxt type (comp type edn)) (symbol ":hello")) => [clojure.lang.Symbol clojure.lang.Keyword]

edn? ^

[x]
Added 3.0

checks if an entry is valid edn

v 3.0
(defn edn?
  ([x]
   (or (nil? x)
       (boolean? x)
       (string? x)
       (char? x)
       (symbol? x)
       (keyword? x)
       (number? x)
       (seq? x)
       (vector? x)
       (record? x)
       (map? x)
       (set? x)
       (tagged-literal? x)
       (var? x)
       (regexp? x))))
link
(edn? 1) => true (edn? {}) => true (edn? (java.util.Date.)) => false

keyword ^

[obj]
Added 3.0

returns the keyword value

v 3.0
(defn keyword
  ([obj]
   (cond (keyword? obj)
         obj

         (string? obj)
         (clojure.core/keyword obj)

         :else
         (throw (ex-info "Cannot process obj" {:input obj})))))
link
(keyword :hello) => :hello (keyword "hello") => :hello

string ^

[obj]
Added 3.0

creates a string from a byte array

v 3.0
(defn string
  ([obj]
   (cond (bytes? obj)
         (String. ^bytes obj)

         :else
         (str obj))))
link
(string (.getBytes "Hello")) => "Hello"

strn ^

[obj] [obj & more]
Added 3.0

returns the strn value

v 3.0
(defn strn
  (^String
   [obj]
   (cond (bytes? obj)
         (String. ^bytes obj)

         (keyword? obj)
         (subs (str obj) 1)

         (string? obj)
         obj

         :else
         (pr-str obj)))
  (^String
   [obj & more]
   (apply str (strn obj) (map strn more))))
link
(strn :hello) => "hello" (strn "hello") => "hello"

7    Type Predicates



array? ^

[x] [cls x]
Added 3.0

checks if object is a primitive array

v 3.0
(defn array?
  ([x]
   (.isArray ^Class (type x)))
  ([cls x]
   (and (array? x)
        (= cls (.getComponentType ^Class (type x))))))
link
(array? (into-array [])) => true (array? String (into-array ["a" "b" "c"])) => true

atom? ^

[obj]
Added 3.0

returns `true` if `x` is of type `clojure.lang.Atom`.

v 3.0
(defn atom?
  ([obj]
   (instance? clojure.lang.Atom obj)))
link
(atom? (atom nil)) => true

bigdec? ^

[x]
Added 3.0

returns `true` if `x` is of type `java.math.BigDecimal`.

v 3.0
(defn bigdec?
  ([x]
   (instance? java.math.BigDecimal x)))
link
(bigdec? 1M) => true (bigdec? 1.0) => false

bigint? ^

[x]
Added 3.0

returns `true` if `x` is of type `clojure.lang.BigInt`.

v 3.0
(defn bigint?
  ([x]
   (instance? clojure.lang.BigInt x)))
link
(bigint? 1N) => true (bigint? 1) => false

byte? ^

[x]
Added 3.0

returns `true` if `x` is of type `java.lang.Byte`

v 3.0
(defn byte?
  ([x] (instance? java.lang.Byte x)))
link
(byte? (byte 1)) => true

comparable? ^

[x y]
Added 3.0

returns `true` if `x` and `y` both implements `java.lang.Comparable`.

v 3.0
(defn comparable?
  ([x y]
   (and (instance? Comparable x)
        (instance? Comparable y)
        (= (type x) (type y)))))
link
(comparable? 1 1) => true

ideref? ^

[obj]
Added 3.0

checks if

v 3.0
(defn ideref?
  ([obj]
   (instance? clojure.lang.IDeref obj)))
link
(ideref? (volatile! 0)) => true (ideref? (promise)) => true

iobj? ^

[x]
Added 3.0

checks if a component is instance of `clojure.lang.IObj`

v 3.0
(defn iobj?
  ([x]
   (instance? clojure.lang.IObj x)))
link
(iobj? 1) => false (iobj? {}) => true

iref? ^

[obj]
Added 3.0

returns `true` if `x` is of type `clojure.lang.IRef`.

v 3.0
(defn iref?
  ([obj]
   (instance? clojure.lang.IRef obj)))
link
(iref? (atom 0)) => true (iref? (ref 0)) => true (iref? (agent 0)) => true (iref? (volatile! 0)) => false (iref? (promise)) => false (iref? (clojure.core/future)) => false

long? ^

[x]
Added 3.0

returns `true` if `x` is of type `java.lang.Long`

v 3.0
(defn long?
  ([x]
   (instance? java.lang.Long x)))
link
(long? 1) => true (long? 1N) => false

regexp? ^

[x]
Added 3.0

returns `true` if `x` implements `clojure.lang.IPersistentMap`.

v 3.0
(defn regexp?
  ([x] (instance? java.util.regex.Pattern x)))
link
(regexp? #"d+") => true

short? ^

[x]
Added 3.0

returns `true` if `x` is of type `java.lang.Short`

v 3.0
(defn short?
  ([x]
   (instance? java.lang.Short x)))
link
(short? (short 1)) => true

thread? ^

[obj]
Added 3.0

returns `true` is `x` is a thread

v 3.0
(defn thread?
  ([obj]
   (instance? java.lang.Thread obj)))
link
(thread? (Thread/currentThread)) => true

url? ^

[x]
Added 3.0

returns `true` if `x` is of type `java.net.URL`.

v 3.0
(defn url?
  ([x] (instance? java.net.URL x)))
link
(url? (java.net.URL. "file:/Users/chris/Development")) => true

8    Parsing



parse-double ^

[s]
Added 3.0

parses a double from string

v 3.0
(defn parse-double
  ([s]
   (Double/parseDouble s)))
link
(parse-double "100") => 100.0 (parse-double "100.123") => 100.123

parse-long ^

[s]
Added 3.0

parses a long from string

v 3.0
(defn parse-long
  ([s]
   (Long/parseLong s)))
link
(parse-long "100") => 100

9    Invocation



call ^

[obj] [obj f] [obj f v1] [obj f v1 v2] [obj f v1 v2 v3] [obj f v1 v2 v3 v4] [obj f v1 v2 v3 v4 & vs]
Added 3.0

like `invoke` but reverses the function and first argument

v 3.0
(defn call
  ([obj] obj)
  ([obj f] (if (nil? f) obj (f obj)))
  ([obj f v1] (if (nil? f) obj (f obj v1)))
  ([obj f v1 v2] (if (nil? f) obj (f obj v1 v2)))
  ([obj f v1 v2 v3] (if (nil? f) obj (f obj v1 v2 v3)))
  ([obj f v1 v2 v3 v4] (if (nil? f) obj (f obj v1 v2 v3 v4)))
  ([obj f v1 v2 v3 v4 & vs] (if (nil? f) obj (apply f obj v1 v2 v3 v4 vs))))
link
(call 2) => 2 (call 2 + 1 2 3) => 8

invoke ^

[f] [f & args]
Added 3.0

provides a caller for the `IFn`

v 3.0
(defn invoke
  ([^clojure.lang.IFn f]
   (.invoke f))
  ([^clojure.lang.IFn f & args]
   (.applyTo f args)))
link
(invoke (fn [] (+ 1 2 3))) => 6

10    Errors



error ^

[message] [message data]
Added 3.0

throws an error with message

v 3.0
(defmacro error
  ([message]
   `(throw (ex-info ~message {})))
  ([message data]
   `(throw (ex-info ~message ~data))))
link
(error "Error") => (throws)

suppress ^

[body] [body catch-val]
Added 3.0

suppresses any errors thrown in the body.

v 3.0
(defmacro suppress
  ([body]
   `(try ~body (catch Throwable ~'t)))
  ([body catch-val]
   `(try ~body (catch Throwable ~'t
                 (cond (fn? ~catch-val)
                       (~catch-val ~'t)
                       :else ~catch-val)))))
link
(suppress (throw (ex-info "Error" {}))) => nil (suppress (throw (ex-info "Error" {})) :error) => :error (suppress (throw (ex-info "Error" {})) (fn [^Throwable e] (.getMessage e))) => "Error"

throwable? ^

[obj]
Added 3.0

checks that object is a `Throwable`

v 3.0
(defn throwable?
  ([obj]
   (instance? Throwable obj)))
link
(throwable? (ex-info "hello" {})) => true

with-ex ^

[& body]
Added 4.0

gets the exception data in a form

v 4.0
(defmacro with-ex
  [& body]
  `(ex-data (try ~@body (catch Throwable ~'t ~'t))))
link
(with-ex (throw (ex-info "Error" {:hello "1"}))) => {:hello "1"}

with-thrown ^

[& body]
Added 4.0

gets the exception data in a form

v 4.0
(defmacro with-thrown
  [& body]
  `(try ~@body (catch Throwable ~'t ~'t)))
link
(ex-data (with-thrown (throw (ex-info "Error" {:hello "1"})))) => {:hello "1"}

11    Utilities



aget ^

[arr i]
Added 3.0

typesafe aget

v 3.0
(defn aget
  ([arr i]
   (case (.getName ^Class (type arr))
     "[J" (clojure.core/aget ^longs arr i)
     "[I" (clojure.core/aget ^ints arr i)
     "[S" (clojure.core/aget ^shorts arr i)
     "[B" (clojure.core/aget ^bytes arr i)
     "[Z" (clojure.core/aget ^booleans arr i)
     "[F" (clojure.core/aget ^floats arr i)
     "[D" (clojure.core/aget ^doubles arr i))))
link
(aget (int-array [1 2 3]) 2) => 3

demunge ^

[name]
Added 3.0

demunges an input to be nicer looking

v 3.0
(defn demunge
  ([name]
   (clojure.lang.Compiler/demunge name)))
link
(demunge ;;; (munge "+test!") "_PLUS_test_BANG_") => "+test!"

hash-code ^

[obj]
Added 3.0

returns the hash code of an object

v 3.0
(defn hash-code
  ([^Object obj]
   (.hashCode obj)))
link
(hash-code "hello") => number?

hash-id ^

[obj]
Added 3.0

returns the actual memory related id for an object

v 3.0
(defn hash-id
  ([obj]
   (System/identityHashCode obj)))
link
(hash-id {}) => (hash-id {}) (= (hash-id {:a 1}) (hash-id {:a 1})) => false (hash-id "1") => (hash-id "1")

unbound? ^

[obj]
Added 3.0

checks if a variable is unbound

v 3.0
(defn unbound?
  ([obj]
   (instance? clojure.lang.Var$Unbound obj)))
link
(declare -lost1-) (unbound? -lost1-) => true

var-sym ^

[var]
Added 3.0

converts a var to a symbol

v 3.0
(defn var-sym
  ([^clojure.lang.Var var]
   (symbol (str (.getName (.ns var)))
           (str (.sym var)))))
link
(var-sym #'var-sym) => 'std.lib.foundation/var-sym

12    std.lib.foundation Recommendations

std.lib.foundation provides the most basic utility functions for the entire foundation-base ecosystem. Its goal is to be a lightweight, universal "prelude" for all other modules. Here are some recommendations for new functionality that would align with this goal and further enhance the developer experience.

  • More String Utilities:n Justification: String manipulation is a very common task. While std.string.common exists, std.lib.foundation would benefit from having a few core, frequently used string functions directly available. This would reduce the need for other modules to import std.string.common, simplifying dependencies and improving code readability.n Recommendations:n trim: Removes leading and trailing whitespace from a string.n split: Splits a string into a sequence of strings based on a delimiter.n join: Joins a sequence of strings into a single string with a separator.n replace: Replaces all occurrences of a substring or pattern with another string.n starts-with?, ends-with?: Checks if a string starts or ends with a given prefix or suffix.n Example Usage:n ```clojuren (-> " hello world " h/trim (h/split #" ") (h/join "-"))n ;; => "hello-world"n ```nn Enhanced Type Checking:n Justification: The codebase already has predicates like string?, keyword?, and symbol?. Expanding this set would provide a more complete and consistent way to perform type checks, which is especially useful for validation and multi-method dispatch.n Recommendations:n mapp?: Checks if an object is a map.n vector?: Checks if an object is a vector.n set?: Checks if an object is a set.n fn?: Checks if an object is a function.n coll?: Checks if an object is a collection (list, vector, set, or map).n Example Usage:n ```clojuren (when (h/mapp? my-data)n (h/map-vals process-value my-data))n ```nn More Math Functions:n Justification: While the project has a math namespace, some very basic math functions are so common that they would be a good fit for std.lib.foundation.n Recommendations:n abs: Returns the absolute value of a number.n min, max: Returns the minimum or maximum of a set of numbers.n round, floor, ceil: For rounding numbers.n Example Usage:n ```clojuren (h/round 3.14159) ;; => 3n (h/max 1 5 2 8 3) ;; => 8n ```nn identity function:n Justification: The identity function is a fundamental building block in functional programming. It's often used as a default function or in higher-order functions. Its absence is a noticeable omission.n Recommendation: Add (defn identity [x] x).n Example Usage:n ```clojuren (get-in my-map [:a :b] :default-value)n ;; vsn (-> (get-in my-map [:a :b]) (or :default-value))n ;; with identityn (-> (get-in my-map [:a :b]) (h/call identity) (or :default-value))n ```nn constantly function:n Justification: constantly is another useful higher-order function that creates a function that always returns the same value. It's great for stubbing out functions or for use with functions like map.n Recommendation: Add (defn constantly [x] (fn [& args] x)).n Example Usage:n ```clojuren (map (h/constantly 0) (range 5)) ;; => (0 0 0 0 0)n ```nn juxt function:n Justification: juxt is a powerful function for applying multiple functions to the same arguments and collecting the results. It can simplify code and make it more expressive.n Recommendation: Add a juxt implementation.n Example Usage:n ```clojuren (let [stats (h/juxt min max count)]n (stats [1 5 2 8 3])) ;; => [1 8 5]n ```

13    std.lib.foundation: A Comprehensive Summary

The std.lib.foundation namespace is a foundational utility library within the foundation-base ecosystem, providing a wide array of functions and macros that serve as core building blocks for other modules. It extends, re-implements, or introduces new functionalities for common programming tasks, with a strong emphasis on low-level operations, type checking, meta-programming, and interoperability.

Key Features and Concepts (Summarizing all public symbols):

  1. Core Constants and Basic Utilities:n +init+: A var holding find-ns, likely used for initialization or namespace lookup.n *sep*: A dynamic var for a separator string, defaulting to "/".n T: A function that always returns true, regardless of arguments.n F: A function that always returns false, regardless of arguments.n NIL: A function that always returns nil, regardless of arguments.n xor: A macro for performing an exclusive OR comparison between two boolean values.nn2. Unique Identifiers and Time:n sid: Generates a short, unique ID string.n sid-tag: A memoized function to generate a short ID string based on a tag.n uuid: Creates a java.util.UUID object from various inputs (random, string, byte array, keyword, or two Longs).n uuid-nil: Constructs a nil UUID (all zeros).n instant: Returns a java.util.Date object, either current or from a Long timestamp.n uri: Creates a java.net.URI object from a path string.n url: Creates a java.net.URL object from a path string.n date: Creates a java.util.Date object, either current or from a long timestamp.n flake: Returns a unique, time-incremental ID string using hara.lib.foundation.Flake.nn3. String and Data Manipulation:n strn: Converts various types (bytes, keyword, string) to a string, or pr-str for others. Can concatenate multiple arguments.n lsubs: Returns a substring from the beginning, excluding n characters from the end.n keyword: Converts a string or keyword to a keyword.n string: Converts a byte array to a string, or str for other types.n concatv: Concatenates multiple sequences into a single vector.n edn: Prints an object to a string and then reads it back, useful for serialization/deserialization testing.nn4. Combinators:n U: The U combinator, enabling recursive function definitions.n Z: The Z combinator, also for recursive function definitions.nn5. Counters:n counter: Creates a mutable counter object (hara.lib.foundation.Counter).n inc!: Increments a counter by 1 or a specified amount.n dec!: Decrements a counter by 1 or a specified amount.n reset!: Resets a counter to a given value.nn6. Function Invocation and Macros:n invoke: Invokes a clojure.lang.IFn with arguments.n call: Similar to invoke, but reverses the function and first argument, allowing for a threading-like style.n const: A macro that evaluates its body at compile time, effectively creating a constant.n applym: A macro that allows applying other macros to arguments, similar to apply for functions.nn7. Code Context and Threading Macros:n code-ns: Returns the symbol of the current namespace where the code is located.n code-line: Returns the line number of the current code form.n code-column: Returns the column number of the current code form.n thread-form: A helper function for -> and ->> macros.n ->: A threading macro similar to clojure.core/->, but uses % as a placeholder for the threaded value, offering more flexibility.n ->>: A threading macro similar to clojure.core/->>, also using % as a placeholder.nn8. Var and Symbol Management:n var-sym: Converts a clojure.lang.Var to its fully qualified symbol.n unbound?: Checks if a var is currently unbound.n set!: A macro to set the value of a var without altering its metadata, providing a controlled way to re-define vars.nn9. Error Handling and Debugging:n suppress: A macro that executes a body of code and suppresses any Throwable exceptions, optionally returning a default value or applying a handler function to the exception.n with-thrown: A macro that executes a body and returns any Throwable caught, otherwise returns the result of the body.n with-ex: A macro that executes a body and returns the ex-data of any Throwable caught, otherwise returns the result of the body.n with-retry-fn: A function that retries a given function f a specified limit number of times, with a sleep interval between retries, until it succeeds or the limit is reached.n with-retry: A macro wrapper around with-retry-fn for convenient retry logic.n error: A macro to throw an ex-info with a message and optional data.n trace: A macro that returns a Throwable containing a stack trace, useful for debugging code paths.n throwable?: A predicate to check if an object is an instance of java.lang.Throwable.nn10. Type Predicates:n byte?: Checks if an object is a java.lang.Byte.n short?: Checks if an object is a java.lang.Short.n long?: Checks if an object is a java.lang.Long.n bigint?: Checks if an object is a clojure.lang.BigInt.n bigdec?: Checks if an object is a java.math.BigDecimal.n regexp?: Checks if an object is a java.util.regex.Pattern.n iobj?: Checks if an object implements clojure.lang.IObj.n iref?: Checks if an object implements clojure.lang.IRef (e.g., Atom, Ref, Agent).n ideref?: Checks if an object implements clojure.lang.IDeref (e.g., volatile!, promise).n thread?: Checks if an object is a java.lang.Thread.n url?: Checks if an object is a java.net.URL.n atom?: Checks if an object is a clojure.lang.Atom.n comparable?: Checks if two objects are both Comparable and of the same type.n array?: Checks if an object is a primitive array, optionally checking its component type.n edn?: Checks if an object is a valid EDN (Extensible Data Notation) value.nn11. Parsing and Hashing:n parse-long: Parses a string into a Long.n parse-double: Parses a string into a Double.n hash-id: Returns the identity hash code of an object (memory address-based).n hash-code: Returns the standard hashCode of an object.nn12. Array Access:n aget: A type-safe version of clojure.core/aget for primitive arrays (e.g., longs, ints, bytes).nn13. Namespace and Var Interning (Meta-programming):n demunge: Demunges a Java-mangled name back to its original Clojure form.n re-create: A memoized function to create a java.util.regex.Pattern from a string, escaping special characters.n intern-var: Interns a var into a specified namespace, optionally merging metadata.n intern-form: A helper function to create the form for intern-var.n intern-in: A macro to intern specific vars from other namespaces into the current one.n intern-all: A macro to intern all public vars from one or more namespaces into the current one.nn14. Templating Macros (Advanced Meta-programming):n *template-meta*: A dynamic var for binding template metadata.n with:template-meta: A macro to bind *template-meta* for a block of code.n template-meta: Returns the currently bound template metadata.n template-vars: A macro to generate multiple var definitions using a template function and a list of symbols/arguments.n template-entries: A macro to generate entries using a template function and a list of data entries, supporting resolution of symbols and lists.n template-bulk: Similar to template-entries but optimized for heavy usage, applying eval to the template function's output.n template-ensure: A helper function to verify that templated entries match the actual interned vars, useful for consistency checks.nn15. Wrapped Objects:n Wrapped: A deftype for wrapping values, primarily for display purposes, allowing custom toString behavior.n wrapped: Creates a Wrapped object.n wrapped?: Checks if an object is a Wrapped instance.nn16. Namespaced Symbol Resolution:n resolve-namespaced: Resolves a namespaced symbol to its fully qualified var symbol.nn17. Multiple Var Definition:n def.m: A macro to define multiple vars from the elements of a sequence returned by a single call.

Usage and Importance:

std.lib.foundation is a critical component of the foundation-base project, serving as its low-level utility belt. Its functions and macros are designed to:

  • Enhance Clojure Core: Provide more robust or specialized versions of common Clojure functionalities.n Facilitate Interoperability: Offer seamless integration with Java types and features.n Support Meta-programming: Enable powerful code generation, introspection, and transformation, which is essential for the project's transpilation and runtime management goals.n Improve Debugging and Development: Provide tools for unique ID generation, precise timing, error handling, and code context retrieval.n Ensure Type Safety: Offer a comprehensive set of type predicates and type-aware operations.

By consolidating these fundamental capabilities, std.lib.foundation provides a stable and extensible base upon which the rest of the foundation-base ecosystem is built, contributing significantly to its flexibility, performance, and maintainability.