php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #32734 Support for #line pragma, as in C and Perl
Submitted: 2005-04-17 08:47 UTC Modified: 2017-09-27 15:51 UTC
Votes:5
Avg. Score:4.2 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: php at koterov dot ru Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: 5.0.4 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at koterov dot ru
New email:
PHP Version: OS:

 

 [2005-04-17 08:47 UTC] 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!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-10 19:35 UTC] rasmus at mindplay dot dk
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.
 [2016-12-30 22:53 UTC] cmb@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2017-09-27 15:51 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2017-09-27 15:51 UTC] cmb@php.net
Thank you for your interest in PHP and for submitting a feature request. Please
be aware that due to the magnitude of change this request requires, it would be
necessary to discuss it on PHP Internals list (internals@lists.php.net) as an
RFC. Please read the guide about creating RFCs here:
<https://wiki.php.net/rfc/howto>. If you haven't had experience with writing
RFCs before, it is advised to seek guidance on the Internals list
(<http://php.net/mailing-lists.php>) and/or solicit help from one of the
experienced developers. 

Please do not consider this comment as a negative view on the merits of your
proposal – every proposal which requires changes of certain magnitude, even the
very successful and widely supported ones, must be done through the RFC process.
This helps make the process predictable, transparent and accessible to all
developers.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC