[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: #define alternative for Ruby

SonOfLilit

3/11/2007 10:51:00 AM

Use the P4 preprocessor on your scripts :P You'll get #define EXACTLY.

No, but seriously - text substitute macros are awful. There's a good
reason that Matz didn't offer them in Ruby.

If you want real macros, there's a sort of a way to do it with
ParseTree, but it's kind of complicated AFAIK (never tried).

Tell us what you want to do and we'll probably find a way to do it
without the awful #define.


Aur


Check http://rubymentor.ruby...

On 3/11/07, Michael Strelnikov <michaelst@gmail.com> wrote:
> Hello all,
>
> Does Ruby have something like "#define" for C/C++? Especially with
> arguments like "#define foo(x) (something_done_with_x(x))".
>
> Please don't say that "def" do the same. It doesn't.
>
> Thanks,
> Michael
>

5 Answers

Rick DeNatale

3/11/2007 10:04:00 PM

0

On 3/11/07, SonOfLilit <sonoflilit@gmail.com> wrote:
> Use the P4 preprocessor on your scripts :P You'll get #define EXACTLY.
>
> No, but seriously - text substitute macros are awful. There's a good
> reason that Matz didn't offer them in Ruby.

There's also the interesting problem of what the semantics of changing
a text macro in a dynamically compiled language like ruby. Let's say
you use a macro expansion in a method, and then later change the
macro. Do the methods which use that macro then need to be
re-compiled? What if you introduce a new macro that has the same name
as a non-macro name.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

Mike

3/12/2007 12:52:00 AM

0

On Mar 12, 9:03 am, "Rick DeNatale" <rick.denat...@gmail.com> wrote:
> On 3/11/07, SonOfLilit <sonofli...@gmail.com> wrote:
>
> > Use the P4 preprocessor on your scripts :P You'll get #define EXACTLY.
>
> > No, but seriously - text substitute macros are awful. There's a good
> > reason that Matz didn't offer them in Ruby.
>
> There's also the interesting problem of what the semantics of changing
> a text macro in a dynamically compiled language like ruby. Let's say
> you use a macro expansion in a method, and then later change the
> macro. Do the methods which use that macro then need to be
> re-compiled? What if you introduce a new macro that has the same name
> as a non-macro name.
>
> --
> Rick DeNatale
>
> My blog on Rubyhttp://talklikeaduck.denh...

I agree there are some semantic problems. But there are huge
advantages as well.
I'd prefer for have some warning about redefinitions.

Kevin Cunningham

1/11/2011 7:40:00 PM

0

On Jan 11, 11:26 am, The PHANTOM <hoofhearte...@yahoo.com> wrote:
> On Jan 11, 9:06 am, Ramon F Herrera <ra...@conexus.net> wrote:
>
>
>
>
>
>
>
>
>
> > On Jan 11, 1:34 am, Tracey12 <tracey12em...@gmail.com> wrote:
>
> > > I've watched Sarah Palin for hours by now in many different interviews
> > > on TV.
> > > I cannot figure out what it is about this very nice person that
> > > inspires such hate!
>
> > > The radical democrats literally hate Sarah!  They've even gone so far
> > > as to blame her for he AZ shooting!   HOW can they make that work?
>
> > > Sarah appears to be nothing more and nothing less than a smart woman
> > > who loves America and her nice family.  She loves life and liberty and
> > > appears to want to help navigate America away from the authoritarian
> > > ways of the radical left so that we are all free persons.
>
> > > For some odd reason, except for her values, and or her Christianity,
> > > the left has no reason to hate her.
>
> > > WHY?
>
> > No democrat hates Sarah! That would be absurd!
>
> > Our worse fear is that she will self-implode too early (sort of
> > premature ejaculation). We liberals (socially only in my case) pray
> > that she endures until the last possible minute. She is a God-sent
> > gift to Obama and the democrats.
>
> > Run, Sarah, run!!!
>
> > -Ramon- Hide quoted text -
>
> > - Show quoted text -
>
> Is that why so many "liberals" are calling for her murder??

No liberal wants to kill any one, much less Palin.

We want her to run for president. That will end the repug
party.........

The PHANTOM

1/11/2011 7:50:00 PM

0

On Jan 11, 1:40 pm, Kevin Cunningham <sms...@mindspring.com> wrote:
> On Jan 11, 11:26 am, The PHANTOM <hoofhearte...@yahoo.com> wrote:
>
>
>
>
>
> > On Jan 11, 9:06 am, Ramon F Herrera <ra...@conexus.net> wrote:
>
> > > On Jan 11, 1:34 am, Tracey12 <tracey12em...@gmail.com> wrote:
>
> > > > I've watched Sarah Palin for hours by now in many different interviews
> > > > on TV.
> > > > I cannot figure out what it is about this very nice person that
> > > > inspires such hate!
>
> > > > The radical democrats literally hate Sarah!  They've even gone so far
> > > > as to blame her for he AZ shooting!   HOW can they make that work?
>
> > > > Sarah appears to be nothing more and nothing less than a smart woman
> > > > who loves America and her nice family.  She loves life and liberty and
> > > > appears to want to help navigate America away from the authoritarian
> > > > ways of the radical left so that we are all free persons.
>
> > > > For some odd reason, except for her values, and or her Christianity,
> > > > the left has no reason to hate her.
>
> > > > WHY?
>
> > > No democrat hates Sarah! That would be absurd!
>
> > > Our worse fear is that she will self-implode too early (sort of
> > > premature ejaculation). We liberals (socially only in my case) pray
> > > that she endures until the last possible minute. She is a God-sent
> > > gift to Obama and the democrats.
>
> > > Run, Sarah, run!!!
>
> > > -Ramon- Hide quoted text -
>
> > > - Show quoted text -
>
> > Is that why so many "liberals" are calling for her murder??
>
> No liberal wants to kill any one, much less Palin.
>
> We want her to run for president.  That will end the repug
> party.........- Hide quoted text -
>
> - Show quoted text -

Then why are you crazy motherfuckers calling for her execution?? WTF
is WRONG with you people ??!!

Dacato

1/11/2011 9:07:00 PM

0

On Jan 11, 10:26 am, The PHANTOM <hoofhearte...@yahoo.com> wrote:
> On Jan 11, 9:06 am, Ramon F Herrera <ra...@conexus.net> wrote:
>
>
>
>
>
> > On Jan 11, 1:34 am, Tracey12 <tracey12em...@gmail.com> wrote:
>
> > > I've watched Sarah Palin for hours by now in many different interviews
> > > on TV.
> > > I cannot figure out what it is about this very nice person that
> > > inspires such hate!
>
> > > The radical democrats literally hate Sarah!  They've even gone so far
> > > as to blame her for he AZ shooting!   HOW can they make that work?
>
> > > Sarah appears to be nothing more and nothing less than a smart woman
> > > who loves America and her nice family.  She loves life and liberty and
> > > appears to want to help navigate America away from the authoritarian
> > > ways of the radical left so that we are all free persons.
>
> > > For some odd reason, except for her values, and or her Christianity,
> > > the left has no reason to hate her.
>
> > > WHY?
>
> > No democrat hates Sarah! That would be absurd!
>
> > Our worse fear is that she will self-implode too early (sort of
> > premature ejaculation). We liberals (socially only in my case) pray
> > that she endures until the last possible minute. She is a God-sent
> > gift to Obama and the democrats.
>
> > Run, Sarah, run!!!
>
> > -Ramon- Hide quoted text -
>
> > - Show quoted text -
>
> Is that why so many "liberals" are calling for her murder??- Hide quoted text -
>
> - Show quoted text -

Cite please!