November 11, 2013
On 2013-11-11 13:36, Rikki Cattermole wrote:

> Yes outside of macros would be useful. For example code like this would
> become redundant:
> pragma(msg, "Support for x is not implemented on platform y");
> static assert(0);
>
> Becoming:
> pragma(error, "Support for x is not implemented on platform y");
>
> Also pragma's core responsibility is to cause the compiler to do
> something. In this case to say we hit an error during compilation please
> tell the user/dev and die.
>
> It is a hook to the compilers workings.
>
> Currently working on getting this implemented. Nearly done with it. Just
> got some extra spaces that shouldn't be in output.

I just don't want to add a bunch of pragmas. I don't know what's the best solution.

-- 
/Jacob Carlborg
November 11, 2013
Am 11.11.2013 13:36, schrieb Rikki Cattermole:
> On Monday, 11 November 2013 at 12:30:07 UTC, Jacob Carlborg wrote:
>> Yes, I still don't understand why you would want it as a
>> pragma. Be usable outside of macros?
>
> Yes outside of macros would be useful. For example code like this
> would become redundant:
> pragma(msg, "Support for x is not implemented on platform y");
> static assert(0);
>
> Becoming:
> pragma(error, "Support for x is not implemented on platform y");
>
> Also pragma's core responsibility is to cause the compiler to do
> something. In this case to say we hit an error during compilation
> please tell the user/dev and die.
>
> It is a hook to the compilers workings.
>
> Currently working on getting this implemented. Nearly done with
> it. Just got some extra spaces that shouldn't be in output.

but in macros the context information is much more interesting then anything else - so #pragma(error,...) won't fully fit the needs to context error returning - it could be much more then just a message

example: to help the compiler forming better error messages - or maybe recover from deep macro expansion etc...)

what you want is just #pragma(error,...) -> break compiliation now
Jacob is talking about the feedback for the compiler thing...


November 11, 2013
On Sunday, 10 November 2013 at 21:20:34 UTC, Jacob Carlborg wrote:
> I've been thinking quite long of how AST macros could look like in D. I've been posting my vision of AST macros here in the newsgroup a couple of times already. I've now been asked to create a DIP out of it, so here it is:
>
> http://wiki.dlang.org/DIP50

I don't have time to investigate this in details but I'd like to mention that this is one of few possible new features where ROI is really worth it. It removes lot of burden from core language and allows to replace some very arcane template hacks with cleaner code. I'd say it is a bit too early to go for it (really, we need at least to figure out how to make releases without issues first :)) but it is a good future goal even in context of general feature freezing.
November 11, 2013
On Monday, 11 November 2013 at 13:16:23 UTC, Jacob Carlborg wrote:
> I just don't want to add a bunch of pragmas. I don't know what's the best solution.

I am only suggesting one :)
We only need one that'll output any text we want it to and make the compiler consider it an error.
On the macro side of things we can build a string which then can be given to the pragma.

All of the wrapping giving the goodness would go into the context.

Current what I have enables this:

void main() {
	U u;
}

alias T!("hi", "bye") U;

struct T(string a, string b) {
	pragma(error, a ~ "\n" ~ b);
}

test.d(8): Error: hi
bye

test.d(5): Error: template instance test.T!("hi", "bye") error instantiating

Not really in pull state but thats the best I can do. Really that final error should be omitted.
November 11, 2013
On 2013-11-11 14:32, Rikki Cattermole wrote:

> I am only suggesting one :)

What about warnings? And no, the current pragma(msg) isn't the same.

> We only need one that'll output any text we want it to and make the
> compiler consider it an error.
> On the macro side of things we can build a string which then can be
> given to the pragma.
>
> All of the wrapping giving the goodness would go into the context.
>
> Current what I have enables this:
>
> void main() {
>      U u;
> }
>
> alias T!("hi", "bye") U;
>
> struct T(string a, string b) {
>      pragma(error, a ~ "\n" ~ b);
> }
>
> test.d(8): Error: hi
> bye
>
> test.d(5): Error: template instance test.T!("hi", "bye") error
> instantiating
>
> Not really in pull state but thats the best I can do. Really that final
> error should be omitted.

I wouldn't say no to this if macros are completely off the table. Perhaps it's a good addition regardless.

-- 
/Jacob Carlborg
November 11, 2013
On Monday, 11 November 2013 at 13:22:34 UTC, dennis luehring wrote:
> example: to help the compiler forming better error messages - or maybe recover from deep macro expansion etc...)
>
> what you want is just #pragma(error,...) -> break compiliation now
> Jacob is talking about the feedback for the compiler thing...

Jacob mentioned originally he wanted to create a compiler error. Or at least thats is how I took it. Hence pragma(error, "text");
We can already message out at both compile and runtime its simply does the compiler recognise it as an error part.
November 11, 2013
On Monday, 11 November 2013 at 13:36:14 UTC, Jacob Carlborg wrote:
> What about warnings? And no, the current pragma(msg) isn't the same.
I'm not doing one for warnings. See how the error one goes. The warning one won't stop compilation and pragma msg can be used to fake it.

> I wouldn't say no to this if macros are completely off the table. Perhaps it's a good addition regardless.

Personally I think it was already needed even without macros. Just this has started me off on actually looking into it. We'll see what the compiler devs think though.
November 11, 2013
On 2013-11-11 14:40, Rikki Cattermole wrote:

> I'm not doing one for warnings. See how the error one goes. The warning
> one won't stop compilation and pragma msg can be used to fake it.

Yes, but I want warnings to be available in the context parameter as well. That's what I've been talking about all along. It's not just errors, it's all of the stuff that can be added.

Warnings can be turned off, pragma(msg) cannot (at least not as far as I know).

> Personally I think it was already needed even without macros. Just this
> has started me off on actually looking into it. We'll see what the
> compiler devs think though.

I see. I'm not saying that we don't need it.

-- 
/Jacob Carlborg
November 11, 2013
On 2013-11-11 14:36, Rikki Cattermole wrote:

> Jacob mentioned originally he wanted to create a compiler error. Or at
> least thats is how I took it. Hence pragma(error, "text");
> We can already message out at both compile and runtime its simply does
> the compiler recognise it as an error part.

"error" would be just a single function that is available in the context parameter. There would be many others. From the DIP:

* The arguments used when the compiler was invoked

* Functions for emitting messages of various verbosity level, like error, warning and info

* Functions for querying various types of settings/options, like which versions are defined, is "debug" or "release" defined and so on

* In general providing as much as possible of what the compiler knows about the compile run

* The context should have an associative array with references to all scoped variables at initiation point.

-- 
/Jacob Carlborg
November 11, 2013
On Monday, 11 November 2013 at 14:10:32 UTC, Jacob Carlborg wrote:
> On 2013-11-11 14:40, Rikki Cattermole wrote:
>
>> I'm not doing one for warnings. See how the error one goes. The warning
>> one won't stop compilation and pragma msg can be used to fake it.
>
> Yes, but I want warnings to be available in the context parameter as well. That's what I've been talking about all along. It's not just errors, it's all of the stuff that can be added.
>
> Warnings can be turned off, pragma(msg) cannot (at least not as far as I know).

Ah ok, I'll see what I can drum up in that regard then. I guess I was wrong about being able to fake it with pragma msg.