[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New feature proposal: Support C-code inline?

From: nalaginrut
Subject: New feature proposal: Support C-code inline?
Date: Wed, 20 Apr 2011 17:50:13 +0800

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
And I found a similar feature in Ruby. So I wrote a module to provide
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 <inline> #: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)))
   (myfunc 5 6)

===> 11

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?

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--
---end key---

Attachment: inline.scm
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]