View mode: basic / threaded / horizontal-split · Log in · Help
March 14, 2008
[Issue 1924] New: fail to pragma compile time constant
http://d.puremagic.com/issues/show_bug.cgi?id=1924

          Summary: fail to pragma compile time constant
          Product: D
          Version: 1.026
         Platform: PC
       OS/Version: Windows
           Status: NEW
         Severity: normal
         Priority: P2
        Component: DMD
       AssignedTo: bugzilla@digitalmars.com
       ReportedBy: davidl@126.com


char[] wrongfunc()
{
   char[] result;
   pragma(msg, result);       // fail at this line
   return result;
}
mixin(wrongfunc);


--
March 14, 2008
[Issue 1924] fail to pragma compile time constant
http://d.puremagic.com/issues/show_bug.cgi?id=1924


fvbommel@wxs.nl changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
            Status|NEW                         |RESOLVED
        Resolution|                            |INVALID




------- Comment #1 from fvbommel@wxs.nl  2008-03-14 09:44 -------
Your 'result' is a variable that happens not to get assigned at runtime, but
the fact that it happens not to change doesn't mean it's a constant.


P.S. According to the spec it even needs to be a string literal (which I don't
think is what the compiler implements, since I'm pretty sure it allows string
constants constructed by templates and ctfe). But either way your code is
clearly illegal.


--
March 15, 2008
[Issue 1924] fail to pragma compile time constant
http://d.puremagic.com/issues/show_bug.cgi?id=1924


davidl@126.com changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
            Status|RESOLVED                    |REOPENED
        Resolution|INVALID                     |




------- Comment #2 from davidl@126.com  2008-03-15 00:23 -------
char[] wrongfunc()
{
   char[] result="void main()";
   result ~= "{}";
   const char[] myresult= result;
   pragma(msg, myresult);       // fail at this line
   return result;
}
mixin(wrongfunc);

abc.d(6): Error: string expected for message, not 'result'

pragma here is clearly for debugging CTFE. I don't want to make it as the
following 

char[] getresult()
{
   char[] result="void main()";
   result ~= "{}";
   return result;
}
char[] myfunc()
{
   const char[] result = getresult();
   pragma(msg,result);
   return result;
}
mixin(myfunc);

it's way dummier for debugging CTFE, especially if i want to do only some
simple inspect on some particular vars.


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924


clugdbug@yahoo.com.au changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
          Severity|normal                      |enhancement
          Keywords|spec                        |
           Summary|fail to pragma compile time |Allow pragma(msg) in CTFE
                  |constant                    |




------- Comment #3 from clugdbug@yahoo.com.au  2008-11-26 08:35 -------
Although a way of debugging CTFE functions would be very nice to have, this is
definitely not a bug. 

I'm changing this to an enhancement, changed title from: fail to pragma compile
time constant


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924





------- Comment #4 from smjg@iname.com  2008-11-26 08:52 -------
I think we need separate notation for this.  Generating a compiler message
while compiling a function is conceptually different from generating a compiler
message while evaluating it.


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924


shro8822@vandals.uidaho.edu changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |shro8822@vandals.uidaho.edu




------- Comment #5 from shro8822@vandals.uidaho.edu  2008-11-26 10:32 -------

pragma(writefln,"hello #%d", 1);
vote++;


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924





------- Comment #6 from smjg@iname.com  2008-11-26 11:13 -------
From the names pragma(msg) and pragma(writefln), it isn't clear at all that
one's while compiling and one's while evaluating.

Better would be to name it something like "ctfeMsg" or "msgCTFE".  And perhaps
writefln notation could be supported in both this and regular msg.  This won't
break existing code as long as pragma(msg, string) with no further arguments is
still defined to write that exact string.


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924





------- Comment #7 from shro8822@vandals.uidaho.edu  2008-11-26 11:17 -------
To date, every use of writefln I've seen has been run time. So it doesn't seem
particularly ambiguous at least to me,


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924





------- Comment #8 from smjg@iname.com  2008-11-26 12:05 -------
(In reply to comment #7)
> To date, every use of writefln I've seen has been run time. So it doesn't seem
> particularly ambiguous at least to me,

That's because at the moment writefln can only be executed at run time.  If it
(or something resembling it) becomes executable at compile time, it could just
as well be either as and when compiled or during CTFE.

Having a difference between pragma(msg) and pragma(writefln) beyond what they
say on the tin would be arbitrary and confusing.


--
November 26, 2008
[Issue 1924] Allow pragma(msg) in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=1924





------- Comment #9 from shro8822@vandals.uidaho.edu  2008-11-26 12:43 -------

Sorry, I was far less than clear.

writefln in all cases we use it in now executes with the code path, e.g. when
the code is executed rather than generated. pragma is compile time in all
cases. Seems like a good fit to me.

OTOH as long as it's not something like
pragma(D9B01F73-E64A-4FA9-A2DE-C20CD24560BA) I'm not going to object to getting
it!


--
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home