4 ms·
Skill issue ;) * (defun fx-add (x y) (declare (optimize (speed 3) (safety 0) (debug 0)) (type fixnum x y)) (the fixnum (+ x
by ska80 2y ago
Skill issue ;)
* (defun fx-add (x y)
(declare (optimize (speed 3) (safety 0) (debug 0))
(type fixnum x y))
(the fixnum (+ x y)))
FX-ADD
* (disassemble 'fx-add)
; disassembly for FX-ADD
; Size: 6 bytes. Origin: #x552C81A6 ; FX-ADD
; 6: 4801FA ADD RDX, RDI
; 9: C9 LEAVE
; A: F8 CLC
; B: C3 RET
NIL
- ArtixFox 2y agowhat does (the ....) do?
- ska80 2y ago> what does (the ....) do? Specifies the type of the form. In this example, it tells the CL compiler that the returned `(+ x y)` is a `fixnum`.
- ArtixFox 2y agoOh thank you!!
- ska80 2y agoYou can also get the same result by declaring the function's type: * (declaim (ftype (function (fixnum fixnum) fixnum) fx-add)) (FX-ADD) * (defun fx-add (x y) (declare (optimize (speed 3) (safety 0) (debug 0))) (+ x y)) FX-ADD * (disassemble 'fx-add) ; disassembly for FX-ADD ; Size: 6 bytes. Origin: #x552C81A6 ; FX-ADD ; 6: 4801FA ADD RDX, RDI ; 9: C9 LEAVE ; A: F8 CLC ; B: C3 RET NIL