digitalmars.D - invariant()
- Michel Fortin (18/18) Apr 12 2009 In D1 you had to write:
- davidl (5/19) Apr 12 2009 It will be good if it will be the same in both D1 and D2
- Jarrett Billingsley (6/17) Apr 12 2009 Actually, the D1 compiler now accepts the "invariant() {}" syntax, so
- Michel Fortin (10/12) Apr 12 2009 Actually, I was just converting some D1 code to D2 (with no intention
- Walter Bright (2/4) Apr 12 2009 I see no point to breaking invariant() again.
- Kristian Kilpi (8/12) Apr 13 2009 Will 'invariant' as a type modifier go away? If so, then of course the
- Stewart Gordon (4/6) Apr 12 2009 Where do you get that idea from???
- Michel Fortin (13/19) Apr 12 2009 D 2.020's changelog:
- Stewart Gordon (9/18) Apr 13 2009 My first reaction was to look for documentation on what the keyword
- Kagamin (2/4) Apr 13 2009 It's a function :)
- Don (2/8) Apr 13 2009 So is unittest.
In D1 you had to write: invariant { ... } while in D2, to disabiguate with invariant being overloaded with immutability you had to write: invariant() { ... } Now that the use of the invariant keyword in D2 has returned to its single original meaning of class invariant, is there still a reason for it to require an empty parenthesis? Should I fill a bug? -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Apr 12 2009
在 Sun, 12 Apr 2009 20:57:28 +0800,Michel Fortin <michel.fortin michelf.com> 写道:In D1 you had to write: invariant { ... } while in D2, to disabiguate with invariant being overloaded with immutability you had to write: invariant() { ... } Now that the use of the invariant keyword in D2 has returned to its single original meaning of class invariant, is there still a reason for it to require an empty parenthesis? Should I fill a bug?It will be good if it will be the same in both D1 and D2 -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Apr 12 2009
On Sun, Apr 12, 2009 at 8:57 AM, Michel Fortin <michel.fortin michelf.com> wrote:In D1 you had to write: =A0 =A0 =A0 =A0invariant =A0 =A0 =A0 =A0{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0... =A0 =A0 =A0 =A0} while in D2, to disabiguate with invariant being overloaded with immutability you had to write: =A0 =A0 =A0 =A0invariant() =A0 =A0 =A0 =A0{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0... =A0 =A0 =A0 =A0}Actually, the D1 compiler now accepts the "invariant() {}" syntax, so if you want your code to work with both D1 and D2, use that. Whether it'll be going away, I'm not sure. I guess Walter is the only one who knows that.
Apr 12 2009
On 2009-04-12 10:29:52 -0400, Jarrett Billingsley <jarrett.billingsley gmail.com> said:Actually, the D1 compiler now accepts the "invariant() {}" syntax, so if you want your code to work with both D1 and D2, use that.Actually, I was just converting some D1 code to D2 (with no intention of keeping it D1-compatible) and had to change a few of them, which made me wonder whether Walter has considered reversing this change to D2 now that the reason for doing it has disappered. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Apr 12 2009
Jarrett Billingsley wrote:Whether it'll be going away, I'm not sure. I guess Walter is the only one who knows that.I see no point to breaking invariant() again.
Apr 12 2009
On Sun, 12 Apr 2009 22:00:43 +0300, Walter Bright <newshound1 digitalmars.com> wrote:Jarrett Billingsley wrote:Will 'invariant' as a type modifier go away? If so, then of course the parentheses could be dropped out from the class invariant. Or, both the syntaxes ('invariant {}' and 'invariant() {}') could be supported (imho, only one syntax would be better though). Currently the syntaxes of the class invariants and unit tests are a bit inconsistent, and I don't like it too much. :)Whether it'll be going away, I'm not sure. I guess Walter is the only one who knows that.I see no point to breaking invariant() again.
Apr 13 2009
Michel Fortin wrote: <snip>Now that the use of the invariant keyword in D2 has returned to its single original meaning of class invariant,Where do you get that idea from??? Stewart.
Apr 12 2009
On 2009-04-12 19:08:08 -0400, Stewart Gordon <smjg_1998 yahoo.com> said:Michel Fortin wrote: <snip>D 2.020's changelog: - immutable now is implemented. I though this meant that invariant was replaced by immutable as a type modifier. Apparently, it was not: invariant can still be used as a synonym to immutable. This also makes: (invariant int).stringof == "immutable(int)" So I guess I should change my initial question: is this use of invariant going to be kept indefinitely? -- Michel Fortin michel.fortin michelf.com http://michelf.com/Now that the use of the invariant keyword in D2 has returned to its single original meaning of class invariant,Where do you get that idea from???
Apr 12 2009
Michel Fortin wrote: <snip>D 2.020's changelog: - immutable now is implemented. I though this meant that invariant was replaced by immutable as a type modifier.My first reaction was to look for documentation on what the keyword means and have no success. And so I filed this.... http://d.puremagic.com/issues/show_bug.cgi?id=2572Apparently, it was not: invariant can still be used as a synonym to immutable.<snip> If it meant that invariant had been removed, then that's what it would've said. Stewart.
Apr 13 2009
Michel Fortin Wrote:is there still a reason for it to require an empty parenthesis?It's a function :)
Apr 13 2009
Kagamin wrote:Michel Fortin Wrote:So is unittest.is there still a reason for it to require an empty parenthesis?It's a function :)
Apr 13 2009