feyd wrote:Hockey wrote:Perhaps, but PHP supports various CRT style functions, which should be used over concatenation operator anyways (sprintf and company) so they could do away with the '.' operator as concatenation and use it for member access instead.
sprintf et al are completely
impractical for most string operations in this language. Why do you think C++ added the String class and Java natively has a String class which is always included?
Hockey wrote:Of course, you realize that is a joke? Apparently I have to make this clear because many of you seem to think I am serious or that unpractical.

How could we possibly know you are joking? Many-a-time have you posted of similar outlandish, neigh impossible, ideas and were totally serious. If you need your memory jogged, how about the time you wanted to create and thereby impose a coding style. I'd say that's pretty similar in the "it won't happen, ever" scenario that you're fairly well known for. Whether that's a bad or good thing, hard to say.

I'm curious why they are impractical? I personally prefer sprintf over string concatenation operators. For starters I imagine it's faster than relying on:
a) String interpolation
b) The parser/interpreter to join strings togather
Just because C++ (more specifically MFC) has a CString with the '+' operator overloaded doesn't mean it's practical or useful. In fact if you look into the source of MFC and the usage of CString I'm willing to bet most uses avoid that and instead opt for sprintf equivelants. Sure there are times perhaps when:
Might be more "handy" than:
Code: Select all
$str = sprintf('%s%s%s%s', 'this', 'is', 'a', 'string');
But I wouldn't consider it more practical. If anything its less practical, because anyone coming from C/C++ would immediately recognize and feel comfortable with sprintf and possibly lost at the sight of a '.' acting as concatenation. That, and using sprintf is far more flexible and powerful and should be used when appropriate instead of hacking togather strings using operaters and PHP's string interpolation...
Whatever man, personal choice, thats fine. But to claim one is more or less practical without providing practical examples indicating where one excels over the other, is like calling a Goose a Duck when it's actually a Swan.
As for Java. Because *everything* is an object. You mean to tell me Java string classes don't have a Format or Sprintf or similar method as part of that class API? It relies solely on an operator to provide concatenation?
JCart I had a good one, but it slipped.
Edit: strict coding styles actually do offer practical advantages. Self describing code, consistency and not to mention variables, etc which follow convention make for easy times in developing tools to auto-extract details about a software system.
Top quality software goes far beyond MVC or MVP and design patterns and/or object practices and principles. I like having applications with near perfect coding styles, comments, architecture, file structure, core functionality, documentation, etc, etc, etc...maybe thats just me.
Cheers
