Chuck Blake wrote:
> E.g., define max_tmpl.pxi:
> 
>     TYPE def NAMES(x)(TYPE a, TYPE b):
>         return a > b if a else b
> 
> Then a client can simply
> 
>     include "max_tmpl.pxi" TYPE="int", NAMES(x)=("int_" + x)
> 
> and just use the defined function int_max() as they like...
> 
> If something like NAMES() can refer to its outer definitions in its own,
> you can do a nested hierarchy of namespaces:
> 
>     include "max_tmpl.pxi" TYPE="int", NAMES(x)=NAMES("int_" + x)
> 

This made my mind up: I do not think we should reinvent the wheel here.

Rather than focusing on improving the DEF, IF and include statements, we 
should look for an existing macro language for our uses (and rather 
deprecate DEF, IF and include than make them more powerful).

We could even find a preprocessing language that is made "official", 
distributed with Cython and automatically invoked and all (and even 
modify it to take care of IF, DEF and include as they are today and 
refactor this out of core Cython) -- I'm just saying that I'd like these 
kind of low-level string manipulations to stay out the Cython compiler 
core and use an existing package (any existing package) for this. The 
Cython compiler can then be devoted to the higher-level constructs.

C has a clear seperation between the language and the preprocessor, with 
great success.

(Still, anything which is already implemented is, well, already 
implemented and "free" in some sense.).

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to