Req #32734 [Com]: Support for #line pragma, as in C and Perl
| From: | rasmus at mindplay dot dk | Date: | Tue, 10 May 2011 17:35:46 +0000 |
| Subject: | Req #32734 [Com]: Support for #line pragma, as in C and Perl | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160666@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=32734&edit=1
ID: 32734
Comment by: rasmus at mindplay dot dk
Reported by: php at koterov dot ru
Summary: Support for #line pragma, as in C and Perl
Status: Open
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: all
PHP Version: 5.0.4
Block user comment: N
Private report: N
New Comment:
This feature is badly lacking to support many good, modern patterns,
which could broaden the scope and use of PHP in general. View-engines as
mentioned, but not least aspect-oriented programming, code generation
and meta-programming in general, and cross-language-compilation from
other languages.
Microsoft's C# compiler has an implementation of this feature that could
be referenced:
http://msdn.microsoft.com/en-us/library/aa691102%28v=VS.71%29.aspx
I would propose extending the existing syntax for execution directives,
as implemented by the declare keyword:
http://www.php.net/manual/en/control-structures.declare.php
It might looks like this:
// start of file
declare(source='test.c#20');
something();
declare(source='test.c#30') {
other();
more();
}
// end of file
Consistent with the way declare otherwise works - the first
declare-statement in this example changes the error-reporting for all of
the following statements in that file, while the second
declare-statement changes the error reporting within the brackets.
I think this idea should be taken into serious consideration, as it has
the potential to open up the world of PHP to entirely new forms of
development.
Previous Comments:
------------------------------------------------------------------------
[2005-04-17 08:47:01] php at koterov dot ru
Description:
------------
C, C++ and Perl support the folowing feature:
// start of file
#line 20 "test.c"
something
#line 30 "test.c"
other
// end of file
If error is generated into code "something", it is reported as error "in
test.c on line 20" - NOT on line 3! For code "other" - "in test.c on
line 30". The same Perl code example:
### start of file
#line 20 "test.c"
warn "something";
#line 30 "test.c"
warn "other";
### end of file
Result is:
something at test.c line 20.
other at test.c line 30.
Unfortunately PHP does not support this useful feature, and because of
that any template engines with pre-compilation (e.g. Smarty) make the
life not so pleasant as it could be.
Do you plan to add #line feature in future versions of PHP? Programmers
need it very much!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=32734&edit=1