digitalmars.D - #line ?
- Matthew Wilson (1/1) Jul 12 2004 What do we think of supporting #line?
- Derek Parnell (11/12) Jul 12 2004 YES PLEASE! And #file too!.
- Derek Parnell (9/23) Jul 13 2004 Of course I'm thinking conceptually here. The exact syntax is not an iss...
- Matthew Wilson (8/20) Jul 13 2004 This is not what I mean. I meant in the same way that C/C++ compilers us...
- Walter (3/9) Jul 13 2004 It already supports that.
- Vathix (4/5) Jul 12 2004 Already there, www.digitalmars.com/d/lex.html#specialtokens
- Matthew Wilson (4/10) Jul 13 2004 Perfect!
- Andy Friesen (6/7) Jul 12 2004 The only use for it I can think of is for tricking the compiler into
- Walter (4/10) Jul 13 2004 The #line is there in D so that D can handle the output of the C
- Matthew Wilson (3/16) Jul 13 2004 And you are a prescient super-being. :)
- Kris (11/24) Jul 13 2004 That's cool, but how about being able to print the current line number a...
- Matthew Wilson (7/35) Jul 13 2004 I don't see what's wrong with __FILE__ and __LINE__.
- Kris (7/48) Jul 13 2004 Can't say that I particularly care what they're called; I just want the
- Arcane Jill (10/12) Jul 13 2004 You can get it, if you're prepared to live with an ugly hack (and one wh...
-
Stewart Gordon
(10/13)
Jul 13 2004
- J Anderson (7/69) Jul 13 2004 Whats wrong is that looks ugly. They should be under some namespace
- Stewart Gordon (10/16) Jul 13 2004 For people who've found an inadequacy in D's replacement features, and
- Walter (5/16) Jul 13 2004 It's handy for any potential programs that use D as an intermediate code...
- Matthew Wilson (5/11) Jul 13 2004 Exactly. This is why I'm interested in it.
- Jonathan Leffler (15/24) Jul 13 2004 If D is successful, it will be the target language for other
- pragma (14/15) Jul 13 2004 Right off the bat, I can say that I use it extensively in DSP, since its
On Tue, 13 Jul 2004 15:28:41 +1000, Matthew Wilson wrote:What do we think of supporting #line?YES PLEASE! And #file too!. The D compiler automatically defines int #line; char[] #file; and fills in the appropriate values when used. assert("ABORT in file '" ~ #file "' at line " ~ toString(#line)) -- Derek Melbourne, Australia 13/Jul/04 3:49:48 PM
Jul 12 2004
On Tue, 13 Jul 2004 15:52:16 +1000, Derek Parnell wrote:On Tue, 13 Jul 2004 15:28:41 +1000, Matthew Wilson wrote:Of course I'm thinking conceptually here. The exact syntax is not an issue The concept is to be able to get to the source code file name and line number at 'run-time'. -- Derek Melbourne, Australia 13/Jul/04 5:06:18 PMWhat do we think of supporting #line?YES PLEASE! And #file too!. The D compiler automatically defines int #line; char[] #file; and fills in the appropriate values when used. assert("ABORT in file '" ~ #file "' at line " ~ toString(#line))
Jul 13 2004
This is not what I mean. I meant in the same way that C/C++ compilers use it, i.e. #line N stipulates that the next line of course _is_ line N, and error messages respect that. Thus, we could generate D source from some meta-D, and use a pre-processor to generate the D using #line to keep generated code in accord with the meta-D source. "Derek Parnell" <derek psych.ward> wrote in message news:ccvtah$1kpc$1 digitaldaemon.com...On Tue, 13 Jul 2004 15:28:41 +1000, Matthew Wilson wrote:What do we think of supporting #line?YES PLEASE! And #file too!. The D compiler automatically defines int #line; char[] #file; and fills in the appropriate values when used. assert("ABORT in file '" ~ #file "' at line " ~ toString(#line)) -- Derek Melbourne, Australia 13/Jul/04 3:49:48 PM
Jul 13 2004
"Matthew Wilson" <dmd synesis.com.au> wrote in message news:cd04js$22sn$1 digitaldaemon.com...This is not what I mean. I meant in the same way that C/C++ compilers use it, i.e. #line N stipulates that the next line of course _is_ line N, and error messages respect that. Thus, we could generate D source from some meta-D, and use a pre-processor to generate the D using #line to keep generated code in accord with the meta-D source.It already supports that.
Jul 13 2004
"Matthew Wilson" <dmd synesis.com.au> wrote in message news:ccvs29$1iu2$1 digitaldaemon.com...What do we think of supporting #line?Already there, www.digitalmars.com/d/lex.html#specialtokens I was thinking it should be removed and use pragma(line) instead.
Jul 12 2004
Perfect! :-) "Vathix" <vathixSpamFix dprogramming.com> wrote in message news:ccvvi0$1or5$1 digitaldaemon.com..."Matthew Wilson" <dmd synesis.com.au> wrote in message news:ccvs29$1iu2$1 digitaldaemon.com...What do we think of supporting #line?Already there, www.digitalmars.com/d/lex.html#specialtokens I was thinking it should be removed and use pragma(line) instead.
Jul 13 2004
Matthew Wilson wrote:What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma? -- andy
Jul 12 2004
"Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...Matthew Wilson wrote:The #line is there in D so that D can handle the output of the C preprocessor.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma?
Jul 13 2004
"Walter" <newshound digitalmars.com> wrote in message news:cd02p5$1vj6$1 digitaldaemon.com..."Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...And you are a prescient super-being. :)Matthew Wilson wrote:The #line is there in D so that D can handle the output of the C preprocessor.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma?
Jul 13 2004
That's cool, but how about being able to print the current line number and source file using #line and #file or equivalent? Perhaps treat them as char[], so you can do something like printf ("file %.*s, line %.*s\n", #file, #line) ? Why would one wish to do that, you ask? Well, it's really very useful for a remote-logger to indicate which file a log-event was generated from, and even more so when it tells you the source line number. Currently there's no reasonable way for mango.log to produce that kind of information as it spits out log events to the Chainsaw console ... "Walter" <newshound digitalmars.com> wrote in message news:cd02p5$1vj6$1 digitaldaemon.com..."Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...Matthew Wilson wrote:The #line is there in D so that D can handle the output of the C preprocessor.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma?
Jul 13 2004
I don't see what's wrong with __FILE__ and __LINE__. Ruby does this. "Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:cd0a9m$2drd$1 digitaldaemon.com...That's cool, but how about being able to print the current line number and source file using #line and #file or equivalent? Perhaps treat them as char[], so you can do something like printf ("file %.*s, line %.*s\n", #file, #line) ? Why would one wish to do that, you ask? Well, it's really very useful foraremote-logger to indicate which file a log-event was generated from, and even more so when it tells you the source line number. Currently there'snoreasonable way for mango.log to produce that kind of information as itspitsout log events to the Chainsaw console ... "Walter" <newshound digitalmars.com> wrote in message news:cd02p5$1vj6$1 digitaldaemon.com..."Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...Matthew Wilson wrote:The #line is there in D so that D can handle the output of the C preprocessor.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma?
Jul 13 2004
Can't say that I particularly care what they're called; I just want the functionality :-) "Matthew Wilson" <dmd synesis.com.au> wrote in message news:cd0alo$2eeg$1 digitaldaemon.com...I don't see what's wrong with __FILE__ and __LINE__. Ruby does this. "Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:cd0a9m$2drd$1 digitaldaemon.com...andThat's cool, but how about being able to print the current line numberforsource file using #line and #file or equivalent? Perhaps treat them as char[], so you can do something like printf ("file %.*s, line %.*s\n", #file, #line) ? Why would one wish to do that, you ask? Well, it's really very usefulawhenremote-logger to indicate which file a log-event was generated from, and even more so when it tells you the source line number. Currently there'snoreasonable way for mango.log to produce that kind of information as itspitsout log events to the Chainsaw console ... "Walter" <newshound digitalmars.com> wrote in message news:cd02p5$1vj6$1 digitaldaemon.com..."Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...Matthew Wilson wrote:What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messagescompiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma?The #line is there in D so that D can handle the output of the C preprocessor.
Jul 13 2004
In article <cd0bjn$2g99$1 digitaldaemon.com>, Kris says...Can't say that I particularly care what they're called; I just want the functionality :-)You can get it, if you're prepared to live with an ugly hack (and one which D was trying to avoid). You can tweak your makefile or build script so that your D source is pushed through a C++ preprocessor before it hits the D compiler. __FILE__ and __LINE__ will then be expanded by the preprocessor, and subsequently seen as compile-time constants by DMD. If D /really/ wants to make the preprocessor redundant, it will have to provide that functionality for itself. Arcane Jill
Jul 13 2004
Matthew Wilson wrote:I don't see what's wrong with __FILE__ and __LINE__. Ruby does this.<snip top of upside-down reply> Aren't identifiers beginning with __ meant to be implementation specific? (Or am I thinking of C(++)?) If we're going to support it, is there a reason against having it in the standard? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 13 2004
Matthew Wilson wrote:I don't see what's wrong with __FILE__ and __LINE__. Ruby does this.Whats wrong is that looks ugly. They should be under some namespace instead. We discussed this before, I mentioned the namespace could be debug but then someone mentioned some similar namespace that was already provided that could be used (I forget the name)."Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:cd0a9m$2drd$1 digitaldaemon.com...-- -Anderson: http://badmama.com.au/~anderson/That's cool, but how about being able to print the current line number and source file using #line and #file or equivalent? Perhaps treat them as char[], so you can do something like printf ("file %.*s, line %.*s\n", #file, #line) ? Why would one wish to do that, you ask? Well, it's really very useful foraremote-logger to indicate which file a log-event was generated from, and even more so when it tells you the source line number. Currently there'snoreasonable way for mango.log to produce that kind of information as itspitsout log events to the Chainsaw console ... "Walter" <newshound digitalmars.com> wrote in message news:cd02p5$1vj6$1 digitaldaemon.com..."Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...Matthew Wilson wrote:The #line is there in D so that D can handle the output of the C preprocessor.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor. If D even needs it, shouldn't it be a pragma?
Jul 13 2004
Walter wrote:"Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...<snip>For people who've found an inadequacy in D's replacement features, and so decide to run their code through the preprocessor before compiling it? Or for ports of programs like lex/yacc to generate D code? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.If D even needs it, shouldn't it be a pragma?The #line is there in D so that D can handle the output of the C preprocessor.
Jul 13 2004
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:cd0knm$2v4r$1 digitaldaemon.com...Walter wrote:It's handy for any potential programs that use D as an intermediate code, yet wish to have error messages refer to whatever the original source text was."Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...<snip>For people who've found an inadequacy in D's replacement features, and so decide to run their code through the preprocessor before compiling it? Or for ports of programs like lex/yacc to generate D code?If D even needs it, shouldn't it be a pragma?The #line is there in D so that D can handle the output of the C preprocessor.
Jul 13 2004
"Andy Friesen" <andy ikagames.com> wrote in message news:ccvvum$1pi6$1 digitaldaemon.com...Matthew Wilson wrote:Exactly. This is why I'm interested in it.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor.If D even needs it, shouldn't it be a pragma?#line is a well-established convention, so it'd not be wise to change from being compatible with just about any C/C++ preprocessor.
Jul 13 2004
Andy Friesen wrote:Matthew Wilson wrote:If D is successful, it will be the target language for other compilers. For example, consider Yacc/Bison - that generates C code; a D version might be useful, one day. Lex/Flex is a closely related example, of course. And I've worked with a number of other languages that use C as an intermediate (not necessarily the only intermediate) language. And it helps the original language compiler (the one that generates C or D) to get the error reporting right if the lower-level compiler (C or D) reports line numbers in terms of the original language -- hence #line.What do we think of supporting #line?The only use for it I can think of is for tricking the compiler into outputting 'correct' line numbers and filenames in error messages when compiling code that is the output of some preprocessor.If D even needs it, shouldn't it be a pragma?Pass. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler earthlink.net, jleffler us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Jul 13 2004
In article <ccvs29$1iu2$1 digitaldaemon.com>, Matthew Wilson says...What do we think of supporting #line?Right off the bat, I can say that I use it extensively in DSP, since its basically a preprocessor. It does a great job of coercing the compiler to generate useful output when a compilation fails, in a way that other languages couldn't possibly hope to achieve. However, I could really use something like "#line default" or "#line" to signal the compiler to resume the default line number and filename from that point on. It is something of a wart in the syntax though, and could easily be replaced by a "pragma()" or some other keyword similar to "version()" and the rest. Another problem is that is it has zero effect on symbolic information compiled into the code. When exceptions are thrown, they "appear" to be from the original source file and line number, not from where "#line" specifies in the code. - Pragma
Jul 13 2004