digitalmars.D - praise: optional comma at the end of argument list is a life saver for
- mw (15/15) Sep 13 2020 I'm referring to this:
- =?UTF-8?Q?Ali_=c3=87ehreli?= (18/18) Sep 13 2020 Yes, accepting that trailing comma is very useful in many contexts.
- Dominikus Dittes Scherkl (3/8) Sep 13 2020 And it would still not be sufficient, as e.g. German would need
- DlangUser38 (28/44) Sep 14 2020 yeah it's okish. Also good for git diff, for example when you add
I'm referring to this: https://github.com/mingwugmail/talibd/blob/master/source/talibd.d#L109 int lookback = TA_MACD_Lookback(optInFastPeriod,optInSlowPeriod,optInSignalPeriod,); D compiler accept (but ignore) the last comma "," is a life saver for generated code. Otherwise, one have to find new ways to remove it which is a nuisance. (The generating C macro in this case, are defined as: #define SPLIT_THEN_TAKE_VAR(X) SPLIT(TAKE_VAR, X), FUNC_INS)); __NL__\ https://github.com/mingwugmail/talibd/blob/master/source/talibd.h#L121 https://github.com/mingwugmail/talibd/blob/master/source/talibd.h#L60 )
Sep 13 2020
Yes, accepting that trailing comma is very useful in many contexts. Related, I use std.format's %( and %) specifiers, which automatically remove the extra delimiters at the end: import std.stdio; void main() { writefln!"%(%s, %)"([1, 2, 3]); } Prints 1, 2, 3 When we want, we can use %| to mean "keep the delimiters up to this place": writefln!"%(%s,%| %)"([1, 2, 3]); Now the comma is printed as well but not the following space: 1, 2, 3, I wish it had an additional feature where we could say "use this delimiter before the last one" so we could inject e.g. and "and": 1, 2, and 3 As far as I know, it doesn't exist. Ali
Sep 13 2020
On Sunday, 13 September 2020 at 19:28:05 UTC, Ali Çehreli wrote:I wish it had an additional feature where we could say "use this delimiter before the last one" so we could inject e.g. and "and": 1, 2, and 3 As far as I know, it doesn't exist.And it would still not be sufficient, as e.g. German would need to remove also the comma before the and: "1, 2, 3 und 4"
Sep 13 2020
On Sunday, 13 September 2020 at 18:57:14 UTC, mw wrote:I'm referring to this: https://github.com/mingwugmail/talibd/blob/master/source/talibd.d#L109 int lookback = TA_MACD_Lookback(optInFastPeriod,optInSlowPeriod,optInSignalPeriod,); D compiler accept (but ignore) the last comma "," is a life saver for generated code. Otherwise, one have to find new ways to remove it which is a nuisance. (The generating C macro in this case, are defined as: #define SPLIT_THEN_TAKE_VAR(X) SPLIT(TAKE_VAR, X), int lookback = __NL__\ https://github.com/mingwugmail/talibd/blob/master/source/talibd.h#L121 https://github.com/mingwugmail/talibd/blob/master/source/talibd.h#L60 )yeah it's okish. Also good for git diff, for example when you add a member to an enum then you only have one line modified instead of two. --- enum Foo { f1 } enum Foo { - f1 + f1, + f2 } --- now in D you can just have --- enum Foo { f1, } enum Foo { f1, + f2, } ---
Sep 14 2020