# Fw: Re: Ruby/DL Documentation

**URL:** <https://www.ruby-forum.com/t/fw-re-ruby-dl-documentation/167390>\
**Category:** Ruby\
**Created:** [May 7, 2009, 11:38am UTC](https://www.ruby-forum.com/t/fw-re-ruby-dl-documentation/167390 "2009-05-07T11:38:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@Aston](https://www.ruby-forum.com/u/Aston)\
**Post date:** [May 7, 2009, 11:38am UTC](https://www.ruby-forum.com/t/fw-re-ruby-dl-documentation/167390/1 "2009-05-07T11:38:05Z")

</div>

I think this thread makes more sense here instead of polluting core ML

----- Forwarded Message ----  
From: Aston [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: removed\_email\_address@domain.invalid  
Sent: Wednesday, 6 May, 2009 11:34:36 PM  
Subject: [ruby-core:23371] Re: Ruby/DL Documentation

thanks a lot removed\_email\_address@domain.invalid and removed\_email\_address@domain.invalid

tad seems to be using 1.8.x, i am using ruby19 on FreeBSD7.2

[diesalunix@raptor ~]$ uname -a  
FreeBSD raptor 7.2-PRERELEASE FreeBSD 7.2-PRERELEASE #1: Sun Mar 29  
19:18:27 UTC 2009Â Â Â Â root@raptor:/usr/obj/usr/src/sys/ARGON18Â amd64  
[diesalunix@raptor ~]$ ruby19 -v  
ruby 1.9.2dev (2009-05-02 trunk 23326) [x86\_64-freebsd7.2]

as suggested by sh@ test/dl/test\_\*.rb are good (not gr8!) source for  
learning, but given the fact there exists no other code using dl  
elsewhere I am very happy I found them. thanks sh@

While googling around I discovered ruby-ffi  
([http://kenai.com/projects/ruby-ffi/pages/Home](http://kenai.com/projects/ruby-ffi/pages/Home)), and it seems to be much  
more clean and complete solution. It is supported by other VMs as well.  
I would have prefered to be with dl since it is part of standard ruby C  
implementation but it is very difficult to use(u got to have lot of time  
and little black magic), code using it is almost non-existent and  
/dev/null documentation

when reading about ruby-ffi elsewhere it appears very promising, what is  
its future in regard to ruby’s C implementation ? will it ever be part  
of stdlib ? it appears it is still taking shape but by and large stable

Aston

* * *

From: “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: removed\_email\_address@domain.invalid  
Sent: Tuesday, 5 May, 2009 2:06:09 PM  
Subject: [ruby-core:23359] Re: Ruby/DL Documentation

Hi,

It is helpful to read test/dl/test\_\*.rb in ruby-1.9.tar.gz.  
You have to master pack and unpack anyway.  
The following is an example.

$ cat sum.c  
double sum(double \*arry, int len)  
{  
Â double ret = 0;  
Â int i;  
Â for(i = 0; i \< len; i++){  
Â Â ret = ret + arry[i];  
Â }  
Â return ret;  
}

$ gcc -shared sum.c -o libsum.so

$ cat d.rb  
require ‘dl/import’  
module M  
Â extend DL::Importer  
Â dlload ‘./libsum.so’  
Â extern ‘double sum(double\*, int)’  
end  
p M.sum([2.0, 3.0, 4.0].pack(“d\*”), 3)

$ ruby-1.9 -v d.rb  
ruby 1.9.2dev (2009-05-02 trunk 23326) [i686-linux]  
9.0

2009/5/4 Aston [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> hack around ./ext/dl/_.c files but i have gained very little usable  
> some\_fast\_math\_function( float_ array, int len);  
> array = DL.malloc(size)  
> Click here!

* * *

Explore your hobbies and interests. Click here to begin.

```
  Cricket on your mind? Visit the ultimate cricket website. Enter 

```

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com/)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!
