Re: Strict types



Treefrog wrote:
Hi All,

For a while now I've been wishing PHP had (at least the option to
enable) strict types. It would help a massive amount in BIG
applications, and maybe start to taper the millions of lines of crap
code that's out there.

PHP is a great language, but the masses of incompetant coders out there
do absolutely nothing to help the language grow. I know we all have to
start somewhere, so please don't think I'm being eliteist, because I'm
not, but something has to be done to try to fix the mess out there.

Surely the contractors on here have witnessed this, or is it just me?

What is everyone else's opinion?

Cheers,

T'rog


Hi, T'rog,

Well, one of the big attractions to PHP is the lack of strict typing. You don't have to go through all the overhead of declaring variable types (or even variables unless they are class members). Getting rid of the "administrative overhead" allows you to concentrate on the problem.

You can write good code in any language (except maybe COBOL :-) ). You can write bad code in any language - including Java and C++. However, IMHO, strict typing does in general get you to write "better" code.

I think a good compromise between old and new would be a "strict" flag. It could be set in the php.ini file or .htaccess (on Apache, if allowed). Perhaps it could even be a parse-time command (ini_set isn't executed until too late), similar to C/C++'s pragma statement. The last would allow someone to convert a website one file at a time to strict. Then when everything's changed, change the php.ini file, or, if on a shared server, at a statement to .htaccess.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • exporting Environment variables from mod_perl
    ... Normally the environment will propagate to processes called via ... use strict; ... open T, "php test.php|"; ... The PHP script you attempted to run was not found on this server. ...
    (comp.lang.perl.modules)
  • "use strict"?
    ... Is there anything in PHP like the "use strict" of Perl which requires ... misspellings in variable names. ...
    (alt.php)
  • Re: Strict types
    ... enable) strict types. ... PHP is a scripting language. ... which has strict typing and encourages ...
    (comp.lang.php)
  • Re: equivalent to use strict in php?
    ... >is there any equivalent of perl's use strict; ... because PHP doesn't have lexically scoped variables in the same was as ... Perl, nor does it have any way of defining variables other than through the ...
    (comp.lang.php)
  • Re: Beyond CL?
    ... > a language definition, which has to do with whether how far away the valid ... loose, throwing an exception is strict. ... Loose programs seem necessarily dense because there are fewer invalid ...
    (comp.lang.lisp)