From: "Brian F. Feldman" Date: 2001-07-23T03:26:43+09:00 Subject: [ruby-talk:18304] Re: NUM2LONG problem :) Dave Thomas wrote: > "Brian F. Feldman" writes: > > > The definition should be trivially fixed, nonetheless... the rules > > I've learned for the implementation of macros have been: > > > * all parameters should be evaluated only once. > > which would rule out 'MIN' and 'MAX' in the standard headers. Yeah, macros which are not dependent on any specific type or "class" of parameters are not easy to do at all without evaluating arguments multiple times. That's the exception, rather than the rule, though. > However, I _do_ believe that if it can be done across all the target > environments, this is a good candidate for an inline function. An inline can pose problems for some compilers, and isn't any more dynamic than a macro, so I'd probably recommend against inlines in something meant to be as portable as Ruby is. Of course, macros have variable naming issues (much like Ruby's blocks not allowing variable shadowing :), which is why then you have to require a prefix uniquifying variables used in macros so that conflicts don't occur there. Type checking can be a considerable advantage of inline functions, of course. One possibility, realistically, is that functions can be declared in headers as just static instead of a macro or a static inline function; compilers which generally would be intelligent enough to understand an inline directive should work fine without one and inline a function in any cases you'd have wanted it inlined, anyway. Food for thought... -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------'