Re: [Discussion] FFI in PHP
| From: | Michael Wallner | Date: | Wed, 08 Feb 2017 14:10:10 +0000 |
| Subject: | Re: [Discussion] FFI in PHP | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98263@lists.php.net to get a copy of this message | ||
On 08/02/17 14:54, Michał Brzuchalski wrote:
> 2017-02-08 12:51 GMT+01:00 Michael Wallner <mike@php.net>:
>
>>
>> ```
>> // https://github.com/m6w6/ext-psi#implementations
>> function math\add(int $a, int $b) : int {
>> let a = intval($a);
>> let b = intval($b);
>> return to_int(add);
>> }
>> ```
>>
>
> What is the purpose of
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
intval call if both variables were
> declared as int
> already?
> Also what to_int stands for if we already declared int return type?
>
While those type casts might seem superfluous for simple functions,
marshalling between PHP and C quickly becomes complicated and requiring
explicit casts just reduces the possibility of tripping points even if
the types match on both sides. Omitting them wouldn't change anything
internally, but just bloat the parser.
--
Regards,
Mike
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc