diff options
author | nbruin <nbruin@cecm.sfu.ca> | 2014-11-20 23:46:40 -0800 |
---|---|---|
committer | nbruin <nbruin@cecm.sfu.ca> | 2014-11-20 23:46:40 -0800 |
commit | 9431c66117818e6d948d7a834b686724463abef7 (patch) | |
tree | f6f0e233ba475a89001c8a041a0cec269e5d16aa | |
parent | 4d624b9f24a1bd6afbf4bce42f4365b4d9c5813a (diff) | |
download | cython-9431c66117818e6d948d7a834b686724463abef7.tar.gz |
Document implicit return value behaviour of cdef functions.
--HG--
extra : transplant_source : %FB/K%D2%ED5%9EN%94%139%07A%ECq%1C%C7%E8%D7%0C
-rw-r--r-- | docs/src/userguide/language_basics.rst | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/src/userguide/language_basics.rst b/docs/src/userguide/language_basics.rst index e1a950d7f..534fbf60f 100644 --- a/docs/src/userguide/language_basics.rst +++ b/docs/src/userguide/language_basics.rst @@ -160,6 +160,10 @@ with string attributes if they are to be used after the function returns. C functions, on the other hand, can have parameters of any type, since they're passed in directly using a normal C function call. +Functions declared using :keyword:`cdef`, like Python functions, will return a :keyword:`False` +value when execution leaves the function body without an explicit return value. This is in +contrast to C/C++, which leaves the return value undefined. + A more complete comparison of the pros and cons of these different method types can be found at :ref:`early-binding-for-speed`. @@ -216,7 +220,11 @@ returns ``-1``, an exception will be assumed to have occurred and will be propagated. When you declare an exception value for a function, you should never -explicitly return that value. If all possible return values are legal and you +explicitly or implicitly return that value. In particular, if the exceptional return value +is a ``False`` value, then you should ensure the function will never terminate via an implicit +or empty return. + +If all possible return values are legal and you can't reserve one entirely for signalling errors, you can use an alternative form of exception value declaration:: |