|
From: Barry S. <ba...@ba...> - 2015-09-18 08:47:14
|
Thanks for the feedback. I hope to have something to test next week.
Barry
> On 12 Sep 2015, at 20:59, Vivian De Smedt <vd...@gm...> wrote:
>
> Hi Barry,
>
> I understand and share your concerns, backward compatibility is important.
>
> Personally I prefer you second solution based on Py::ObjectAllowNull.
> I think construct object that could accept NULL should be rare and easily identifiable in a code.
>
> Best regards,
> Vivian.
>
>
>
>
> Le mar. 1 sept. 2015 à 18:13, Vivian De Smedt <vd...@gm... <mailto:vd...@gm...>> a écrit :
> Hi Barry,
>
> Thanks for your detailed analysis. I'm currently in Holidays in Scotland. I'll read your mail carefully next week.
>
> Best regards,
> Vivian
>
>
> On Tuesday, September 1, 2015, Barry Scott <ba...@ba... <mailto:ba...@ba...>> wrote:
> Vivian,
>
> I think I have 2 patches to work on from you.
>
> * Add the ability to react to PySequence_DelItem()
> * Make py2 and py3 handling of Py::Object( NULL ) consistent
>
> I was worried that someone might be relying on being able to use
> detect the NULL value in sequence_ass_item(). Given that Py2 cannot
> call the sequence_ass_item() because of the NULL check. I will take
> your patch to all sequence_ass_del(). It is a nice API.
>
> My feeling that it should be possible to create Py::Object from NULL.
> But there are clearly cases when its not a reasonable thing to do.
>
> I wondering what the API should look like.
>
> Adding another bool to the c’tor is possible.
>
> Py::Object( PyObject *, bool owner, bool accept_null );
> Then have validate() change behaviour on accept_null.
>
> Or use two classes:
>
> * a Py::Object which Allows Null
> * a Py::Object which Disallows Null
>
> Take the current Py::Object and rename to Py::ObjectAllowNull.
>
> class Py::ObjectAllowNull;
> with validate() { return true; }
> add new predicate hasObject() { return p != NULL; }
>
> Then derive Py::Object from Py::ObjectAllowNull.
>
> class Py::Object(Py::ObjectALllowNull);
> with validate() { return p!=NULL; }
>
> All the existing classes like Py::Int, Py::List derive from Py::Object that rejects Null.
>
> With the accept_null c’tor it would be possible to have a Py::Int that accepts NULL.
>
> Any thoughts?
>
> Barry
>
|