Hi all!
I remember the topic of 'nowdocs' (if you don't remember what it is,
read on) was already discussed, but nothing really happened about it.
For those who just recently woke up from cryogenic sleep :), "nowdocs"
are heredocs extension that does not interpret the content (think single
quotes instead of double quotes). Should look something like:
$foo = <<<'END'
blah$fooblah
END
unline regular heredocs, $foo would be left as-is. I think now it's
good to add it to 5.3 (and I like 'FOO' syntax best of all variants).
Any objections to this?
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Hi all!
I remember the topic of 'nowdocs' (if you don't remember what it is,
read on) was already discussed, but nothing really happened about it.
For those who just recently woke up from cryogenic sleep :), "nowdocs"
are heredocs extension that does not interpret the content (think single
quotes instead of double quotes). Should look something like:
$foo = <<<'END'
blah$fooblah
END
unline regular heredocs, $foo would be left as-is. I think now it's
good to add it to 5.3 (and I like 'FOO' syntax best of all variants).
Without turning this into color of the bikeshed flame, I'd go with the
orginal <<<~LABEL syntax, I think quoting the label will be easier to
confuse with heredocs (I had to read your example twice, thought you
accidentally used the heredoc syntax..).
It is also easier to document, and search for, <<<~ than <<< 'foo'.
But I trust you read the old thread and picked <<< 'foo' for a reason,
so feel free to ignore my comment.
Any objections to this?
No. +1 from me.
-Hannes
Hi all!
I remember the topic of 'nowdocs' (if you don't remember what it is,
read on) was already discussed, but nothing really happened about it.
For those who just recently woke up from cryogenic sleep :),
"nowdocs"
are heredocs extension that does not interpret the content (think
single
quotes instead of double quotes). Should look something like:
$foo = <<<'END'
blah$fooblah
END
unline regular heredocs, $foo would be left as-is. I think now it's
good to add it to 5.3 (and I like 'FOO' syntax best of all variants).Without turning this into color of the bikeshed flame, I'd go with the
orginal <<<~LABEL syntax, I think quoting the label will be easier to
confuse with heredocs (I had to read your example twice, thought you
accidentally used the heredoc syntax..).
It is also easier to document, and search for, <<<~ than <<< 'foo'.But I trust you read the old thread and picked <<< 'foo' for a reason,
so feel free to ignore my comment.
Disclaimer: I haven't read the old thread, but I prefer <<<~.
Any objections to this?
No. +1 from me.
Nor from me, +1.
--
Geoffrey Sneddon
<http://gsnedders.com/
+1, using 'END' as the syntax.
The ~ version to me implies some kind of bit-flipping operation,
whereas the single quotes remind us that interpolation doesn't happen.
--Wez.
Hi all!
I remember the topic of 'nowdocs' (if you don't remember what it is,
read on) was already discussed, but nothing really happened about
it. For those who just recently woke up from cryogenic sleep :),
"nowdocs" are heredocs extension that does not interpret the content
(think single quotes instead of double quotes). Should look
something like:
$foo = <<<'END'
blah$fooblah
END
unline regular heredocs, $foo would be left as-is. I think now it's
good to add it to 5.3 (and I like 'FOO' syntax best of all variants).Any objections to this?
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
The final nowdoc patches are attached.
I'm going to commit them on Thursday in case of no objections.
Thanks. Dmitry.
Stanislav Malyshev wrote:
Hi all!
I remember the topic of 'nowdocs' (if you don't remember what it is,
read on) was already discussed, but nothing really happened about it.
For those who just recently woke up from cryogenic sleep :), "nowdocs"
are heredocs extension that does not interpret the content (think single
quotes instead of double quotes). Should look something like:
$foo = <<<'END'
blah$fooblah
END
unline regular heredocs, $foo would be left as-is. I think now it's good
to add it to 5.3 (and I like 'FOO' syntax best of all variants).Any objections to this?
The final nowdoc patches are attached.
I'm going to commit them on Thursday in case of no objections.
So the current syntax is
$var = <<<'TEXT'
text
'TEXT';
am I right?
I believe it's far from readable and clear and I suggest not to add it until
we have a better syntax.
Also looking at the discussion, I can see only 6 people involved (including Dmitry),
which most likely means nobody is really interested in that "nowdoc" and this is
yet another reason not to add it.
P.S. I personally see no need in such thing at all.
--
Wbr,
Antony Dovgal
The final nowdoc patches are attached.
I'm going to commit them on Thursday in case of no objections.So the current syntax is
$var = <<<'TEXT'
text
'TEXT';am I right?
I believe it's far from readable and clear and I suggest not to add it until
we have a better syntax.
What do you suggest? :)
Also looking at the discussion, I can see only 6 people involved (including Dmitry),
which most likely means nobody is really interested in that "nowdoc" and this is
yet another reason not to add it.P.S. I personally see no need in such thing at all.
I'm pretty sure there is more people interested. I find nowdoc very
handy and is the perfect complement to heredoc.
--
Pierre
http://blog.thepimp.net | http://www.libgd.org
I believe it's far from readable and clear and I suggest not to add it until
we have a better syntax.What do you suggest? :)
I suggest to wait until we find a better syntax.
I do not suggest any syntax myself because I do not see any need in this 'nowdoc' thing at all.
--
Wbr,
Antony Dovgal
I believe it's far from readable and clear and I suggest not to add it until
we have a better syntax.What do you suggest? :)
I suggest to wait until we find a better syntax.
I do not suggest any syntax myself because I do not see any need in this 'nowdoc' thing at all.--
Wbr,
Antony Dovgal
As we may be missing a trick, how do you create strings which have $
and ' and " in them?
--
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
As we may be missing a trick, how do you create strings which have $
and ' and " in them?
$string = 'it's not that hard to add a $slash';
or
$string = <<<END
since when do we need a $new 'language construct' to save one keystroke?
END;
or even
$string = "it's the $third way to do the same "thing", but you want to add a 4th one";
--
Wbr,
Antony Dovgal
$string = 'it's not that hard to add a $slash';
It's not too hard to add a slash unless you have to do it in a big chunk
of text that may contain quotes, slashes, etc. - e.g. random PHP code
for a template generation. Going over it each time is sure recipe for
errors, and is very annoying. Having something that can accept any text
with absolutely no modification looks a good idea to me, and far more
than "saving one keystroke".
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
$string = 'it's not that hard to add a $slash';
It's not too hard to add a slash unless you have to do it in a big chunk
of text that may contain quotes, slashes, etc. - e.g. random PHP code
for a template generation.
Templates are usually put into separate files.
Embedding them into the code is just a weird fantasy and not a reason for a new construct.
--
Wbr,
Antony Dovgal
Pierre Joye schreef:
The final nowdoc patches are attached.
I'm going to commit them on Thursday in case of no objections.
So the current syntax is$var = <<<'TEXT'
text
'TEXT';am I right?
I believe it's far from readable and clear and I suggest not to add it until
we have a better syntax.What do you suggest? :)
someone suggested this:
$s = <<<~TEXT
foo bar qux
TEXT;
which does seem more readable and/or less confusing than quoting the delimter.
or maybe use an unbalanced single quote:
$s = <<<'TEXT
foo bar qux
TEXT;
which could have a complement of
$s = <<<"TEXT
foo bar qux
TEXT;
the '"' being optional and having the same meaning as heredoc syntax as it stands now.
having an unbalanced quote would leave less room for someone to ask why a string literal
was used (because it's not a string literal without the second quote), additionally
using single/double quote identifiers likens the here* syntax to the behaviour of
single and double quoted strings with regard to variable interpolation.
just a thought.
Also looking at the discussion, I can see only 6 people involved (including Dmitry),
which most likely means nobody is really interested in that "nowdoc" and this is
yet another reason not to add it.P.S. I personally see no need in such thing at all.
I'm pretty sure there is more people interested. I find nowdoc very
handy and is the perfect complement to heredoc.
The feature is very useful, however, I agree, the syntax would be better. :)
The current syntax:
$var = <<<'TEXT'
text
TEXT;
Thanks. Dmitry.
Antony Dovgal wrote:
The final nowdoc patches are attached.
I'm going to commit them on Thursday in case of no objections.So the current syntax is
$var = <<<'TEXT'
text
'TEXT';am I right?
I believe it's far from readable and clear and I suggest not to add it until
we have a better syntax.Also looking at the discussion, I can see only 6 people involved (including Dmitry),
which most likely means nobody is really interested in that "nowdoc" and this is
yet another reason not to add it.P.S. I personally see no need in such thing at all.
Dmitry Stogov wrote:
The feature is very useful, however, I agree, the syntax would be
better. :)
The current syntax:$var = <<<'TEXT'
text
TEXT;
I would like to see nowdocs. The closest equivalent in another syntax I
can think of is xml's CDATA. Perhaps we can borrow something similar to
that syntax
$var = <<<CDATA[
string here
]CDATA;
Greg
Greg Beaver wrote:
Dmitry Stogov wrote:
The feature is very useful, however, I agree, the syntax would be
better. :)
The current syntax:$var = <<<'TEXT'
text
TEXT;I would like to see nowdocs. The closest equivalent in another syntax I
can think of is xml's CDATA. Perhaps we can borrow something similar to
that syntax$var = <<<CDATA[
string here
]CDATA;
No, please, let's not further promote CDATA abuse. Everyone seems to
think that CDATA is some sort of binary-clean way to toss any junk they
want into an XML file which isn't even close to being true.
I don't think the 'FOO' syntax is very obvious either, but I can't think
of a better one and if there isn't a commonly known syntax we can steal
from another language, then making up our own, no matter what it is, is
going to be non-obvious to a lot of people.
-Rasmus
I don't think the 'FOO' syntax is very obvious either, but I can't think
of a better one and if there isn't a commonly known syntax we can steal
from another language, then making up our own, no matter what it is, is
We can steal from perl, which has exactly 'FOO' ;)
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
On Wednesday 30 January 2008 20:52:40 Stanislav Malyshev wrote:
I don't think the 'FOO' syntax is very obvious either, but I can't think
of a better one and if there isn't a commonly known syntax we can steal
from another language, then making up our own, no matter what it is, isWe can steal from perl, which has exactly 'FOO' ;)
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Ruby has, too (stolen from perl ;))
et@edea:~/programming/ruby> cat test.rb
#!/usr/bin/env ruby
var = "ls *.rb"
puts <<"EOT"
#{var}
EOT
puts <<EOT
#{var}
EOT
puts <<'EOT'
#{var}
EOT
puts <<EOT
#{var}
EOT
et@edea:~/programming/ruby> ruby test.rb
ls *.rb
ls *.rb
#{var}
test.rb
Regards,
Stefan
Also looking at the discussion, I can see only 6 people involved (including Dmitry),
which most likely means nobody is really interested in that "nowdoc" and this is
yet another reason not to add it.
I don't see how 'foo' is anything but obvious to anybody that gives
himself a second to actually think about it.
Also, let's take into account that this is syntax change, and in 5.3 we
have an unique opportunity because it's a syntax changing release. If we
don't add it in 5.3, we probably don't add it till 6. And there were
multiple requests for it, both on the list and offline. Waiting for
"better syntax" when there's nobody willing to actually work on this
syntax is just another way to say "kill it".
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
On 30.01.2008 21:40, Stanislav Malyshev wrote:
Waiting for "better syntax" when there's nobody willing to actually work on this
syntax is just another way to say "kill it".
"Nobody willing to actually work on this" effectively means "nobody actually needs it".
--
Wbr,
Antony Dovgal
I think it's actually pretty useful and not that uncommon to have large
chunks of text which you want to capture in a variable (and not deal
with the shortcomings of single quotes and/or output buffering in those
instances). The fact that you haven't found use in it doesn't mean that
others haven't. And we're not talking about something significant which
has risk associated with it and/or impacts other areas.
I think if the syntax is confusing we can go for just a single quote as
part of the operator which doesn't make it look like just another plain
old string, e.g.:
$bar =<<<'FOO
Sdjfslk
Sdfkj
FOO;
Andi
-----Original Message-----
From: Antony Dovgal [mailto:tony@daylessday.org]
Sent: Wednesday, January 30, 2008 10:51 AM
To: Stas Malyshev
Cc: 'PHP Internals'
Subject: Re: [PHP-DEV] nowdocs againWaiting for "better syntax" when there's nobody willing to actually
work on this
syntax is just another way to say "kill it"."Nobody willing to actually work on this" effectively means "nobody
actually needs it".--
Wbr,
Antony Dovgal
Andi Gutmans skrev:
I think if the syntax is confusing we can go for just a single quote as
part of the operator which doesn't make it look like just another plain
old string, e.g.:$bar =<<<'FOO
Sdjfslk
Sdfkj
FOO;
+1/2
Once again thinking as a teacher... Just a few weeks into my last course
I actually had students asking if there was a "single quote like
equivalent to heredoc", without my prompting them whatsoever. They just
thought it would be natural.
I am advocating the suggestion above as having <<<'FOO' looks too much
like a string and will be misleading for newbies (and ~ is a PITA to
type on a Swedish keyboard...)
My main concern is that is easy to miss such a small glyph. Maybe:
<<<|FOO
or even
<<<#FOO
would be an alternative?
Lars Gunther
I think it's actually pretty useful and not that uncommon to have large
chunks of text which you want to capture in a variable (and not deal
with the shortcomings of single quotes and/or output buffering in those
instances).
Does this work for you?
$string = <<<DATA
I don't like slashes in my
DATA
, so I use heredoc
DATA;
I don't want to deal with slashes whatsoever.
And we're not talking about something significant which
has risk associated with it and/or impacts other areas.
Sure, this is just a new syntax, we add them every day.
--
Wbr,
Antony Dovgal
Hi,
Andi Gutmans wrote:
I think if the syntax is confusing we can go for just a single quote as
part of the operator which doesn't make it look like just another plain
old string, e.g.:$bar =<<<'FOO
Such a thing is not nice for casual string syntax highlighting in editors.
Needs a special rule to handle an opening but not closing single quote .. mhmmm :/
- Markus
Such a thing is not nice for casual string syntax highlighting in
editors. Needs a special rule to handle an opening but not closing
single quote .. mhmmm :/
I think for 'FOO' syntax it should be pretty easy to fix the highlighter
- e.g. just add quote processing to the rule that does <<<.
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Yeah that is very true. I guess Perl way of doing 'FOO' is better after
all :)
Andi
-----Original Message-----
From: Markus Fischer [mailto:markus@fischer.name]
Sent: Wednesday, January 30, 2008 2:33 PM
To: Andi Gutmans
Cc: Antony Dovgal; Stas Malyshev; PHP Internals
Subject: Re: [PHP-DEV] nowdocs againHi,
Andi Gutmans wrote:
I think if the syntax is confusing we can go for just a single quote
as
part of the operator which doesn't make it look like just another
plain
old string, e.g.:$bar =<<<'FOO
Such a thing is not nice for casual string syntax highlighting in
editors.
Needs a special rule to handle an opening but not closing single quote
.. mhmmm :/
- Markus
Markus Fischer wrote:
Hi,
Andi Gutmans wrote:
I think if the syntax is confusing we can go for just a single quote as
part of the operator which doesn't make it look like just another plain
old string, e.g.:$bar =<<<'FOO
Such a thing is not nice for casual string syntax highlighting in
editors. Needs a special rule to handle an opening but not closing
single quote .. mhmmm :/'
(I'll try again)
I still think it looks weird. Could we consider instead using <<<' '
with '; required on a new line?
$bar = <<<'
text
with lots of 'quotes', "Quotes"
and a few $variables, \slashes and \n \t not expanded
';
Also very clear (and more intuitive in my view) would be:
$bar = <<<'
text
with lots of 'quotes', "Quotes"
and a few $variables, \slashes and \n \t not expanded
'>>>;
Greg
Also looking at the discussion, I can see only 6 people involved
(including Dmitry), which most likely means nobody is really
interested in that "nowdoc" and this is yet another reason not to
add it.I don't see how 'foo' is anything but obvious to anybody that gives
himself a second to actually think about it.
I don't see how this is obvious.
Since nowdocs isn't an existing concept, someone who comes across it
isn't going to recognize the syntax as special.
Therefore, I don't know why people would assume that a delimiter token
surrounded by single quotatation marks (i.e. a nowdoc) isn't just a
regular delimiter token that happens to have single quotation marks
around it (i.e. a heredoc).
I would expect people to be confused.
-adam
--
adam@trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!