[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Purpose of rb_assoc_new

Ian Macdonald

2/25/2005 8:12:00 PM

Hello,

I recently took over the maintenance of the Ruby/LDAP library and am
stuck on interpreting the following line:

tmp = rb_assoc_new (op, rb_ary_new ());

I can't find an explanation of rb_assoc_new() anywhere. It's used all
over the Ruby source code and yet I still can't figure what's going on.

I know that rb_ary_new() makes a new array, which is presumably being
associated with tmp, but what does op have to do with it?

array.c has the definition:

VALUE
rb_assoc_new(car, cdr)
VALUE car, cdr;
{
VALUE ary;

ary = rb_ary_new2(2);
RARRAY(ary)->ptr[0] = car;
RARRAY(ary)->ptr[1] = cdr;
RARRAY(ary)->len = 2;

return ary;
}

Is this just a convenient way to instantiate a two element array?

Ian
--
Ian Macdonald | He knew the tavernes well in every toun.
System Administrator | -- Geoffrey Chaucer
ian@caliban.org |
http://www.c... |
|


5 Answers

Marcelo (PC)

2/25/2005 8:16:00 PM

0

Do anyone know about a library capable of generating a printable report?


----- Original Message -----
From: "Ian Macdonald" <ian@caliban.org>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Friday, February 25, 2005 12:12 PM
Subject: Purpose of rb_assoc_new()


> Hello,
>
> I recently took over the maintenance of the Ruby/LDAP library and am
> stuck on interpreting the following line:
>
> tmp = rb_assoc_new (op, rb_ary_new ());
>
> I can't find an explanation of rb_assoc_new() anywhere. It's used all
> over the Ruby source code and yet I still can't figure what's going on.
>
> I know that rb_ary_new() makes a new array, which is presumably being
> associated with tmp, but what does op have to do with it?
>
> array.c has the definition:
>
> VALUE
> rb_assoc_new(car, cdr)
> VALUE car, cdr;
> {
> VALUE ary;
>
> ary = rb_ary_new2(2);
> RARRAY(ary)->ptr[0] = car;
> RARRAY(ary)->ptr[1] = cdr;
> RARRAY(ary)->len = 2;
>
> return ary;
> }
>
> Is this just a convenient way to instantiate a two element array?
>
> Ian
> --
> Ian Macdonald | He knew the tavernes well in every toun.
> System Administrator | -- Geoffrey Chaucer
> ian@caliban.org |
> http://www.c... |
> |
>
>
> --
> Este correo esta libre de virus!
>


--
Este correo esta libre de virus!



Austin Ziegler

2/25/2005 8:22:00 PM

0

On Sat, 26 Feb 2005 05:15:49 +0900, Marcelo Paniagua
<paniagua@pcmxl.com.mx> wrote:
> Do anyone know about a library capable of generating a printable report?

Why, yes.

PDF::Writer.

But wait -- there's a major release coming out in the next couple of
weeks; I don't think that I'm going to make my original target date of
1 March, but it shouldn't be too much longer after that.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Charles Mills

2/25/2005 10:02:00 PM

0

Ian Macdonald wrote:
> Hello,
>
> I recently took over the maintenance of the Ruby/LDAP library and am
> stuck on interpreting the following line:
>
> tmp = rb_assoc_new (op, rb_ary_new ());
>
> I can't find an explanation of rb_assoc_new() anywhere. It's used all
> over the Ruby source code and yet I still can't figure what's going
on.
>
> I know that rb_ary_new() makes a new array, which is presumably being
> associated with tmp, but what does op have to do with it?
>
(...)
> Is this just a convenient way to instantiate a two element array?
>
This seems to be the most common use. Perhaps in the future it may
have a different meaning (if there was some kind of Assoc Class..??
like described here:
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-... ).

-Charlie

Marcelo (PC)

2/26/2005 12:57:00 AM

0

Thanks! Checked the units and they seems great.. Will test them on
weekend..

See you
Marcelo
----- Original Message -----
From: "Austin Ziegler" <halostatue@gmail.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Friday, February 25, 2005 12:22 PM
Subject: Re: Reports on Ruby


> On Sat, 26 Feb 2005 05:15:49 +0900, Marcelo Paniagua
> <paniagua@pcmxl.com.mx> wrote:
>> Do anyone know about a library capable of generating a printable report?
>
> Why, yes.
>
> PDF::Writer.
>
> But wait -- there's a major release coming out in the next couple of
> weeks; I don't think that I'm going to make my original target date of
> 1 March, but it shouldn't be too much longer after that.
>
> -austin
> --
> Austin Ziegler * halostatue@gmail.com
> * Alternate: austin@halostatue.ca
>
>
> --
> Este correo esta libre de virus!
>



--
Este correo esta libre de virus!



Yukihiro Matsumoto

2/26/2005 2:43:00 AM

0

Hi,

In message "Re: Purpose of rb_assoc_new()"
on Sat, 26 Feb 2005 05:12:11 +0900, Ian Macdonald <ian@caliban.org> writes:

|Is this just a convenient way to instantiate a two element array?

Yes.

matz.