[Pyrex] conditional compilation

Sam Rushing sam-pyrex at rushing.nightmare.com
Thu Mar 30 22:46:00 CEST 2006


On Wed, 2006-03-29 at 09:43 +0200, Stefan Behnel wrote:
> If we're talking language syntax, what about allowing the "const" qualifier
> instead of a "define" ? Then you could hand that to the C-compiler and it
> would see by its own what can be resolved at compile time. That should solve a
> lot of cases where your conditionals are used now without actually needing
> explicit conditionals.

One of the more challenging features is the ability to choose between
implementations of a method/function at run time:

if DEBUG:
  def fetch_thingy (arg0, arg1):
    ...
else:
  def fetch_thingy (arg0):
    ...

[yeah, this is contrived]

I can *kinda* imagine mapping this all the way down to #ifdef in C, but
it seems pretty difficult.  

Regardless, it'd be nice to have Pyrex know about constants.

> BTW: what is your "%import" doing?

It's only there so you can put modules into the compile-time namespace.
For example, the UNAME_SYSNAME symbol that's predefined in the patch
could be done by the user like this:

%import os
%define UNAME_SYSNAME os.uname()[0]

-Sam

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20060330/84cd447b/attachment.bin


More information about the Pyrex mailing list