Hi Larry,
On Tue, Feb 4, 2014 at 9:34 AM, Larry Garfield <[email protected]>wrote:
> On 2/3/14 1:57 PM, Yasuo Ohgaki wrote:
>
>> Hi Stas,
>>
>> On Tue, Feb 4, 2014 at 4:42 AM, Stas Malyshev <[email protected]
>> >wrote:
>>
>> There are many code out there checks if (!extention_loaded(foo'))
>>>>
>>> die('You
>>>
>>>> need foo'). This is waste of CPU resources once it is checked. These
>>>> requirements for scripts may be evaluated at compile time and script
>>>>
>>> runs a
>>>
>>>> little faster.
>>>>
>>>
>>> Managing requirements is a job for package manager, like composer, not
>>> language compiler, IMO.
>>>
>>
>>
>> I agree that good package manager should manage requirements. However,
>> once
>> code is installed, package manager will not check requirements. (Package
>> manager could be made to execute requirement checks at any time, though)
>> Therefore, there would be developers embed environmental checks to make
>> sure not to die with function not found, etc.
>>
>> In addition to this, there would be SCL for RHEL7 and there are some tools
>> like phpenv. Installing PHP does not have to be executing PHP. Even if
>> there is good package manager, compile time requirement check is nice to
>> have. It's nice to have and it's not must have, though.
>>
>> Regards,
>>
>
> I have to agree with Stas and Sara on this one. This is not the job of
> the language syntax. This is the package manager's job; once the code is
> installed (not compiled, installed), you shouldn't be changing your version
> anyway without knowing what you're doing / verifying on a test system
> anyway.
>
> If this were more like Javascript's "use strict", where it affected the
> parsing rules of that file, that would at least be useful (if potentially
> mind-bendingly painful for the engine; no I'm not suggesting we do that).
> But a shortcut for if (version_compare()) die; is not needed, and that
> would be a dumb way to go about implementing version requirements in the
> first place.
This assumption is not valid as I already wrote.
There will be SCL in RHEL7 and there are tools like phpenv.
Installing PHP does not have to be executing PHP.
Version and module requirement checks are popular and I
don't think it is dumb at all. It is dumb that if script didn't
work as it should be due to version mismatch, isn't it?
BTW, it is not a short cut of version check, but "elimination of
run time check overheads". Many people don't understand
what declare() is, it seems.
declare() is compiler directive, *NOT* a function. Thus it could
instruct what compiler should do at compile time. Since declare()
is compiler directive, compiler may omit byte code for declare
block. Therefore, run time overheads of declare block may be
eliminated with byte code cache.
Isn't checking requirements over and over a waste of resources?
Regards,
--
Yasuo Ohgaki
[email protected]