digitalmars.D - Do we have __DATE__ ??
- Matthew (2/2) Mar 07 2005 Or __FILE__, __LINE__, etc. etc.?
- Derek Parnell (9/12) Mar 07 2005 Hear! Hear!. I also would love to have these compiler generated values.
- novice2 (1/1) Mar 07 2005 I also need __FILE__, __LINE__. __DATE__
- G.Vidal (4/14) Mar 07 2005 Build can do that, it's exactly the same thing as plugins.
- Stewart Gordon (13/15) Mar 07 2005 Are these actually that useful in a language that doesn't have a macro
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (10/18) Mar 07 2005 When it is compiled...
- novice2 (2/5) Mar 07 2005 It is very usefull!
- Stewart Gordon (8/15) Mar 07 2005 Because as Walter pointed out somewhere or other, the primary use of
- Walter (16/27) Mar 07 2005 The __DATE__, __TIME__, and __TIMESTAMP__ ones make sense, and I'll add
- pandemic (19/45) Mar 07 2005 You've never had the necessity to 'log' output from your code? Glad to h...
- Walter (15/41) Mar 07 2005 in
- Unknown W. Brackets (12/18) Mar 08 2005 Throughout at least two megabytes or more of code written in PHP (which
- bamb00 (17/78) Mar 07 2005 Neat idea! I like the $ symbol for it , fits with convention of
- Matthew (8/38) Mar 07 2005 Great!
- Matthew (11/21) Mar 07 2005 So what?! Just because Walter says one thing that proscribes the univers...
- Matthew (5/13) Mar 07 2005 Yup!
- Lukas Pinkowski (4/7) Mar 07 2005 I'd go further and introduce __FUNC__ which gives us the function name a...
- =?iso-8859-1?q?Knud_S=F8rensen?= (4/13) Mar 07 2005 Nice suggestion.
- Matthew (32/39) Mar 07 2005 Yes, the thing I'm wanting __DATE__ for would also be much simpler with ...
- xs0 (8/17) Mar 07 2005 This is a job for AspectD! :)
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (16/19) Mar 07 2005 But aren't __FILE__, __LINE__, __DATE__, __TIME__ all
Or __FILE__, __LINE__, etc. etc.? I really need __DATE__
Mar 07 2005
On Mon, 7 Mar 2005 23:07:51 +1100, Matthew wrote:Or __FILE__, __LINE__, etc. etc.? I really need __DATE__Hear! Hear!. I also would love to have these compiler generated values. They can give meaningful information to people who are trying to find errors happening at a customer's site. It helps narrow down what version they are running and where a run-time message is really coming from. -- Derek Parnell Melbourne, Australia 7/03/2005 11:09:23 PM
Mar 07 2005
Build can do that, it's exactly the same thing as plugins. I explained how we could do it in my last post: http://www.dsource.org/forums/viewtopic.php?t=624 Le Mon, 07 Mar 2005 23:12:14 +1100, Derek Parnell a écrit :On Mon, 7 Mar 2005 23:07:51 +1100, Matthew wrote:Or __FILE__, __LINE__, etc. etc.? I really need __DATE__Hear! Hear!. I also would love to have these compiler generated values. They can give meaningful information to people who are trying to find errors happening at a customer's site. It helps narrow down what version they are running and where a run-time message is really coming from.
Mar 07 2005
Matthew wrote:Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?I really need __DATE__Date of what? The file's timestamp? When it is compiled? What data type/format would it be? A d_time? (Most sensible for as long as d_time remains the nearest we have to a standard date type.) A string as formatted using std.date.toDateString or std.date.toString? Something else? And do we really want to use reserved identifiers for this? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Mar 07 2005
Stewart Gordon wrote:When it is compiled... http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.htmlI really need __DATE__Date of what? The file's timestamp? When it is compiled?What data type/format would it be? A d_time? (Most sensible for as long as d_time remains the nearest we have to a standard date type.) A string as formatted using std.date.toDateString or std.date.toString? Something else?Something else: __DATE__ = "Mar 7 2005"; __TIME__ = "15:44:00";And do we really want to use reserved identifiers for this?Well, we *could* use date and time and file and line... It would "silently break" a couple of dozen people's code, but they should be used to that since length ? ;-) --anders
Mar 07 2005
It is very usefull! And why "preprocessor"? This is "compiler-predefined constants".Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?
Mar 07 2005
novice2 wrote:Would you care to elaborate?It is very usefull!Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?And why "preprocessor"? This is "compiler-predefined constants".Because as Walter pointed out somewhere or other, the primary use of __FILE__ and __LINE__ seems to be to create an assert macro. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Mar 07 2005
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d0i0lu$2rhh$1 digitaldaemon.com...novice2 wrote:The __DATE__, __TIME__, and __TIMESTAMP__ ones make sense, and I'll add them. The __FILE__ and __LINE__ make less sense, as their usual appearance is in code generating macros (of which assert() is the dominating one). If you used __FILE__ and __LINE__ in a D mixin template, they'll give the file and line of where the template was defined, *not* where the template was instantiated. There's still some utility to that, but not much. But I'll add them in anyway, they don't detract from anything, and people coming from C/C++ really miss them. But I suspect that after a while, they'll be removing them from the source. __FUNCTION__ and __MODULE__ are the wrong way to do things in D. A better way would be to add a general .name property to things, which will give a string with the name in it. g++ goofed with __FUNCTION__ as it prevents the preprocessor from being separated from the compiler.Would you care to elaborate?It is very usefull!Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?And why "preprocessor"? This is "compiler-predefined constants".Because as Walter pointed out somewhere or other, the primary use of __FILE__ and __LINE__ seems to be to create an assert macro.
Mar 07 2005
In article <d0i5rq$5o$1 digitaldaemon.com>, Walter says..."Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d0i0lu$2rhh$1 digitaldaemon.com...You've never had the necessity to 'log' output from your code? Glad to hear you're adding these two. BTW: how about considering these as "meta-tags" as has been discussed elsewhere? They could be prescribed in a manner akin to _arguments, _argptr, length -- all prefixed with the "meta-tag" $ symbol? That way, you can avoid all the issues of clashing names. We then have: $arguments $argptr $length $line $file $date $time $timestamp or use the symbol instead? Doesn't this appear to be a cleaner way to handle such things? All those __NAME__ style decorations seem a bit crude, and a bit crufty.novice2 wrote:The __DATE__, __TIME__, and __TIMESTAMP__ ones make sense, and I'll add them. The __FILE__ and __LINE__ make less sense, as their usual appearance is in code generating macros (of which assert() is the dominating one). If you used __FILE__ and __LINE__ in a D mixin template, they'll give the file and line of where the template was defined, *not* where the template was instantiated. There's still some utility to that, but not much. But I'll add them in anyway, they don't detract from anything, and people coming from C/C++ really miss them. But I suspect that after a while, they'll be removing them from the source.Would you care to elaborate?It is very usefull!Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?And why "preprocessor"? This is "compiler-predefined constants".Because as Walter pointed out somewhere or other, the primary use of __FILE__ and __LINE__ seems to be to create an assert macro.
Mar 07 2005
"pandemic" <pandemic_member pathlink.com> wrote in message news:d0id7u$8r4$1 digitaldaemon.com...In article <d0i5rq$5o$1 digitaldaemon.com>, Walter says...inThe __FILE__ and __LINE__ make less sense, as their usual appearance isandcode generating macros (of which assert() is the dominating one). If you used __FILE__ and __LINE__ in a D mixin template, they'll give the fileaddline of where the template was defined, *not* where the template was instantiated. There's still some utility to that, but not much. But I'llI do it sometimes. But since the __LINE__ isn't coming from macro expansion, I doubt many will write: log(message, __FILE__, __LINE__); But we'll see.them in anyway, they don't detract from anything, and people coming from C/C++ really miss them. But I suspect that after a while, they'll be removing them from the source.You've never had the necessity to 'log' output from your code?BTW: how about considering these as "meta-tags" as has been discussedelsewhere?They could be prescribed in a manner akin to _arguments, _argptr,length -- allprefixed with the "meta-tag" $ symbol? That way, you can avoid all theissues ofclashing names. We then have: $arguments $argptr $length $line $file $date $time $timestamp or use the symbol instead? Doesn't this appear to be a cleaner way tohandlesuch things? All those __NAME__ style decorations seem a bit crude, and abitcrufty.That is a pretty good idea. At first glance, it looks better.
Mar 07 2005
Throughout at least two megabytes or more of code written in PHP (which has no macros whatsoever) this is exactly what I do and have instructed the developers I lead to do; I have also seen it commonly done in other PHP projects. I'm very glad to see this in D, now, should it stay. I'm afraid I think making the assumption that people won't spell it out (when it's the only way to use such an important debugging tool) is a mistake. Most important, consider a proxying function, such as a function that executes a database query, some other long/abstracted process, etc. Having the error message/assert come from those line numbers couldn't be more useless. -[Unknown]I do it sometimes. But since the __LINE__ isn't coming from macro expansion, I doubt many will write: log(message, __FILE__, __LINE__); But we'll see.
Mar 08 2005
We then have: $arguments $argptr $length $line $file $date $time $timestamp or use the symbol instead? Doesn't this appear to be a cleaner way tohandlesuch things? All those __NAME__ style decorations seem a bit crude, and abitcrufty.Neat idea! I like the $ symbol for it , fits with convention of 'interpolation' in most scripting languages , and looks good :). Charlie "pandemic" <pandemic_member pathlink.com> wrote in message news:d0id7u$8r4$1 digitaldaemon.com...In article <d0i5rq$5o$1 digitaldaemon.com>, Walter says...macro"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d0i0lu$2rhh$1 digitaldaemon.com...novice2 wrote:Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have ainThe __DATE__, __TIME__, and __TIMESTAMP__ ones make sense, and I'll add them. The __FILE__ and __LINE__ make less sense, as their usual appearance isWould you care to elaborate?preprocessor?It is very usefull!And why "preprocessor"? This is "compiler-predefined constants".Because as Walter pointed out somewhere or other, the primary use of __FILE__ and __LINE__ seems to be to create an assert macro.andcode generating macros (of which assert() is the dominating one). If you used __FILE__ and __LINE__ in a D mixin template, they'll give the fileaddline of where the template was defined, *not* where the template was instantiated. There's still some utility to that, but not much. But I'llhearthem in anyway, they don't detract from anything, and people coming from C/C++ really miss them. But I suspect that after a while, they'll be removing them from the source.You've never had the necessity to 'log' output from your code? Glad toyou're adding these two. BTW: how about considering these as "meta-tags" as has been discussedelsewhere?They could be prescribed in a manner akin to _arguments, _argptr,length -- allprefixed with the "meta-tag" $ symbol? That way, you can avoid all theissues ofclashing names. We then have: $arguments $argptr $length $line $file $date $time $timestamp or use the symbol instead? Doesn't this appear to be a cleaner way tohandlesuch things? All those __NAME__ style decorations seem a bit crude, and abitcrufty.
Mar 07 2005
"Walter" <newshound digitalmars.com> wrote in message news:d0i5rq$5o$1 digitaldaemon.com..."Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d0i0lu$2rhh$1 digitaldaemon.com...Great.novice2 wrote:The __DATE__, __TIME__, and __TIMESTAMP__ ones make sense, and I'll add them.Would you care to elaborate?It is very usefull!Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?And why "preprocessor"? This is "compiler-predefined constants".Because as Walter pointed out somewhere or other, the primary use of __FILE__ and __LINE__ seems to be to create an assert macro.The __FILE__ and __LINE__ make less sense, as their usual appearance is in code generating macros (of which assert() is the dominating one). If you used __FILE__ and __LINE__ in a D mixin template, they'll give the file and line of where the template was defined, *not* where the template was instantiated. There's still some utility to that, but not much. But I'll add them in anyway, they don't detract from anything, and people coming from C/C++ really miss them. But I suspect that after a while, they'll be removing them from the source.Great! I'd also ask that we have something like the __BASE_FILE__, which the DMC++ and GCC compilers provide, which represents the main source file/line. I recognise the increased complexity that this would incur when instantiating mixins, but I'm also highly confident that it's not intractable to your cunning. (Nor can I see how it's more complex than the implementation of mixins and foreach, and you did them rather well, no?)__FUNCTION__ and __MODULE__ are the wrong way to do things in D. A better way would be to add a general .name property to things, which will give a string with the name in it. g++ goofed with __FUNCTION__ as it prevents the preprocessor from being separated from the compiler.Agreed.
Mar 07 2005
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d0i0lu$2rhh$1 digitaldaemon.com...novice2 wrote:So what?! Just because Walter says one thing that proscribes the universe of possibilities that ingenious minds may create. Bjarne Stroustrup says the one thing anyone can be sure of is that no-one can know of all the possible ways in which C++ may be used. Now some might argue the real possibility of this being a problem with C++, but I guarantee you that D is sufficiently complex for it to apply to it as well. I have, right now, a use for __DATE__. There's been a clear requirement for __FILE__ and __LINE__ for as long as I can remember. Just because Walter states that _he_ doesn't think users should ever get a glimpse of the file and line information associated with a fatal program error - cos more info is always a problem in critical failure conditions, being as how it so hampers the diagnosis of the flaw ... - doesn't make it a universal wisdom. Sigh ...Would you care to elaborate?It is very usefull!Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?And why "preprocessor"? This is "compiler-predefined constants".Because as Walter pointed out somewhere or other, the primary use of __FILE__ and __LINE__ seems to be to create an assert macro.
Mar 07 2005
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d0ho99$2hod$1 digitaldaemon.com...Matthew wrote:Absolutely!Or __FILE__, __LINE__, etc. etc.?Are these actually that useful in a language that doesn't have a macro preprocessor?Yup!I really need __DATE__Date of what? The file's timestamp? When it is compiled?What data type/format would it be? A d_time? (Most sensible for as long as d_time remains the nearest we have to a standard date type.) A string as formatted using std.date.toDateString or std.date.toString? Something else?I've currently made it a ulong. So anything that fits in there.And do we really want to use reserved identifiers for this?It's a lot simpler and less likely to dialecticalise (sic.) than using preprocessors.
Mar 07 2005
Matthew wrote:Or __FILE__, __LINE__, etc. etc.? I really need __DATE__I'd go further and introduce __FUNC__ which gives us the function name and also __MODULE__, which gives us, right, the module name. This would be really neat, I need some of them, too!
Mar 07 2005
Nice suggestion. I have added it to my wish list under compiler values. http://all-technology.com/eigenpolls/dwishlist/ On Mon, 07 Mar 2005 15:33:35 +0100, Lukas Pinkowski wrote:Matthew wrote:Or __FILE__, __LINE__, etc. etc.? I really need __DATE__I'd go further and introduce __FUNC__ which gives us the function name and also __MODULE__, which gives us, right, the module name. This would be really neat, I need some of them, too!
Mar 07 2005
"Lukas Pinkowski" <Lukas.Pinkowski web.de> wrote in message news:d0hoo5$2hp8$1 digitaldaemon.com...Matthew wrote:Yes, the thing I'm wanting __DATE__ for would also be much simpler with __MODULE__. I also agree that __FUNC__ should be in there, esp. if Walter facilitates the forwarding of these things in templates and mixins. But even absent that, if people want to use D+preprocessor, these things are really important. For myself, though I'd really like to avoid the preprocessor in D, if we had all these features I would probably write code that'd work well with and without preprocessing, such that one can do builds that will insert them when desirable. Something like: module M; void funcF() { /+ FUNCTION_ +/ . . . } class X { void methodY() { /+ METHOD_ +/ . . . } After all, such things are easy to include in code-generators, and easy to auto insert with Ruby scripts. Even done manually, it's a write once thing. Then one's code will compile with normal D, and with macro expansion, e.g. #define FUNCTION_ +/ std.logging.GroovyLogger.getLogger().LogFunction(__MODULE__, __FUNCTION__, __FILE__, __LINE__); /+ #define METHOD_ +/ std.logging.GroovyLogger.getLogger().LogMethod(__MODULE__, __CLASS__, __FUNCTION__, __FILE__, __LINE__); /+ Frankly, I think such things would be incredibly useful in large projects.Or __FILE__, __LINE__, etc. etc.? I really need __DATE__I'd go further and introduce __FUNC__ which gives us the function name and also __MODULE__, which gives us, right, the module name. This would be really neat, I need some of them, too!
Mar 07 2005
Then one's code will compile with normal D, and with macro expansion, e.g. #define FUNCTION_ +/ std.logging.GroovyLogger.getLogger().LogFunction(__MODULE__, __FUNCTION__, __FILE__, __LINE__); /+ #define METHOD_ +/ std.logging.GroovyLogger.getLogger().LogMethod(__MODULE__, __CLASS__, __FUNCTION__, __FILE__, __LINE__); /+ Frankly, I think such things would be incredibly useful in large projects.This is a job for AspectD! :) I'm just thinking - if you have a front-end done, how hard is it to implement AOP? It would seem that it's relatively simple, there's "just" pattern matching, code insertion, and some meta-info being made available.. And having debug() and version() with aspects would be just sweet. But I guess supporting AOP at this point in time is not likely to happen? xs0
Mar 07 2005
Matthew wrote:Or __FILE__, __LINE__, etc. etc.? I really need __DATE__But aren't __FILE__, __LINE__, __DATE__, __TIME__ all part of that ancient old preprocessor which is so evil ? ;-) I also find the GCC extension __FUNCTION__ to be useful. Wouldn't it be possible to add these as constants to the lexer, without messing up the language to bad ? Or it could be like an escape sequence or something... But easiest would just be if they were "special" literals. char[] file = __FILE__; int line = __LINE__; char[] date = __DATE__; // "??? ?? ????" char[] time = __TIME__; // "??:??:??" char[] module = __MODULE__; char[] function = __FUNCTION__; Doesn't sound impossible to hack into the DMD front-end... --anders
Mar 07 2005