CIEL is an extended CL
Find a file
2020-10-09 12:58:46 +02:00
src add cl-decimals 2019-08-07 18:52:15 +02:00
.gitignore init 2019-03-23 13:04:03 +01:00
ciel.asd bordeaux-threads, lparallel, moira, cl-cron, trivial-monitored-thread 2020-10-09 12:58:46 +02:00
README.org readme punch 2019-08-07 19:01:40 +02:00

Packages:

  • ciel
  • ciel-user: commodity.
  • generic-ciel: uses generic-cl instead of cl.

What is this ?

generic-cl

TODO: contribute a defmethod example.

;; with a struct or class "point":
(defmethod equalp ((p1 point) (p2 point))
   ())

Libraries

Syntax extensions

Pythonic triple quotes docstring

https://github.com/smithzvk/pythonic-string-reader

We can use triple quotes for docstrings, and double quotes within them.

(defun foo ()
  """foo "bar"."""
  t)

Lambda shortcuts

https://github.com/windymelt/cl-punch/ - Scala-like anonymous lambda literal.

;; ^() is converted into (lambda ...) .
;; Each underscore is converted into a lambda argument.

(mapcar ^(* 2 _) '(1 2 3 4 5))
;; => '(2 4 6 8 10)

;; One underscore corresponds one argument.

(^(* _ _) 2 3)
;; => 6

;; <_ reuses last argument.

(mapcar ^(if (oddp _) (* 2 <_) <_) '(1 2 3 4 5))
;; => '(2 2 6 4 10)

;; _! corresponds one argument but it is brought to top of the argument list.
;; It can be useful when you want to change argument order.

(^(cons _ _!) :a :b)
;; => (:b . :a)

(^(list _! _! _!) 1 2 3)
;; => '(3 2 1)

[TODO] cl-annot: Python-like annotations

https://github.com/m2ym/cl-annot

Without the slime helper, can't use it in the REPL ??

If you use Emacs, it is recommended to install misc/slime-annot.el which contains some features of annotations. After locating misc/slime-annot.el into your loadpath, write the following code into your .emacs.

(require 'slime-annot)

Parsing numbers, floats, decimals

cl-decimals: parse and format decimal numbers

https://github.com/tlikonen/cl-decimals

The main interface are the functions parse-decimal-number and format-decimal-number. The former is for parsing strings for decimal numbers and the latter for pretty-printing them as strings.

Reading:

DECIMALS> (parse-decimal-number "0.24")
6/25


DECIMALS> (parse-decimal-number "12,345"
                                :decimal-separator #\,
                                :negative-sign #\)
-2469/200

Parsing:

DECIMALS> (format-decimal-number -100/6 :round-magnitude -3)
"-16.667"
("-" "16" "." "667")

DECIMALS> (loop for e from -5 upto 5
                do (print (format-decimal-number
                           (expt 10 e) :round-magnitude -5
                           :decimal-separator ","
                           :integer-minimum-width 7
                           :integer-group-separator " "
                           :fractional-minimum-width 7
                           :fractional-group-separator " ")))

"      0,000 01"
"      0,000 1 "
"      0,001   "
"      0,01    "
"      0,1     "
"      1       "
"     10       "
"    100       "
"  1 000       "
" 10 000       "
"100 000       "
NIL

trivial-arguments

https://github.com/Shinmera/trivial-arguments

(defun foo (a b c &optional d) nil)
(arglist #'foo)
;; (a b c &optional d)

Rules

  • don't install libraries that need a Slime helper to work in the REPL (cl-annot).