Author skrah
Recipients Amaury.Forgeot.d'Arc, Arfrever, Jim.Jewett, Ramchandra Apte, amaury.forgeotdarc, asvetlov, benjamin.peterson, casevh, ced, eric.smith, eric.snow, haypo, jjconti, lemburg, mark.dickinson, pitrou, python-dev, rhettinger, skrah
Date 2012-03-27.18:57:31
SpamBayes Score 1.16229e-07
Marked as misclassified No
Message-id <1332874653.03.0.913919121944.issue7652@psf.upfronthosting.co.za>
In-reply-to
Content
I have a couple of questions about the proposed capsule C API. In order to
be useful, it should be possible to set temporary contexts and pass them
to functions. For example, PyDec_Add could look like:

   PyDec_Add(PyObject *a, PyObject *b, PyObject *context);


To stay sane, either access macros or access functions to the context would
need to be provided:

  CTX(workcontext)->prec = 100;
  PyDec_SetPrec(workcontext, 100);
  PyDecContext_SetPrec(workcontext, 100);


Probably flags would need to be checked at some point:

  if (CTX(workcontext)->status & MPD_Underflow)
  if (PyDec_GetStatus(workcontext) & MPD_Underflow)
  if (PyDecContext_GetStatus(workcontext) & MPD_Underflow)



I wonder if users would not be better off if libmpdec functions and
access macros were exposed instead. The big advantage is that errors
(even malloc errors) propagate in the form of NaNs, so it is not
necessary to do repeated error checking.

Also, I find things like (status & MPD_Underflow) more readable than
the alternatives above.


I've attached a short (fake) example to demonstrate what I mean.
History
Date User Action Args
2012-03-27 18:57:33skrahsetrecipients: + skrah, lemburg, rhettinger, amaury.forgeotdarc, mark.dickinson, pitrou, haypo, casevh, eric.smith, benjamin.peterson, jjconti, Arfrever, ced, asvetlov, Amaury.Forgeot.d'Arc, python-dev, eric.snow, Ramchandra Apte, Jim.Jewett
2012-03-27 18:57:33skrahsetmessageid: <1332874653.03.0.913919121944.issue7652@psf.upfronthosting.co.za>
2012-03-27 18:57:32skrahlinkissue7652 messages
2012-03-27 18:57:32skrahcreate