Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96236 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94300 invoked from network); 4 Oct 2016 17:57:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2016 17:57:08 -0000 Authentication-Results: pb1.pair.com header.from=php-mailing-list@lool.fr; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php-mailing-list@lool.fr; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lool.fr from 212.27.42.3 cause and error) X-PHP-List-Original-Sender: php-mailing-list@lool.fr X-Host-Fingerprint: 212.27.42.3 smtp3-g21.free.fr Received: from [212.27.42.3] ([212.27.42.3:42979] helo=smtp3-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/3A-06241-F6DE3F75 for ; Tue, 04 Oct 2016 13:57:05 -0400 Received: from daffy (unknown [82.242.106.155]) by smtp3-g21.free.fr (Postfix) with ESMTP id B537713F8B1; Tue, 4 Oct 2016 19:57:00 +0200 (CEST) To: "'PHP internals list'" Cc: =?utf-8?Q?'Micha=C5=82_Brzuchalski'?= , "'Bob Weinand'" , =?utf-8?Q?'Lauri_Kentt=C3=A4'?= , "'Thomas Hruska'" References: <004101d21e33$124edf90$36ec9eb0$@lool.fr> <3bc3c57695cdf6207724db47e6dbbbab@koti.fimnet.fi> <000401d21e4c$3e71d140$bb5573c0$@lool.fr> In-Reply-To: Date: Tue, 4 Oct 2016 19:56:57 +0200 Message-ID: <00ae01d21e68$b2df5ae0$189e10a0$@lool.fr> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00AF_01D21E79.767215F0" X-Mailer: Microsoft Outlook 14.0 Content-Language: fr Thread-Index: AQJOD5dBaeD89DDq2Wc7/IAgKG1G6gGIOw3VApCMc8oB3SCEYQNzcGKQn1Vg3AA= Subject: RE: [PHP-DEV] Feature Request: inline pseudo-instruction From: php-mailing-list@lool.fr ("Pascal KISSIAN") ------=_NextPart_000_00AF_01D21E79.767215F0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable =C2=AB tell me what you need, and I would tell you how to do without it = =C2=BB is a nonsense answer for me=E2=80=A6 =20 I just told you about one among several cases where I found the need for = such a feature. =20 I can also tell you, by example, of a specific grammar driven php writen = parser where about 100 functions have their 2 first lines and 3 ending = lines exactly the same=E2=80=A6 =20 Another use would be to have an =C2=AB inlined code =C2=BB containing = the begining of a loop structure, and another one the ending of that = loop structure=E2=80=A6. (that is no more possible with include in new php versions but it was = possible in older ones, not considering performance issues) =20 And don=E2=80=99t tell me that it is bad coding, or rewrote whole php = source code without macros before. As an example : ZEND_HASH_FOREACH_VAL and ZEND_HASH_FOREACH_END are very = usefull for php itself. =20 Why do not allow php to have such kind of functionnalities? =20 Before thinking about macros, the 1st little step, not so difficult to = implement, would be, according to me, to have an inline statement that = does the same as include, but at compile time instead of at = runtime=E2=80=A6 =20 And my only question is : =20 =E2=80=9CAm I the only people needing this kind of feature?=E2=80=9D =20 If I am the only one, just do as if I never posted to this forum, but if = many people think it could be usefull, perhaps it would make sense to = reconsider the question. =20 Best regards, Pascal KISSIAN =20 =20 =20 =20 De : Micha=C5=82 Brzuchalski [mailto:michal@brzuchalski.com]=20 Envoy=C3=A9 : mardi 4 octobre 2016 17:52 =C3=80 : Bob Weinand Cc : Pascal KISSIAN; PHP internals list Objet : Re: [PHP-DEV] Feature Request: inline pseudo-instruction =20 =20 =20 2016-10-04 17:39 GMT+02:00 Bob Weinand : > Am 4.10.2016 um 16:33 schrieb Pascal KISSIAN = : > >> -----Message d'origine----- >> De : Lauri Kentt=C3=A4 [mailto:lauri.kentta@gmail.com] >> Envoy=C3=A9 : mardi 4 octobre 2016 16:21 >> =C3=80 : Pascal KISSIAN >> Cc : internals@lists.php.net >> Objet : Re: [PHP-DEV] Feature Request: inline pseudo-instruction >> >> On 2016-10-04 14:33, Pascal KISSIAN wrote: >>> I have an application where a small file is included at multiple >>> places. >>> >>> The include is done about an average of 100.000 times . >> >> I'm just wondering if you have ever heard of functions? You really = should write a function, include it only once, and then simply call the = function instead of repeatedly >including the file. Calling a function = is a lot faster than including a file. >> >> -- >> Lauri Kentt=C3=A4 > > Function is not appropriate when the "inlined code" has to share 20-30 = local variables ... > Having a function with 30 args, or having to build and access an = array is not very efficient nor natural... > Local variables include 6 nested "for loop" indices and local = variables/arrays needed for the computing. =20 6-level nested loop and 20-30 local variables in scope has enought = complexity to refactor. This stuff definitelly needs refactor. I wouldn't allow any developer to commit such code, it woudn't pass code = review. There was time I also have such code but it wasn't maintainable, once = written was never beeing understood by any other developer. I think you should read about CleanCode -> = https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132= 350882 =20 Hey, why do you think are your includes so slow? Apart from the include itself (which in itself is fairly slow due to = filesystem access; or in case with opcache, at the very least copying = the op_array etc.), it does exactly this: building an array and = importing it into the included files scope. Also, 20-30 local variables? That sounds a bit like your code has way = too many responsibilities in one same place. Perhaps you should = restructure your code instead, but the way you describe it, no. If your code is so "hot", that also even function calls would be quite = significant then you should probably really inline your code there as a = perf optimization. Anyway, code with that many variables almost always = can meaningfully refactored. It is not the languages task to optimize insane code ... Bob =20 --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski brzuchalski.com =20 ------=_NextPart_000_00AF_01D21E79.767215F0--