Re: strict-api - Proposing a tool to check and enforce encapsulation
| From: | Bob Weinand | Date: | Sat, 12 Sep 2015 22:44:14 +0000 |
| Subject: | Re: strict-api - Proposing a tool to check and enforce encapsulation | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88168@lists.php.net to get a copy of this message | ||
> Am 08.09.2015 um 00:41 schrieb François Laupretre <francois@php.net>:
>
> Hi,
>
> I have written a follow-up to my previous 'zstrict' PR. It is now focused on a simple
> mechanism to detect API violations :
>
> https://github.com/php/php-src/pull/1508
>
> This version just implements the mechanism and applies it to the zend_string val/len/h
> elements. More details in the PR.
>
> Please comment first. Then, when we're OK on the feature, we may talk about the target
> version.
>
> Regards
>
> François
While I don't disagree with the idea of making accidental direct access harder, I see a
particular disadvantage for debugging.
Nobody will like to write "p fbc->op_array.filename->zstrict_field_zend_string_val"
(I hope I got it right?) just to figure out where the targeted op_array is located. [At least lldb
only shows one character of the value when just printing the zend_string, due to the struct hack...]
Now you may say macro? Well, honestly, I don't usually use macros (as ..gdbinit isn't
compatible with lldb and lldb is more stable than gdb on OS X)
While it brings a minor guarantee that the ZSTR_*() API is really used, it makes debugging much
harder; so I prefer to not merge this patch.
Thanks for your efforts here though!
Bob