digitalmars.D.learn - Implementing Design by Contract using GOTO and R(unTime)FE
Hi, what I want to do is to implement Design by Contract only by using *goto* and RTFE (RunTime Function Evaluation) You may wonder why. Short answere is that I am writing a book about OOP in Windev; and DBC should be part of the documentation. Windev s GOTO features are similar to D s. CTFE is not available instead R(untime)TFE, because the Windev compiler is part of a DLL you have to deploy anyway. Just an example : procedure x(parameter is int) toCompile is string toCompile = "r is bool;if parameter > 10 then r = false else r = true;return r" Compile("DummyFunction", toCompile") // Dummufuntion is a /virtual function/ i mean not comparable to D CTFE //Some Windev internals not relevant to understand the code... IF DummyFunction() then GOTO label1 ELSE GOTO label2 END Do you think that I can, based on these 2 language constructs, implement something similar to DBC ?? Many thanks in advance , (and sorry for beeing Off Topic) Bjoern
Jun 12 2007
BLS schrieb:Hi, what I want to do is to implement Design by Contract only by using *goto* and RTFE (RunTime Function Evaluation) You may wonder why. Short answere is that I am writing a book about OOP in Windev; and DBC should be part of the documentation. Windev s GOTO features are similar to D s. CTFE is not available instead R(untime)TFE, because the Windev compiler is part of a DLL you have to deploy anyway. Just an example : procedure x(parameter is int) toCompile is string toCompile = "r is bool;if parameter > 10 then r = false else r = true;return r" Compile("DummyFunction", toCompile") // Dummufuntion is a /virtual function/ i mean not comparable to D CTFE //Some Windev internals not relevant to understand the code... IF DummyFunction() then GOTO label1 ELSE GOTO label2 END Do you think that I can, based on these 2 language constructs, implement something similar to DBC ?? Many thanks in advance , (and sorry for beeing Off Topic) BjoernJust to make it complete and HTH to help me :-) : //Of course I can also pass the toCompile string to procedure x : like val is int = 4 toComp is string = "r is bool;if parameter > 10 then r = false else r = true;return r" if x(val, toComp) then trace("OkeeDokee") end
Jun 12 2007