| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
May 06, 2012 Escaping control in formatting (again) | ||||
|---|---|---|---|---|
| ||||
Sorry for wasting your time again, but I'm so silly that I still believe I was right in previous thread about enabling escaping control in formatting. To convince me I'm wrong, pleas write to this thread that this isn't a desired formatting functionality for you: --- auto myInterfaces = ["Iface1", "Iface2", "Iface3"]; // %!-s disables escaping myDFile.writefln(`class C: %(%!-s, %)`, myInterfaces); --- --- // %!+s enables escaping debug if(str1 != str2) writefln(`WARNING: %!+s != %!+s`, str1, str2); --- and current (undocumented) escaping rules a good for you: 1. User has no escaping control. 2. Escaping is enabled only for associative arrays, ranges (not strings), user-defined types, and all its sub-elements unless a sub element is a character and is formatted with %c or a struct/class formatted using its `toString` method. (it took lot time to understand this rules for me, but this isn't an issue because if they are good, they will be documented some day) Original thread (with only mine and Kenji Hara opinions (yes, and one post from Dmitry who don't know current escaping rules): http://forum.dlang.org/thread/jn3ibu$tp7$1@digitalmars.com -- Денис В. Шеломовский Denis V. Shelomovskij | ||||
May 07, 2012 Re: Escaping control in formatting (again) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | In prev thread, I have posted a proposal, but it didn't posted to
newsgroup, I don't know why.
I re-post my proposal.
----
If the leading compound format specifier has a '-' flag, like "%-( ... %)", it disables auto-escaping for the elements formatting.
writefln(">%(%s, %)<", ["hello", "world"]); // output: >"hello", "world"<
writefln(">%-(%s, %)<", ["hello", "world"]); // output: >hello, world<
You can format the elements as like outside of compound format specifiers. How about you?
----
Kenji Hara
2012/5/6 Denis Shelomovskij <verylonglogin.reg@gmail.com>:
> Sorry for wasting your time again, but I'm so silly that I still believe I was right in previous thread about enabling escaping control in formatting.
>
> To convince me I'm wrong, pleas write to this thread that this isn't a desired formatting functionality for you:
>
> ---
> auto myInterfaces = ["Iface1", "Iface2", "Iface3"];
> // %!-s disables escaping
> myDFile.writefln(`class C: %(%!-s, %)`, myInterfaces);
> ---
>
> ---
> // %!+s enables escaping
> debug if(str1 != str2) writefln(`WARNING: %!+s != %!+s`, str1, str2);
> ---
>
> and current (undocumented) escaping rules a good for you:
> 1. User has no escaping control.
> 2. Escaping is enabled only for associative arrays, ranges (not strings),
> user-defined types, and all its sub-elements unless a sub element is a
> character and is formatted with %c or a struct/class formatted using its
> `toString` method.
>
> (it took lot time to understand this rules for me, but this isn't an issue because if they are good, they will be documented some day)
>
>
> Original thread (with only mine and Kenji Hara opinions (yes, and one post from Dmitry who don't know current escaping rules): http://forum.dlang.org/thread/jn3ibu$tp7$1@digitalmars.com
>
> --
> Денис В. Шеломовский
> Denis V. Shelomovskij
| |||
May 07, 2012 Re: Escaping control in formatting (again) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to kenji hara | 07.05.2012 11:39, kenji hara написал: > In prev thread, I have posted a proposal, but it didn't posted to > newsgroup, I don't know why. > I re-post my proposal. > > ---- > If the leading compound format specifier has a '-' flag, like "%-( ... > %)", it disables auto-escaping for the elements formatting. > > writefln(">%(%s, %)<", ["hello", "world"]); // output:>"hello", "world"< > writefln(">%-(%s, %)<", ["hello", "world"]); // output:>hello, world< > > You can format the elements as like outside of compound format specifiers. > How about you? This is enough for my own needs. Thanks! Who is to implement this? Looks line nobody needs features from my original proposal so they shouldn't be discussed further (unless will become needed). -- Денис В. Шеломовский Denis V. Shelomovskij | |||
May 08, 2012 Re: Escaping control in formatting (again) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | Posted pull request: https://github.com/D-Programming-Language/phobos/pull/573 Kenji Hara 2012/5/7 Denis Shelomovskij <verylonglogin.reg@gmail.com>: > 07.05.2012 11:39, kenji hara написал: > >> In prev thread, I have posted a proposal, but it didn't posted to >> newsgroup, I don't know why. >> I re-post my proposal. >> >> ---- >> If the leading compound format specifier has a '-' flag, like "%-( ... %)", it disables auto-escaping for the elements formatting. >> >> writefln(">%(%s, %)<", ["hello", "world"]); // output:>"hello", "world"< >> writefln(">%-(%s, %)<", ["hello", "world"]); // output:>hello, world< >> >> You can format the elements as like outside of compound format specifiers. How about you? > > > This is enough for my own needs. Thanks! Who is to implement this? > > Looks line nobody needs features from my original proposal so they shouldn't be discussed further (unless will become needed). > > > -- > Денис В. Шеломовский > Denis V. Shelomovskij | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply