[Pyrex] C-switch in Pyrex?
Alexander Belchenko
bialix at ukr.net
Fri Nov 2 06:19:33 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Bradshaw пишет:
> There have been a couple of times when I would've really liked a switch
> statement too, but there are a couple issues. Would switch statements
> fall through (as in C)? Would we require the cases to be ints? What about
>
> http://www.python.org/dev/peps/pep-3103/
>
> or some future Python proposal? Is it just for optimization reasons that
> you don't want to do a if-elif chain?
IMO, in Python/Pyrex switch statements never should fall through, because
it's breaks block behavior of Python, and using fall through in C-programs
is bad practice.
I'm thinking about C integer (from [unsigned] char to long) variable in switch,
and therefore cases also should be integer.
I like the PEP-3103. It's almost what I need.
Alexander
>
> -Robert
>
>
> On Oct 31, 2007, at 10:02 AM, Alexander Belchenko wrote:
>
> Hi,
>
> Is there any way to use switch construct in Pyrex, or to force it's
> generation in C-output?
> I dreaming about construct in Pyrex like:
>
> switch c_int_var:
> case 1:
> do_something()
> case 2:
> do_another_thing()
> default:
> default_action()
>
> (I apologize if this is the stupid question or it was discussed before.)
>
> Alexander
>>
>>
_______________________________________________
Pyrex mailing list
Pyrex at lists.copyleft.no
http://lists.copyleft.no/mailman/listinfo/pyrex
> ------------------------------------------------------------------------
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHKrNlzYr338mxwCURAvw/AJ47OKYgh+7mV0lXUFb0rSemAlU46wCfVhiD
nRDZHD5cKWhIAj68jnDJ8h4=
=AuYU
-----END PGP SIGNATURE-----
More information about the Pyrex
mailing list