At 11/29/2006 05:13 AM, Satyam wrote:
----- Original Message ----- From: "Paul Novitski" <paul@xxxxxxxxxxxxxxxxxxx>
What I find to be a much greater problem is the
human readability of logic code when HTML is
mixed throughout. Your innovation is helpful
here, as you're nearly making HTML tags into
PHP key words, eliminating some of the literal
quoting that makes PHP+HTML so
tiresome. However, even with your pre-compiler
the messy quotes are still there on the attribute level.
The value of the attribute is any valid PHP
expression and if they are literal strings there
will be quotes, but then, you can also use
heredoc if, for example, you are putting some
JavaScript code into an event. If the value is
a numeric value, there is no need for any quotes
at all. In the end, the value of an attribute
is any valid PHP expression and it follows PHP rules.
XHTML, which I would hope you would lean toward
in your pursuit of XML, does require quotes on all attributes:
XHTML? 1.0
4.4. Attribute values must always be quoted
http://www.w3.org/TR/xhtml1/#h-4.4
But it's not the quotes in the attributes I was
referring to as messy, but instead the necessity
for two sets of nested quotes when quoted
expressions and concatenation syntax are
contained within assignment statements.
I am an ardent user of heredoc exactly because it
allows a level of separation of logic from
markup, and at the same time permits embedded PHP
variables. I use heredoc extensively for both
HTML markup and SQL queries, both when they
appear in my PHP scripts and when they imported from separate files.
By the way, I'm not expressing strong opposition
to embedding PHP variables in HTML, as in:
<a class="$sClass" href="$sBaseURL/$sPagename">$sCaption</a>
To my eye, this is a small step away from the more ideal:
<a class="xxxxx" href="xxxxx">xxxxx</a>
where the attribute values and the content of
plain old validatable HTML are replaced based on selectors.
Instead, what I'm objecting to are control
structures, concatenation, mixed quotes, and
escaped quotes fracturing the integrity of the output string.
And, stepping back, you're perpetuating the
embedding of markup with logic so that it will
still take a PHP programmer to modify the
markup of one of your pages. Do you not see
the advantage in separating the two layers?
Yes, I do, and I would recommend using templates
or similar tools to provide for separation of
code and markup, but sometimes there are reasons
not to do so, for example, web services.
Please explain why you think web services promote mixing markup with logic.
I appreciate your comments and, I admit, my main
purpose in doing this was to learn how to do
it. I am an engineer and when I studied, a
couple of semesters of Fortran IV was all I got
(and punching cards at that, yes, I am that
old), all the rest was self-taught so I wanted
to go deeper into some aspects of computer
science such as compilers (there is also a PHP
grammar for JavaCC which I made earlier in the process).
Hah! Fortran on punch cards was my first
computer language as well, back there in the
Mesozoic. And writing compilers is the best
fun. I like to view programming in general as
language creation -- we create functions and
objects as the key words in the custom language
we use at the higher levels of our own
scripts. Writing compilers seems like just an extension of that.
In fact, my original idea was some sort of
embedded SQL as it exists for C, but I know it
does not work quite Ok, in fact, it has been
there for quite some time and it doesn't catch
up. SQL is such a different kind of beast that
it is hard to make it compatible. SQL cursors
and error handling are concepts which are hard
to blend into a procedural language so I believe
it is better to handle SQL through functions
where it is clearly separate from the language
calling them. Thus, I thought, we have three
main languages here, HTML, PHP and SQL. I know
PHP and SQL don't mix well, how about the other
end? That's when I started to think about this
pre-compiler and found it to be a pretty logical mix.
That's interesting, I don't have a problem
allowing PHP & MySQL to play together. I'm
pretty happy with the PHP mysql function library
in which the two communicate with strings and
handles; and negotiation of SQL data structures
maps nicely onto PHP logic blocks. Can you give
an example of where you see the discord?
I try to separate the text of my SQL queries from
my PHP logic in the same way that I try to separate PHP from HTML.
Warm regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php