praise: optional comma at the end of argument list is a life saver for generated code
DlangUser38
DlangUser at nowhere.ch
Mon Sep 14 07:03:05 UTC 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 =
> TA_FUNC##_Lookback(FOR_EACH(SPLIT_THEN_TAKE_VAR, 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
> )
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,
}
---
More information about the Digitalmars-d
mailing list