[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: object reference handle (like perl's reference to scalar

Eric Mahurin

5/6/2005 4:29:00 PM

Nope. You need a dereferencing operator/method just like C.
Otherwise you'd be assigning to the reference itself rather
than what it points to. Here would be the equivalents to C:

C Ruby/ref
---- --------
p=&a p=ref{:a}
*p p[]
*p= p[]=

You can reference/dereference just about anything with this
ruby scheme instead of just a place in memory like you do in C.

Actually, thinking about it more, I'm going to pull this
reference API into another project I'm working on: "cursor". A
Cursor is what some also call an "external iterator" (see
Iterator on rubyforge), but mine is going to be more general.
With this class, you'll be able to do this type of thing to
correlate even more to the C pointer:

C Ruby
--------------- -----
int a[]={0,1,2} a=[0,1,2] # a is already a pointer in C
int *p = a p = Cursor::Indexable(a)
*p p[]
*p= p[]=
*(++p) p.succ![]
*(++p)= p.succ![]=

So, a Cursor is a Reference that you can move around in a data
structure (anything sequential - even an IO). Just like you
can move a pointer around in a data structure to
reference/dereference different elements.

I haven't made and uploaded a "reference" gem yet (or
"cursor"). All I've done is reserved the name on rubyforge.
Feel free to play around with what I previously posted and
comment.

p.s. my middle initial is W and I'm 6'2"

> is it possible to remove the [] appendix? :-)
>
> something like,
>
> hacker = ["bot","pen","a",5,10]
>
> name = hacker.ref[0..2]
> fname = name.ref[0]
> lname = name.ref[1]
> mname = name.ref[2]
>
> height = hacker.ref[3..4]
> feet = height.ref[1]
> inches = height.ref[2]
>
> fname = "Eric"
> lname = "Mahurin"
> mname = "?"
>
> feet = 6
> inches = 5
>
> name #=> ["Eric","Mahurin","?"]
> height #=> [6,5]
> hacker #=> ["Eric","Mahurin","?",6,5]
>
>
> Possible?
>
> btw, i cannot download your reference gem...
>
> thanks and kind regards -botp




__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.co...


3 Answers

Raymond C. Fischer, 90 Hunt Way, Campbell, CA 95008; 408-374-1969

11/9/2011 2:38:00 AM

0

Summary: Ray is a classic usenet zoo monkey. Liars, once they have
been exposed, frequently revert to behavior most similar to a zoo
monkey who sits in the cage throwing feces at passersby but saying
nothing of value. Note that when you reply to a Proven Liar you
encourage them to continue lying.

Raymond C. Fischer (54)
(Louise Fischer)
90 Hunt Way
Campbell, CA 95008
408-374-1969

[][][][][][]
The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

[Courtesy of Buster Norris]

On 19 Jul 2011 06:29:00 GMT, rfischer@sonic.net (Ray Fischer) wrote:
>> Bush didn't
>>sell anything to anyone.
>He doubled the national debt.

LIAR!!!!!!!!!!!!!!!!!

http://en.wikipedia.org/wiki/National_debt_by_U.S._presiden...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

Raymond C. Fischer, 90 Hunt Way, Campbell, CA 95008; 408-374-1969

11/12/2011 2:58:00 AM

0

Summary: Ray is a classic usenet zoo monkey. Liars, once they have
been exposed, frequently revert to behavior most similar to a zoo
monkey who sits in the cage throwing feces at passersby but saying
nothing of value. Note that when you reply to a Proven Liar you
encourage them to continue lying.

Raymond C. Fischer (54)
(Louise Fischer)
90 Hunt Way
Campbell, CA 95008
408-374-1969

[][][][][][]
The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

[Courtesy of Buster Norris]

On 18 Aug 2011 17:53:17 GMT, rfischer@sonic.net (Ray Fischer) wrote:
>pyjamarama <pyjamarama79@gmail.com> wrote:
>>Since his academic records are under seal,
>It takes a fascist to insist that all of a person's records, even
>those that have nothing to do with government service, should be made
>public.

Like fascist lib friends at the Washington Post??????????????

"Confidential college transcripts and test scores obtained by the
Washington Post reveal that neither presidential candidate, George W.
Bush nor Al Gore, were shining students during their college days at
Yale and Harvard, respectively."
http://www.insidepolitics.org/heard/heard...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

Blackwater

11/12/2011 4:35:00 AM

0

The GOP is doomed.

The Dems are dooomed.

And if we can't find alternatives to
them, quickly, then WE are also doomed.