Clojure error reporting is a problem. This gist contains examples of missed opportunities for a clear error message. Let's discuss how common scenarios can be improved, and get some "patch welcome" tickets out there with clearly defined expectations.
ClojureScript macros can be loaded using the :require-macros primitive in ns forms (or require-macros REPL special).
But, there is a shortcut you can take if a runtime namespace requires macros from its macro namepace file. This might be a bit tricky to understand so here is a concrete example.
Let's say you have a macro file:
$ cat src/foo/core.clj
(ns foo.core)
| (defmacro doseqs | |
| [seq-exprs & body] | |
| (let [stk (gensym "stack__") | |
| level (gensym "level__") | |
| seq-exprs (partition 2 seq-exprs) | |
| bindings (vec (map first seq-exprs)) | |
| init-exprs (vec (map second seq-exprs)) | |
| nbinds (count init-exprs) |
| module ActiveRecord | |
| module Batches | |
| def find_each_with_order(options = {}) | |
| if block_given? | |
| find_in_batches_with_order(options) do |records| | |
| records.each { |record| yield record } | |
| end | |
| else | |
| enum_for :find_each, options do | |
| options[:start] ? where(table[primary_key].gteq(options[:start])).size : size |
| (ns clj-spec-playground | |
| (:require [clojure.string :as str] | |
| [clojure.spec :as s] | |
| [clojure.test.check.generators :as gen])) | |
| ;;; examples of clojure.spec being used like a gradual/dependently typed system. | |
| (defn make-user | |
| "Create a map of inputs after splitting name." | |
| ([name email] |
Many people struggle with this question. Some just try to make as much as a full-time employee makes (and ignore that they won't be able to bill as many days). Others follow tips on startup related websites that suggest to ask for 20% to 50% more than an salary would yield (and ignore the additional risk and expenses they have).
Below you will find some numbers to help you calculate how high your hourly or daily rate should be.
- You take more risk than full time employees, phases without income are likely
A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.
How to use:
- The link in the table of content jumps at the copy of the answer on this page.
- The link on the answer itself points back at the original post.
| (ns typehint.core) | |
| ;; A little type hint hint... | |
| (set! *warn-on-reflection* true) | |
| ;; There are two ways to type hint the return value of a function, but one is | |
| ;; (technically) wrong: | |
| (defn ^String as-string0 |
| function lein_current_version() { | |
| command grep defproject project.clj 2> /dev/null | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -o "\".*"\" | sed "s/\"//g" | |
| } | |
| function lein_prompt() { | |
| cat project.clj &> /dev/null || return 0 | |
| ZSH_THEME_LEIN_PROMPT_PREFIX="%{$fg_bold[green]%}" | |
| ZSH_THEME_LEIN_PROMPT_SUFFIX="%{$reset_color%} " | |
| echo "$ZSH_THEME_LEIN_PROMPT_PREFIX$(lein_current_version)$ZSH_THEME_LEIN_PROMPT_SUFFIX" | |
| } |
The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'instead ofconst foo = require('foo')to import the package. You also need to put"type": "module"in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)from CommonJS instead ofrequire(…). - Stay on the existing version of the package until you can move to ESM.