Re: PEAR CS poll
| From: | Justin Patrin | Date: | Fri, 08 Oct 2004 16:08:46 +0000 |
| Subject: | Re: PEAR CS poll | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33710@lists.php.net to get a copy of this message | ||
On Fri, 8 Oct 2004 02:08:17 -0500, Ryan King <ryansking@mac.com> wrote:
>
> On Oct 8, 2004, at 2:44 AM, Ammar Ibrahim wrote:
>
> > I do agree too.
> >
> > But Sometimes when doing Variable interpolation, in my opinion it's ok
> > to use double quotes
>
> I'm pretty sure you have to use double quotes to do variable
> interpolation. My point is that variable interpolation is never
> necessary and in, my opinion, never good idea. I think it is typically
> more readable to do something like:
>
> 'some text' . $variable . 'some more text'
>
> rather than:
>
> "some text $variable some more text"
>
> or even
>
> "some text {$variable} some more text"
>
> The reason? Syntax highlighting in text editors. With my method, the
> variable gets lit up in a different color than the text. I'd like to
> see this part of the CS, but that's just my preference.
>
This is also why I like it. Sure, some text editors may highlight
vars, but most (all?) don't get every possibility. Also:
1) All vars are not interpolated (without using {} or extra code).
This can quite easily cause mistakes.
2) It's slower. It's only noticeably slower when variables are within
the string (ie, 'string' and "string" are not noticeably different),
but it's a CS thing.
3) It promotes bad array indexes ($arr[key]) as you can't use the
quotes within strings. You're supposed to quote them when without a
string, but some people get confused (not most PEAR devs, of course).
It also seems inconsistent to me to have two array standards, one out
of strings and one in.
4) It's more precise. It makes it obvious what's a constant and what's not.
5) SYNTAX HIGHLIGHTING. I'm saying this again because it's a super
useful tool, especially when debugging large amoutns of code with lots
of strings. If you miss one interpolation all hell can break loose.
IMHO, double quotes should only be used when you need a baclslash
expression (\n, \r, \t, etc) or if you really don't like doing 'quote
\'this\' word', although I don't see a problem with that.
> -ryan
>
> > e.g: "Hello World" is NOT ok
> > "Hello {$username}"; is ok
> >
> > Ammar Ibrahim
>
--
paperCrane --Justin Patrin--