D - Initializer lists?
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (5/5) Feb 25 2004 Hi, how can I write code like this:
- Sean Kelly (6/12) Feb 25 2004 I don't think it's legal in D. I just checked the "expression"
- Manfred Nowak (8/9) Feb 25 2004 [...]
- Sean Kelly (12/29) Feb 25 2004 But ConditionalExpression is defined thus:
- Russ Lewis (5/42) Feb 25 2004 ConditionalExpression expands to OrOrExpression
- Sean Kelly (3/9) Feb 25 2004 Oops :) I missed that first time around. Thanks!
- Manfred Nowak (6/7) Feb 25 2004 [...]
- Russ Lewis (8/14) Feb 25 2004 This code compiles & runs cleanly:
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (14/21) Feb 25 2004 Ok, I had it on module level:
- Kris (5/27) Feb 25 2004 I believe you can achieve the same result (at the module level) via a st...
- jcc7 cox.net (15/20) Feb 25 2004 It works for me. Try posting a full example. The problem might be elsewh...
Hi, how can I write code like this: int a, b; a = b = 7; This somehow doesn't work for me, I get an "no identifier for declarator" error. Robert
Feb 25 2004
Robert M. Münch wrote:Hi, how can I write code like this: int a, b; a = b = 7; This somehow doesn't work for me, I get an "no identifier for declarator" error. RobertI don't think it's legal in D. I just checked the "expression" documentation, however, and think it may need to be revised. There's no provision for assignments in "AssignExpression" that I can see. Also, the "statement" documentation references it as "AssignmentExpression." Sean
Feb 25 2004
On Wed, 25 Feb 2004 09:13:57 -0800, Sean Kelly wrote:I don't think it's legal in D.[...] There is: AssignExpression: ConditionalExpression ConditionalExpression = AssignExpression So a list of ..=..= ... = .. is legal. So long.
Feb 25 2004
Manfred Nowak wrote:On Wed, 25 Feb 2004 09:13:57 -0800, Sean Kelly wrote:But ConditionalExpression is defined thus: ConditionalExpression: OrOrExpression OrOrExpression ? Expression : ConditionalExpression So unless I'm reading it wrong there's so provision for a standard lvalue. This is why I said the documentation may need revision--it wasn't clear to me whether chaines assignments should be legal or not. Especially considering what I read somewhere else in the D documentation that a programmer should never rely on a particular evaluation order (except, I assume, for logical expression short-circuiting). SeanI don't think it's legal in D.[...] There is: AssignExpression: ConditionalExpression ConditionalExpression = AssignExpression So a list of ..=..= ... = .. is legal. So long.
Feb 25 2004
Sean Kelly wrote:Manfred Nowak wrote:ConditionalExpression expands to OrOrExpression OrOrExpression expands to AndAndExpression and so on, down the line to PrimaryExpression, which expands to Identifier. So ConditionalExpression does expand to Identifier. :)On Wed, 25 Feb 2004 09:13:57 -0800, Sean Kelly wrote:But ConditionalExpression is defined thus: ConditionalExpression: OrOrExpression OrOrExpression ? Expression : ConditionalExpression So unless I'm reading it wrong there's so provision for a standard lvalue. This is why I said the documentation may need revision--it wasn't clear to me whether chaines assignments should be legal or not. Especially considering what I read somewhere else in the D documentation that a programmer should never rely on a particular evaluation order (except, I assume, for logical expression short-circuiting). SeanI don't think it's legal in D.[...] There is: AssignExpression: ConditionalExpression ConditionalExpression = AssignExpression So a list of ..=..= ... = .. is legal. So long.
Feb 25 2004
Russ Lewis wrote:ConditionalExpression expands to OrOrExpression OrOrExpression expands to AndAndExpression and so on, down the line to PrimaryExpression, which expands to Identifier. So ConditionalExpression does expand to Identifier. :)Oops :) I missed that first time around. Thanks! Sean
Feb 25 2004
Sean Kelly wrote: [...]that a programmer should never rely on a particular evaluation order[...] You are right. The evaluation order for a list of assignments ist not defined. So it is not a chain assignment. So long.
Feb 25 2004
Robert M. Münch wrote:Hi, how can I write code like this: int a, b; a = b = 7; This somehow doesn't work for me, I get an "no identifier for declarator" error. RobertThis code compiles & runs cleanly: int main() { int a,b; a = b = 7; printf("%d %d\n", a,b); return 0; }
Feb 25 2004
On Wed, 25 Feb 2004 11:16:04 -0700, Russ Lewis <spamhole-2001-07-16 deming-os.org> wrote:This code compiles & runs cleanly: int main() { int a,b; a = b = 7; printf("%d %d\n", a,b); return 0; }Ok, I had it on module level: module bla; uint a, b; a = b = 2*4; This one didn't compile: "no identifier for declarator". What I would like to do is: uint a = b = 2*4; <further code> -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Feb 25 2004
I believe you can achieve the same result (at the module level) via a static constructor. - Kris "Robert M. Münch" <robert.muench robertmuench.de> wrote in message news:opr3x69qshheztw6 news.digitalmars.com...On Wed, 25 Feb 2004 11:16:04 -0700, Russ Lewis <spamhole-2001-07-16 deming-os.org> wrote:This code compiles & runs cleanly: int main() { int a,b; a = b = 7; printf("%d %d\n", a,b); return 0; }Ok, I had it on module level: module bla; uint a, b; a = b = 2*4; This one didn't compile: "no identifier for declarator". What I would like to do is: uint a = b = 2*4; <further code> -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Feb 25 2004
In article <opr3xj3st2heztw6 news.digitalmars.com>, =?iso-8859-1?Q?Robert_M._M=FCnch?= says...Hi, how can I write code like this: int a, b; a = b = 7; This somehow doesn't work for me, I get an "no identifier for declarator" error. RobertIt works for me. Try posting a full example. The problem might be elsewhere. JC void main() { int a, b; a = b = 7; printf("%d\t%d\n", a, b); } /+ Output: c:\dmd\bin\..\..\dm\bin\link.exe init2,,,user32+kernel32/noi; 7 7 +/
Feb 25 2004