# HG changeset patch # User Steve Losh # Date 1481837722 18000 # Node ID c6cecc512cbc507dce366a5898276cdb5089f39b # Parent 378a7aae37e31c58c167ee2a004341b2191727db Comments diff -r 378a7aae37e3 -r c6cecc512cbc src/generic-arithmetic.lisp --- a/src/generic-arithmetic.lisp Wed Dec 07 16:12:05 2016 -0500 +++ b/src/generic-arithmetic.lisp Thu Dec 15 16:35:22 2016 -0500 @@ -28,6 +28,9 @@ ;;; known to be `number`s at compile time it will compile in the vanilla CL op ;;; instead: ;;; +;;; +;;; No declaration, calls the generic function in this package: +;;; ;;; (defun foo (x) ;;; (+ 5 x)) ;;; (disassemble 'foo) @@ -45,6 +48,8 @@ ;;; ; 61B: 0F0B10 BREAK 16 ; Invalid argument count trap ;;; ;;; +;;; Number, calls the Lisp +: +;;; ;;; (defun foo-number (x) ;;; (declare (type number x)) ;;; (+ 5 x)) @@ -66,6 +71,8 @@ ;;; ; 6F: 0F0B10 BREAK 16 ; Invalid argument count trap ;;; ;;; +;;; Small number, SBCL just compiles down to fixnum addition: +;;; ;;; (defun foo-byte (x) ;;; (declare (type (unsigned-byte 8) x)) ;;; (+ 5 x)) @@ -121,6 +128,7 @@ (define-generic-operation * cl:* t) (define-generic-operation / cl:/ nil) + ;;;; Example: Vectors ;;; Addition (defmethod unary+ ((v vector)) v)