October 21, 2023
On Saturday, 21 October 2023 at 07:04:35 UTC, Richard (Rikki) Andrew Cattermole wrote:
> On 21/10/2023 7:57 PM, Walter Bright wrote:
>> [...]
>
> This also means that one formatter doesn't have to know about another formatters format string syntax.
>
> Like how formattedWrite doesn't need to know about GDateTime.
>
> And yes, I have that working today with the ``{:}`` syntax in my codebase. Its great.
>
> This is why I do not agree with Adam about his argument against supporting the format string specifier as part of the language. Having it in the language means it is all nicely unified.

I kinda also agree with that, in C# I use it and it's pretty nice indeed
October 21, 2023
On Saturday, 21 October 2023 at 01:50:33 UTC, Walter Bright wrote:
> https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md
>

Can't you "expand" i"..." directly into format(..., ..., ...) instead of expanding in a tuple?
October 21, 2023
On Saturday, 21 October 2023 at 01:50:33 UTC, Walter Bright wrote:
> # DIP1027
> ...
> # Cons
> 1. Is more susceptible to inadvertent matching with the wrong function, because the tuples generated are tuples of strings, integers, and other ordinary types.

2. Requires parsing of format string (always).

Really, except already present *f functions, if you'd like to have your own function accepting interpolated strings, DIP 1027 version would take a lot more time and brain power to write compared to YAIDIP.
October 21, 2023
On Saturday, 21 October 2023 at 08:40:11 UTC, Alexandru Ermicioi wrote:
> On Saturday, 21 October 2023 at 01:50:33 UTC, Walter Bright wrote:
>> # DIP1027
>> ...
>> # Cons
>> 1. Is more susceptible to inadvertent matching with the wrong function, because the tuples generated are tuples of strings, integers, and other ordinary types.
>
> 2. Requires parsing of format string (always).
>
> Really, except already present *f functions, if you'd like to have your own function accepting interpolated strings, DIP 1027 version would take a lot more time and brain power to write compared to YAIDIP.

Is there currently an implementation of 1027 that we can try?
October 21, 2023

On Saturday, 21 October 2023 at 08:25:02 UTC, Andrea Fontana wrote:

>

On Saturday, 21 October 2023 at 01:50:33 UTC, Walter Bright wrote:

>

https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md

Can't you "expand" i"..." directly into format(..., ..., ...) instead of expanding in a tuple?

People are worried about betterC on that.
To be fair, I'm more worried about having a simply works feature that would allow me to get a real string when my argument receives a string, and having the tuple solution if I want to optimize something.

October 21, 2023

On Saturday, 21 October 2023 at 01:50:33 UTC, Walter Bright wrote:

>

https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md

https://github.com/John-Colvin/YAIDIP

[...]

I personally find the swift approach more natural and pretty.

Instead of using a character like $ or %, it uses \ as in "Section count: \(sectionCount)".
It does not give a way to format them, so I think that maybe a second fmt function should be implemented to wrap toString and get something like "Downloading \(completion.format("%.2f"))%" (here there could be another problem if we can't put quotes in here, but I don't know how D parses string in general and if it would be a problem).

October 21, 2023
On Saturday, 21 October 2023 at 06:04:21 UTC, Walter Bright wrote:
> I expect the grammar would be part of the proposal, not a use case.
>
> In any case, I don't see a point in discussing YAIDIP any further, and will await the real proposal.

I’m not really sure I grok the differences between the two proposals at the moment, but the people who support YAIDIP seem to think you have a lot of misconceptions and have left the door open for you to look at the implementations or play with it to have them corrected. If a bunch of people told me I was badly mistaken about something, I would want to find out why…

I’d say put them both behind preview switches and have the proponents of each put together some showcases of what they can do, or can’t do.
October 21, 2023

On Saturday, 21 October 2023 at 06:04:21 UTC, Walter Bright wrote:

>

I expect the grammar would be part of the proposal, not a use case.

In any case, I don't see a point in discussing YAIDIP any further, and will await the real proposal.

I'm getting exhausted with this thread, as you seem not to pay attention to anything I'm saying. So this set of replies will be my last.

