[Cython] Fused types syntax

Robert Bradshaw robertwb at math.washington.edu
Thu Jun 2 22:21:00 CEST 2011


On Thu, Jun 2, 2011 at 1:07 PM, mark florisson
<markflorisson88 at gmail.com> wrote:
> On 2 June 2011 18:39, Robert Bradshaw <robertwb at math.washington.edu> wrote:
>> In looking at merging fused types, it's time to nail down the syntax.
>> The current implementation is
>>
>>    ctypedef cython.fused_type(list, dict, object) fused_t
>>
>> This requires an addition to the grammer to allow the "call" syntax in
>> a type declaration, as well as special casing to make it allowed only
>> in a typedef. What about
>>
>>    cython.fused_type[list, dict, object].
>>
>> One advantage is that indexing is already valid in type declarations,
>> and its the typical syntax for parameterized types. Thoughts? Any
>> other ideas?
>
> I like it, so I'll give another +1. Changing wouldn't be too much work anyways.
>
>> - Robert
>>
>>
>> P.S. Anyone remember buffers and C++ templated types are dissallowed
>> as typedefs?
>
> Yes, there's even a test for it: tests/errors/buffertypedef_T117.pyx
> (http://trac.cython.org/cython_trac/ticket/117). But it looks more
> like an easy fix than a feature.

I could see how for buffers it would require at bit more work, but for
C++ types that shouldn't be a problem. In particular, I'm looking at
https://github.com/cython/cython/blob/master/Cython/Compiler/Parsing.py#L2615

- Robert


More information about the cython-devel mailing list