<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div id="yiv3579301116"><div class="yiv3579301116yqt0936829457" id="yiv3579301116yqt70515"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"><div id="yiv3579301116"><div class="yiv3579301116yqt0556689695" id="yiv3579301116yqt17425"><div id="yiv3579301116yui_3_13_0_1_1396191901957_30483"><div class="yiv3579301116yui_3_13_0_1_1396191901957_30317" id="yiv3579301116yui_3_13_0_1_1396191901957_30482" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;">I was just wondering why cffi doesn't do automatic conversions. Since casting is used so much in c I think it would do automatic conversions...Do
experts in CFFI normally use this approach, do they cast on the Lisp side or use another approach..I'd like to start learning the best way to do things<br clear="none"><div class="yiv3579301116yahoo_quoted" id="yiv3579301116yui_3_13_0_9_1396191901957_10" style="display: block;"> <div class="yiv3579301116yui_3_13_0_1_1396191901957_6341 yiv3579301116yui_3_13_0_1_1396191901957_30319" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"> <div class="yiv3579301116yui_3_13_0_1_1396191901957_6342 yiv3579301116yui_3_13_0_1_1396191901957_30320" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On , Joeish W <joeish80829@yahoo.com> wrote:<br clear="none"> </font> </div> <blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;"> <div
class="yiv3579301116y_msg_container"><div id="yiv3579301116"><div><div class="yiv3579301116yui_3_13_0_1_1396191901957_6345 yiv3579301116yui_3_13_0_1_1396191901957_30323" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"><div><span></span></div><div class="yiv3579301116yqt0081270386" id="yiv3579301116yqt68624"><div class="yiv3579301116yahoo_quoted" style="display:block;"> <div class="yiv3579301116yui_3_13_0_1_1396191901957_6347 yiv3579301116yui_3_13_0_1_1396191901957_30325" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"> <div class="yiv3579301116yui_3_13_0_1_1396191901957_6348 yiv3579301116yui_3_13_0_1_1396191901957_30326" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Sunday, March 30,
2014 7:53 AM, Joeish W <joeish80829@yahoo.com> wrote:<br clear="none"> </font> </div> <blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;"> <div class="yiv3579301116y_msg_container"><div id="yiv3579301116"><div><div class="yiv3579301116yui_3_13_0_1_1396191901957_6351 yiv3579301116yui_3_13_0_1_1396191901957_30329" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"><div><span>I was just
wondering why cffi doesn't do automatic conversions. Since casting is used so much in c I think it would do automatic conversions...Do experts in CFFI normally use this approach, do they cast on the Lisp side or use another approach..I'd like to start learning the best way to do things<br clear="none"></span></div><div class="yiv3579301116yqt8015954991" id="yiv3579301116yqt63278"><div class="yiv3579301116yahoo_quoted" style="display:block;"> <div class="yiv3579301116yui_3_13_0_1_1396191901957_6353 yiv3579301116yui_3_13_0_1_1396191901957_30331" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"> <div class="yiv3579301116yui_3_13_0_1_1396191901957_6354 yiv3579301116yui_3_13_0_1_1396191901957_30332" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Sunday, March 30, 2014
7:45 AM, Stelian Ionescu
<sionescu@cddr.org> wrote:<br clear="none"> </font> </div> <blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;">
<div class="yiv3579301116y_msg_container">On Sun, 2014-03-30 at 07:18 -0700, Joeish W wrote:<br clear="none">> Thanks for getting back to me., I really appreciate it<br clear="none"><br clear="none">> Using coerce though I'm already casting it to a float on the lisp<br clear="none">> side...I was wondering if I can cast a 4 to a float with CFFI and have<br clear="none">> the output be a 4.0f0 like it works in C...without doing anything on<br clear="none">> the Lisp side<br clear="none"><br clear="none">CFFI doesn't do automatic coercions, but you can do it with a custom<br clear="none">type:<br clear="none"><br clear="none">(define-foreign-type float+int () ()<br clear="none"> (:actual-type :float)<br clear="none"> (:simple-parser float+int))<br clear="none"><br clear="none">(defmethod expand-to-foreign (value (type float+int))<br clear="none"> `(coerce ,value 'float))<br clear="none"><br
clear="none">(with-foreign-object (val :float)<br clear="none"> (setf (mem-ref val 'float+int) 4)<br clear="none"> (mem-ref val :float))<div class="yiv3579301116yqt1545252294" id="yiv3579301116yqtfd56486"><br clear="none"><br clear="none">-- <br clear="none">Stelian Ionescu a.k.a. fe[nl]ix<br clear="none">Quidquid latine dictum sit, altum videtur.<br clear="none"></div><br clear="none"><br clear="none"></div> </blockquote> </div> </div> </div></div> </div></div></div><br clear="none"><br clear="none"></div> </blockquote> </div> </div> </div></div> </div></div></div><br clear="none"><br clear="none"></div> </blockquote> </div> </div> </div> </div></div></div></div></div></div></div></div></div></body></html>