The YAIDIP discusses completely the grammar of the solution, the requirements of the solution, and THEN goes into possible use cases.

The C++-style stream manipulators USE CASE is not part of the proposal at all. In no way, will phobos, or druntime, gain some std.iformat module as a REQUIREMENT of this DIP.

Neither are the hypothetical format specifiers that I posted earlier. They are POSSIBLE things you might do if given the power that this DIP provides, not an integral part of the DIP.

-Steve

October 21, 2023

On Saturday, 21 October 2023 at 06:44:22 UTC, Walter Bright wrote:

>

On 10/20/2023 9:42 PM, Steven Schveighoffer wrote:

>

Yes and no. It's very clearly geared towards writef (or else we would have some other default other than %s), even though it doesn't require hooking with writef. But in effect, writef and format (and other functions like it, such as loggers) are the only functions it works with "out of the box".

That's no surprise, since Phobos has adopted that style for more than just writef, such as std.format.format(). There's no reason to invent a different one for loggers.

https://dlang.org/phobos/std_format.html#format

Besides, I had modified DIP1027 to enable any format string between { } specifically to accommodate your database use case.

This is woefully inadequate. It requires users to participate in the details of the SQL format that are irrelevant to the function call, and it also allows people to do the wrong thing quite easily, with no compiler help. Statically typed languages are better than this, and especially D is. We don't want to make users have to know how the "sausage is made".

This is why I consider it a failure.

consider the even worse case of postgres -- all parameters require a positional index, so:

INSERT INTO tbl (name, age) VALUES ($1, $2)

Now, the user not only has to change the %s to $N, but they have to maintain the ordering of the indexes manually. These are the kinds of things that people "get used to" because they have no other options. Much better to let the function itself handle the proper placeholders that correspond to the implementation details of the usage.

You might say, "hey, that's just the way it is, you are using postgres". But what about a DB abstraction library? It might want to change the placeholders based on the underlying backend.

> >

There are many other functions that use the same style of "blueprint + data" calls which will utterly fail, and can't be made to work with DIP1027.

Example, please. I already showed how to do Adam's example of things that wouldn't work with DIP1027.

The point I was making was that there are no other functions except writef and format that work, or can be made to work, directly with this mechanism (of course, without sausage-making by the user). Even printf requires the user to become involved.

Of course, it is possible to write a completely new function with a new name that will handle (poorly) the puzzle that the compiler constructed in its quirky writef-like way (oh, and make sure you don't change those placeholders, because we can't detect that!)

> >

BTW, I count a failure as having to specify the correct substitution as the user. That is the domain of the function or the type system.

I don't know what that means.

The {} thing you mentioned above. It does not suffice as discussed above. The user shouldn't have to be involved with figuring out placeholders when we have a perfectly capable compiler to do it for us.

> >

Nobody, and I really truly mean, NOBODY, is clamoring for
better ways to call printf (specifically printf).

Which is too bad. printf has many advantages:

I was saying printf is fine the way it is, nobody needs new ways to call printf.

> >

NOBODY

Nobody wanted ImportC, either. However, several people have told me that they have been seduced into using it and found it delightful and very productive. Heck, in another posting I discovered it could be used to translate C code to D!

  1. Everybody wanted a way to import C directly. It's been probably the most requested language change for D ever. ImportC is turning out to be a great success, and I think it will change D's future for the better.
  2. People can and do successfully and joyfully use printf. Nobody is asking for more printf capabilities.
  3. YAIDIP and DIP1036 cover this mechanism way way better than DIP1027 or some special case compiler workaround would.

-Steve

October 21, 2023
On 10/21/2023 7:20 AM, jmh530 wrote:
> I’m not really sure I grok the differences between the two proposals at the moment, but the people who support YAIDIP seem to think you have a lot of misconceptions and have left the door open for you to look at the implementations or play with it to have them corrected. If a bunch of people told me I was badly mistaken about something, I would want to find out why…

I know why. YAIDIP is not an actual specification for it. When Adam and Steven prepare a specification then I will look at it again.

(For example, Steven mentions a { } syntax, which does not exist in YADIP.)