--- Neil Watkiss <[EMAIL PROTECTED]> wrote:
> [...]
> But #define'd constants would be a useful feature, and will probably
> work their way into Inline::* some day soon.
Hmm...
For Perl-only constants you can just say "sub FOUR { 4 }", right?
Doesn't the optimizer already just sub in the value?
#define's work fine in Inline::C, but it hadn't occurred to me to
export the actual constant. You could write a "class" method that would
return the constant value, but the class overhead would seem to make it
a moot point.
Neil, just as a comment, I'd say that if you decide to parse #defines
into Perl-available constants, you'd likely run into some nasty
situations with complex definitions. Here in our shop we actually have
a program which uses embedded struct arrays seven deep for quick access
to data that's been loaded, and the author wrote two defines just to
keep from typing a line and a half of code to access a variable. He
says something like THE DATA(x), and it gets parsed out into one big
lookup.
For "#define FOUR 4", you could just put "sub FOUR { 4 }" in the
package namespace, but for anything more elaborate you may be asking
for a headache. Macros and constants are both done with #define.....
> > On that topic, how about an 'h2inline'? Would be extremely handy
> > for writing perl modules to wrap C libraries - parse a header, and
> > emit a <module>.pm file full of Inline::c and Inline::Struct, plus
> > lots of boilerplate POD. Optionally expose functions, structs,
> > enums, #defines, constants, etc.
>
> This is interesting. I never thought of that. I've always been
> thinking of someone sitting in Perl, wanting to get out. I never
> considered the poor souls in C, wanting to get in.
lol.... it is a neat concept.....
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/?.refer=text