Re: New notation for easy use/reading
| From: | Stig Bakken | Date: | Wed, 22 Sep 1999 09:28:25 +0000 |
| Subject: | Re: New notation for easy use/reading | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-11189@lists.php.net to get a copy of this message | ||
On Wed, 22 Sep 1999, JUNG, SungYoung wrote:
|
| Is string concatenator necessary? How about C (or C++ ) style string
| concatenation?
|
| example in C or C++ :
|
| printf("string1" "string2" "\n");
|
| result :
|
| string1string2
PHP does not have the concept of a preprocessor like cpp. Concatenating
constant strings is a task for the Zend optimizer.
| It is easy to implement it to php since it already works like above inside
| of string
|
| in php :
|
| $str1 = "string1";
| $str2 = "string2";
| echo "$str1$str2\n";
|
| result :
|
| string1string2
|
| There is no concatenation operation inside of string even in php.
| So how about remove string concatenator "." all case in php next version?
| Then string operation will be looks better including the case of function
| call and string constant
|
| in original php :
| define ("nic", "Rabbit");
| $str1 = "Test".$str1.$str2 ;
| $str = $this->name.":".strtlower($str1).nic."\n";
|
| in new php :
| define ("nic", "Rabbit");
| $str1 = "Test" $str1 $str2 ;
| $str = $this->name ":" strtlower($str1) nic "\n";
I don't know what makes you think we can just change the language like
this. Do you seriously think that we should remove one of the most
frequently used operators because the code looks much nicer without it?
One of PHP's goals is currently to be as backwards compatible as possible,
which rules removing the string concatenator out.
|
| "JUNG, SungYoung" <syjung@lgcit.com>wrote in news:7s7q16$e80$1@www.php.net
| >
| > An example code in php
| > class a{
| > var $m;
| > function a( $b,$c)
| > {
| > $this->m = $b.c.$this->m;
| > return $this->m;
| > }
| >}
|
| Finally, it will be look like this
|
| class a{
| var $m;
| a( $b,$c)
| {
| $.m = $b $c $.m; // omitted "this" pointer and string
| concatenator "."
| return $.m;
| }
| }
We may or may not agree on what is the most pretty or readable syntax, but
PHP's is the way it is, and there is no way we can just go ahead and
change that now. And given that we want to maintain backwards
compatibility, we can't just go ahead and change it in the future either.
People don't hear me saying this too often, but if it works, why change
it? Once a syntax is defined and established, it should not change unless
there are _really_ good reasons for it, among which aestethics or
someone's personal optinion on readability do not qualify.
- Stig