June 23, 2023

On Thursday, 22 June 2023 at 17:18:25 UTC, Andrej Mitrovic wrote:

>

I'm envisioning a new type __CTX__ which contains all of these different contexts which are currently separate keywords on: https://dlang.org/spec/expression.html#specialkeywords.

This could be implemented in a library after https://issues.dlang.org/show_bug.cgi?id=18919 is fixed. An implementation could then look like this:

struct Loc
{
   string file;
   size_t line;
}
Loc defaultLoc(string file = __FILE__, size_t line = __LINE__)
{
   return Loc(file, line);
}
void foo(Loc loc = defaultLoc)
{
   writeln(loc.file, " ", loc.line);
}

Currently it prints the wrong location, because __FILE__ and __LINE__ are not evaluated at the real call site, but that could be changed.

A library implementation would have the advantage that you could choose the members.

June 24, 2023

On Thursday, 22 June 2023 at 17:49:00 UTC, Ernesto Castellotti wrote:

>

On Thursday, 22 June 2023 at 17:18:25 UTC, Andrej Mitrovic wrote:

>

This isn't a DIP but I'd like to start this conversation to see what people think.

[...]

I don't think it's a good idea to add another special keyword, isn't it possible to rethink the proposal using traits?

Something like __traits(getContext)?

June 24, 2023

On Thursday, 22 June 2023 at 19:49:31 UTC, ryuukk_ wrote:

>
void infoStack(string msg) {
    enum file = __traits(context, calling_file);
    enum line = __traits(context, calling_line);
    writefln("%s(%s): %s", file, line, msg);
}

I'm not sure how this could work with separate compilation?

June 24, 2023

On Saturday, 24 June 2023 at 08:47:36 UTC, Andrej Mitrovic wrote:

>

On Thursday, 22 June 2023 at 19:49:31 UTC, ryuukk_ wrote:

>
void infoStack(string msg) {
    enum file = __traits(context, calling_file);
    enum line = __traits(context, calling_line);
    writefln("%s(%s): %s", file, line, msg);
}

I'm not sure how this could work with separate compilation?

Apologies, others already responded to this and I didn't catch it. :)

June 24, 2023

On Thursday, 22 June 2023 at 17:18:25 UTC, Andrej Mitrovic wrote:

>

This isn't a DIP but I'd like to start this conversation to see what people think.

There's some interest in this so I'll start writing up a DIP.

June 25, 2023

On Saturday, 24 June 2023 at 08:50:18 UTC, Andrej Mitrovic wrote:

>

On Thursday, 22 June 2023 at 17:18:25 UTC, Andrej Mitrovic wrote:

>

This isn't a DIP but I'd like to start this conversation to see what people think.

There's some interest in this so I'll start writing up a DIP.

Be aware that DIP requests are closed right now while the process is being reevaluated. (Which I think is a mistake, but whatever.)

June 26, 2023

On Sunday, 25 June 2023 at 09:35:11 UTC, FeepingCreature wrote:

>

Be aware that DIP requests are closed right now while the process is being reevaluated. (Which I think is a mistake, but whatever.)

Oh thanks for reminding me! Found the announcement here: https://forum.dlang.org/post/hzzallunjtnzyspghezj@forum.dlang.org

1 2
Next ›   Last »