From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: New feature proposal: Support C-code inline? Date: Fri, 22 Apr 2011 16:14:19 -0400 Message-ID: References: <1303293013.2749.41.camel@Renee-desktop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1303503272 28293 80.91.229.12 (22 Apr 2011 20:14:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 22 Apr 2011 20:14:32 +0000 (UTC) Cc: guile-devel To: NalaGinrut@gmail.com Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Apr 22 22:14:26 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QDMkE-0000Fx-BX for guile-devel@m.gmane.org; Fri, 22 Apr 2011 22:14:26 +0200 Original-Received: from localhost ([::1]:46302 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QDMkC-0005BD-W8 for guile-devel@m.gmane.org; Fri, 22 Apr 2011 16:14:25 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QDMk9-0005B3-TC for guile-devel@gnu.org; Fri, 22 Apr 2011 16:14:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QDMk8-0007HT-Pc for guile-devel@gnu.org; Fri, 22 Apr 2011 16:14:21 -0400 Original-Received: from mail-vw0-f41.google.com ([209.85.212.41]:51798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QDMk8-0007HP-NC for guile-devel@gnu.org; Fri, 22 Apr 2011 16:14:20 -0400 Original-Received: by vws4 with SMTP id 4so886574vws.0 for ; Fri, 22 Apr 2011 13:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=SSdbmJlSDANIeLMDJNoIQIe5ZU3se5+aBRRbWTOtsOA=; b=reAgBFAXcKM1Lmiu95sOtr4fx3nw7Ufzs9Q/qvFVY8QMAnYKV7wDB29avtPZYYIz52 kwRTHbe2yXhVg2Cl+M0t7PhaD0U0jdloQc+jPdqtDSlHIAYogAaSxGW2bmHvpRSHSSOp RqK9TCp1wdg7c6RZgfo6zIktNJ1HqUeDmU1nE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=LDUJqFfdpUq2NW4WfTupHRXrrO2TgTgQZJCm2/ZfhiUsyw/3QExVzWF9QyQ8NU7rGG TCm6w3fh1kjX+BzydpqbSixsF3aosOHaMtI2pOBFw8Ow88jixSdNmb4Rvk+ZOYIrNHMX A5MAZOIvpjS4JUXnScmiFiIImluD9ExV6SyEk= Original-Received: by 10.52.111.10 with SMTP id ie10mr2201198vdb.81.1303503259476; Fri, 22 Apr 2011 13:14:19 -0700 (PDT) Original-Received: by 10.52.166.70 with HTTP; Fri, 22 Apr 2011 13:14:19 -0700 (PDT) In-Reply-To: <1303293013.2749.41.camel@Renee-desktop> X-Google-Sender-Auth: n5m6wB3FABFRIf2AG03jJeQr_2c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.212.41 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12315 Archived-At: I just looked at the code. It's really cool! This looks like a way to write modules that use C and Scheme together in such a way that the code is all in one place. I think it could be much easier to read code written this way than code in separate C and Scheme files. What do other people think? Noah On Wed, Apr 20, 2011 at 5:50 AM, nalaginrut wrote: > hi all! > I think somebody will need such a C-inline feature when he wants to > write a smart C-function to replace the critical function in his > algorithm. > And I found a similar feature in Ruby. So I wrote a module to provide > this. > Anyway, I think the best solution is a AOT compiler for guile. But it > seems to be dystocia. So this module provides an easy solution. > > Let me show it's usage: > (use-modules (inline inline)) > > (define in (make #:name "mytest")) > ;; this name is arbitrary. But if you made more than one inline instance > ;; in your program, each must has an unique name. Or shit happens. > > (inline:eat-code in "int func(int a ,int b){ return a+b;}") > ;; well~this example is too stupid. Try another as you will... > > (let ((myfunc (inline:get in))) > =A0 (myfunc 5 6) > =A0) > > =3D=3D=3D> 11 > > Drawback: > 1. Though this module will parse the function type list, it's not > perfect. Users can only chose "int/float/double/char/long/void". > 2. Can't support "unsigned" in the function declaration. But you can use > them in the function body. > 3. Can't support "pointers" in the function declaration, it's a big > drawback. This inline feature is restricted so much because of this > pity. The good news is you can use it in the function body. > 4. ...Anyone find more? > > Future: > 1. Fix the known drawbacks. > 2. Each inline instance will generate a share lib file. That means each > inline function will have one share lib file. > Though they won't conflict because the lib file name is bound to the > program name which use it, I think it's not proper. > Maybe we can add several inline functions to one inline instance, and > generate just one share lib for each program. > > I don't know how much people is interested it. For some low-level > programming guys, this module even provides inline assemble. I know this > module is too simple for some guys, but it's easy to implement and easy > to use. > > My patch is attached(actually it's not a patch...). > Any advices? > > -- > GNU Powered it > GPL Protected it > GOD Blessed it > > HFG - NalaGinrut > > --hacker key-- > v4sw7CUSMhw6ln6pr8OSFck4ma9u8MLSOFw3WDXGm7g/l8Li6e7t4TNGSb8AGORTDLMen6g6R= ASZOGCHPa28s1MIr4p-x hackerkey.com > ---end key--- >