Re: Incorrect newline counters

boots <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
--- messju mohr <[email protected]> wrote:
> On Mon, May 31, 2004 at 03:31:23AM +0400, Dmitry Koteroff wrote:
> > RA> Basically,  the  smarty templates are geared so the resulting
> > RA> output  is the same as the template, and is a higher priority
> > RA> than the compiled template itself.
> > Aargh!
> > 
> > What do I see in _compile_foreach_start(), for example?
> > 
> >   $output .= "if (isset(\$this->_foreach[$name]))
> unset(\$this->_foreach[$name]);\n";
> >   $foreach_props = "\$this->_foreach[$name]";
> > 
> > WHAT IS THIS? Why \n? It breaks line number!
> 
> yes, but nobody here does really seem to care, except of you.

Actually, I'm certain that messju is aware that many of us care very
much -- but I'm certain too that he is also aware that we care about
completely different issues surrounding the topic. Smarty MUST ensure
that the template *output* is line-for-line what was intended in the
template source. The compiled files are of little consequence since
they are not the end target of the template process. In many ways they
are incidental. Yes, Smarty is playing the role of a meta-language
writing code that writes our output; but the code it writes is not our
objective--it is the output of that code that is crucial.

The thing is, is that the compiled code is just that: it is analogous
to the object form of source for a formally compiled program/language.
What would you do to debug from object code in that case? You would
have to have a suitable symbolic debugger which had access to special
symbol tables developed at compile time. If the compiler fails, it
tells you where your source went wrong. If the runtime fails, you are
stuck with a *very* different sort of process to trace back to your
sourcecode. In other words, as already has been suggested, the place to
search for errors is in the sourcecode at compile time -- mucking with
the object files is not how one should spend their debugging time if
they can avoid it. To this end, I agree that it is not feasible (or
desirable) to have Smarty try to catch all possible errors. There are
things we have to live with and we manage them through process and
convention. (For example, most templates are coded using an iterative
testing process, so finding bugs is usually straight-forward: review
your most recent edits.)

In Smarty terms, wading into the compiled templates to debug them is 
the absolute last-choice one would wish to make. Since it is more
important to preserve line-handling for the sake of output the best
thing is to at least make the compiled code human readable. I've been
using Smarty for years and can say that I've only needed to dive into
the compiled sources a handful of times.

From what I've witnessed, the present day line handling is the result
of a lot of give-and-take over the years based on many users
experiences on wide ranges of systems and usage patterns (remember too,
that html is not the only output target). I have no faith that these
patches will be transparent for all users. The risk of breaking
someone's output to support this proposal seems unwarranted to me,
particularly since its aim is more pendantic than productive IMHO.

Greetings,
xo boots


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.