Paste number 49771: What does this give you?

Index of paste annotations: 1 | 2

Paste number 49771: What does this give you?
Pasted by: baggins
11 months, 2 weeks ago
#lispcafe | Context in IRC logs
Paste contents:
Raw Source | XML | Display As
(require '#:asdf)
(asdf:oos 'asdf:load-op '#:cffi)

(defpackage #:foo
  (:use #:cffi #:cl)
  (:shadow float)
)


(in-package #:foo)

(defctype float :float)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defmethod cffi:expand-to-foreign (value (type (eql 'float)))
    `(coerce ,value 'single-float)
)
)


(eval-when (:compile-toplevel :load-toplevel :execute)
  (format t "~s~%" (macroexpand-1 '(cffi:defcfun foreign-foo :void (in float))))
)

Annotations for this paste:

Annotation number 1: what about explicitely putting the package in?
Pasted by: baggins
11 months, 2 weeks ago
Context in IRC logs
Paste contents:
Raw Source | Display As
(require '#:asdf)
(asdf:oos 'asdf:load-op '#:cffi)

(defpackage #:foo
  (:use #:cffi #:cl)
  (:shadow float)
  (:export float)
)


(in-package #:foo)

(defctype foo:float :float)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defmethod cffi:expand-to-foreign (value (type (eql 'foo:float)))
    `(coerce ,value 'single-float)
)
)


(eval-when (:compile-toplevel :load-toplevel :execute)
  (format t "~s~%" (macroexpand-1 '(cffi:defcfun foreign-foo :void (in foo:float))))
)

Annotation number 2: Does this work at all on Mac/SBCL?
Pasted by: baggins
11 months, 2 weeks ago
Context in IRC logs
Paste contents:
Raw Source | Display As

(defctype any-old-type :float)

(defmethod cffi:expand-to-foreign (value (type (eql 'any-old-type)))
  `(coerce ,value 'single-float)
)


(format t "~a~%" (macroexpand-1 '(cffi:defcfun foreign-foo :void (in any-old-type))))

;; giving this:

(PROGN
 NIL
 (DEFUN FOREIGN-FOO (IN)
   (LET ((G1987 (COERCE IN 'SINGLE-FLOAT))) ;; the coerce is the key bit
     (VALUES (%FOREIGN-FUNCALL foreign_foo FLOAT G1987 VOID))
)
)

Colorize as:
Show Line Numbers
Index of paste annotations: 1 | 2

Ads absolutely not by Google

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.