Is it possible to assign a Comma Expression to a variable?
H. S. Teoh
hsteoh at qfbox.info
Tue Nov 29 21:45:03 UTC 2022
On Tue, Nov 29, 2022 at 09:24:43PM +0000, Lucian Danescu via Digitalmars-d wrote:
> To give some context, D-Scanner has a check that warns against
> assigning a comma expression to a variable. Example:
>
> ```
> a = (foo(), bar(), 1); // warn here
> ```
>
> This check was implemented a while back, and from what I can see,
> currently assigning a comma expression results in a compilation error,
> hence that check in D-Scanner would not be necessary anymore.
>
> I just wanted to make sure that it is impossible to assign a comma
> expression to a variable, or if it is possible, can someone please
> clarify when and maybe give an example?
No it's not possible to assign a comma expression to a variable. That
has been deprecated years ago, and as far as I can tell generates a flat
out compile error now.
In the future, comma syntax may be extended to tuples.
T
--
Help a man when he is in trouble and he will remember you when he is in trouble again.
More information about the Digitalmars-d
mailing list