Re: Program logic bugs vs input/environmental errors
On Saturday, 18 October 2014 at 17:55:04 UTC, Walter Bright wrote: On 10/18/2014 9:01 AM, Sean Kelly wrote: So you consider the library interface to be user input? The library designer has to make that decision, not the language. What about calls that are used internally but also exposed as part of the library interface? The library designer has to make a decision about who's job it is to validate the parameters to an interface, and thereby deciding what are input/environmental errors and what are programming bugs. Avoiding making this decision means the API is underspecified, and we all know how poorly that works. Consider: /** * foo() does magical things. * Parameters: * x a value that must be greater than 0 and less than 8 * y a positive integer * Throws: * Exception if y is negative * Returns: * magic value */ int foo(int x, int y) in { assert(x > 0 && x < 8); } body { enforce(y >= 0, "silly rabbit, y should be positive"); ... return ...; } Contract Programming. Contract-rider list all required for this item api conditions. In that case is a list of exseption handler on client side. Epic sample of first post, may be like this: in {rider(except, "this class may trowing io exception, you must defined ...") }
Re: Program logic bugs vs input/environmental errors
On Monday, 20 October 2014 at 20:36:58 UTC, eles wrote: On Saturday, 18 October 2014 at 17:40:43 UTC, Walter Bright wrote: On 10/18/2014 8:21 AM, Jacob Carlborg wrote: On 2014-10-18 07:09, Walter Bright wrote: Which means they'll be program bugs, not environmental errors. Yes, but just because I made a mistake in using a function (hitting an assert) doesn't mean I want to have undefined behavior. As I've said before, tripping an assert by definition means the program has entered an unknown state. I don't believe it is possible for any language to make guarantees beyond that point. What about using the contracts of a fucntion to optimize? They are mainly asserts, after all. this(errnoEnforce(.fopen(name, stdioOpenmode), text("Cannot open file `", name, "' in mode `", stdioOpenmode, "'")), name); making a couple instances of classes not knowing whether they are necessary at all, the performance did not cry. And why do you have all type of cars. Is it really you are so good compiler? What about using the contracts of a fucntion to optimize? They Its linking time. is possible for any language to make guarantees beyond that Of cous no, I will explain later 2-3 hour/ Sorry bisnes offtop: string noexist_file_name = "bag_file_global"; {writefln("-- begin scope: after"); auto fobj = File(noexist_file_name); scope(failure) writefln("test1.failure"); scope(exit) writefln("test1.exit"); } std.exception.ErrnoException@std\stdio.d(362): Cannot open file `bag_... --- 5 line with only a memory addr 0x7C81077 in RegisterWaitForInputIdle i think you need stoped after first errmsg see exception.d: in constructor or class ErrnoException : Exception
Re: Program logic bugs vs input/environmental errors
On Tuesday, 21 October 2014 at 03:25:55 UTC, rst256 wrote: In this post i forgot make correction machine translation. I am so sorry! On Monday, 20 October 2014 at 20:36:58 UTC, eles wrote: On Saturday, 18 October 2014 at 17:40:43 UTC, Walter Bright wrote: On 10/18/2014 8:21 AM, Jacob Carlborg wrote: On 2014-10-18 07:09, Walter Bright wrote: Which means they'll be program bugs, not environmental errors. Yes, but just because I made a mistake in using a function (hitting an assert) doesn't mean I want to have undefined behavior. As I've said before, tripping an assert by definition means the program has entered an unknown state. I don't believe it is possible for any language to make guarantees beyond that point. What about using the contracts of a fucntion to optimize? They are mainly asserts, after all. this(errnoEnforce(.fopen(name, stdioOpenmode), text("Cannot open file `", name, "' in mode `", stdioOpenmode, "'")), name); making a couple instances of classes not knowing whether they are necessary at all, the performance did not cry. And why do you have all type of cars. Is it really you are so good compiler? What about using the contracts of a fucntion to optimize? They Its linking time. is possible for any language to make guarantees beyond that Of cous no, I will explain later 2-3 hour/ Sorry bisnes offtop: string noexist_file_name = "bag_file_global"; {writefln("-- begin scope: after"); auto fobj = File(noexist_file_name); scope(failure) writefln("test1.failure"); scope(exit) writefln("test1.exit"); } std.exception.ErrnoException@std\stdio.d(362): Cannot open file `bag_... --- 5 line with only a memory addr 0x7C81077 in RegisterWaitForInputIdle i think you need stoped after first errmsg see exception.d: in constructor or class ErrnoException : Exception
Re: Program logic bugs vs input/environmental errors
https://en.wikipedia.org/wiki/Code_smell Do you read this? Yes phobos.stdio very smell code. Disagree? 107 КБ of source code olny for call few functions from stdio. Are you sure that this code are full correctly? "silly rabbit, y should be positive" - may be becose his used class like this? the funny thing is that this code can easily be written machine based on a few rules and header. Say that do you think about this code model File("output"){ ... some file operation ... }else{ ... optional if defined handle error ... } ... this not class instance, is macrodef. And "output" is not a file, this external resurce. His may binded to commandline arg (-output), static file and gui(just set asign property in design form editor). May be get from network. That is cool, about this i can say: "Take it to bank". Gui on macros like this may create very quick. File declare as subject not class (eg in json format) you anyway build it from exists function. example: File = { export: [ export list ] blocks: { main:{}, else: {} }, } Firshtein? see https://en.wikipedia.org/wiki/Subject-oriented_programming how this make on jscript https://github.com/jonjamz/amethyst
Re: Who pays for all this?
On Tuesday, 7 October 2014 at 01:11:42 UTC, Shammah Chancellor wrote: On 2014-10-06 22:28:52 +, Andrei Alexandrescu said: On 10/6/14, 12:59 PM, Shammah Chancellor wrote: I'm willing to put in the work if Walter is on board also. I don't want to do all that work to end up being a DPL Foundation in name only. That's very generous of you, thanks! We'll discuss this. From what I read at http://lwn.net/Articles/561336/, my understanding is that we'll need significant ongoing expenses in additional to the initial setup expenditure of time and money. Anyone who knows more about this please chime in. -- Andrei I'll start doing some research. To be forward, I am 100% ignorant of the process at the moment as well. -S. Very good idea. If you want i can help you. I can suggest a few directions of to explore. Source code toolkit: analytic, transformation... I see this as script engine like js(dmdscript?) with extension for access to source code in object form, like this: void foo(int i){ int e; if(i<0){ e = i; } write("yes we can!"); } for script to be { functions:{ foo:{ arg: {i: {type: int, default:no }, body:[ {stament: "var_declare", name:"e", type: "int", default: no}, {stament: "if", expression: "how it do this help!", /* how named main code block? */ block: {} else: no }, {stament: "call", name:"write", arglist: ["yes we can!"]} ] } } } Yes already have similar solutions but they usually focus on a static analysis of the code in one language. But may be this is an expandable basis to do much more: code analysis, refactoring a large project simply by answering the wizard's questions, a project update for the new api, and my favorite migration between languages. Migration between languages - this i think is especially impotant because if you have project greater than hello word you will actually slave chosen programming language. Let's liberate the algorithms of their actual implementation and developers from the monotonous work! Very wrong if you code on the 90% is a wrapper, polymorphism, or has long been created.
Re: Program logic bugs vs input/environmental errors
in the extreme case, if you want to change anything. or as a way to shut problem quickly add to debugging symbols generation algorithm info about file and line - Walter?
Re: Array bound checks removal increasing importance
On Saturday, 31 May 2014 at 23:30:41 UTC, Walter Bright wrote: On 5/31/2014 4:06 PM, "Nordlöw" wrote: I've looked around in DMD for a suitable place to add checks for this but haven't found the spot where range-check is injected. Help anyone? There isn't a suitable place. To make it work, data flow analysis would have to be added to the front end. While doable, this is not a simple addition. Eventually, we'll have to do it as a lot of things become possible & better with data flow analysis, not just bounds check elimination. I just wanted to check the possibility of more cost-free checking array bounds. For development researches possible to disable the check? Of couse its not critical, Monkey patch, replace call on nup But you must understand that this can distort test result. This checking bounds method of couse for using only after all debuging works is done. His bassed on print a stack trace in signal handler, or if it is release code programmer wish to call crashe responce application. by the way this can optimize program code Because in any case, application be closed.
Re: Algorithms to solve programming contest problems
On Saturday, 25 October 2014 at 20:51:04 UTC, Walter Bright wrote: http://www.quora.com/What-are-the-algorithms-required-to-solve-all-problems-using-C++-in-any-competitive-coding-contest Anyone want to review these and see what we should add to Phobos? Dear Mr. Bright. Just can not now comment. Please see this code. test code and profililing log. src\phobos\std\stdio.d: lines 361-373 --- */ /*file and line in this is demo solve. Just for profilling. I now more safety way. */ this(string name, in char[] stdioOpenmode = "rb", string file = __FILE__, size_t line = __LINE__) @safe { import std.conv : text; import std.exception : ErrnoException; /*this(errnoEnforce(.fopen(name, stdioOpenmode), text("Cannot open file `", name, "' in mode `", stdioOpenmode, "'")), name); */ if (!.fopen(name, stdioOpenmode)) throw new ErrnoException(text("Cannot open file `", name, "' in mode `", stdioOpenmode, "'"), file, line); } file.d(test code)--- import std.stdio; void main(string[] args) { /*int i; int a[2]; if(true) i = 3; a[i] = 3;*/ auto fobj = File("hello2.d"); scope(failure) writefln("scope(failure)"); scope(exit) writefln("scope(exit)"); writefln("end"); } profiler log for file.d with old version phobos-- -- 1 _Dmain 7 main _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa 8 89 80 8 _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv -- 8 _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv 8 9 9 -- 1 main _Dmain 1 4083190740831897 1 _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa -- main0 0 0 1 _Dmain 7 _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa Timer Is 3579545 Ticks/Sec, Times are in Microsecs Num TreeFuncPer CallsTimeTimeCall 1114070101140700711407007 _Dmain 8 24 22 2 pure nothrow char[] object._dup!(const(char), char)._dup(const(char)[]) 8 2 2 0 pure nothrow @nogc void object._doPostblit!(char)._doPostblit(char[]) 1 0 0 0 main new version--- -- 1 _Dmain 7 main _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa 8 102 88 8 _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv -- 8 _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiAaZv 8 14 14 -- 1 main _Dmain 1 2336665 2336654 1 _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa -- main0 0 0 1 _Dmain 7 _D6object14__T4_dupTxaTaZ4_dupFNaNbAxaZAa Timer Is 3579545 Ticks/Sec, Times are in Microsecs Num TreeFuncPer CallsTimeTimeCall 1 652782 652779 652779 _Dmain 8 28 24 3 pure nothrow char[] object._dup!(const(char), char)._dup(const(char)[]) 8 3 3 0 pure nothrow @nogc void object._doPostblit!(char)._doPostblit(char[]) 1 0 0 0 main I not check the other functions, because not sure that this style of coding is enough object oriented. It object only because that here you have objects. if you need it, let's work. Best regards.
Re: Algorithms to solve programming contest problems
On Sunday, 26 October 2014 at 20:58:39 UTC, Martin Nowak wrote: On 10/26/2014 02:37 AM, Vic wrote: JRE has Oracle and 100 devs, CLR has MS and 100 dec, there are 7 for D, and it should be narrow, like LUA. It should have 7% of their platform. Majority of scared cows must be killed, the sooner leaders realize the better. I'd actually also like to see less things being stuffed into phobos. Now that we have dub and code.dlang.org the benefit of adding something to phobos instead of maintaining it as a separate library is much smaller. And we already have some Please tell us more. Separation libraries may accelerate the program's execution, or only compilation speed? unmaintained/problematic modules in phobos that would be better as external libraries (std.signals, std.net.curl, std.xml).
Re: C++ developer choices in open source projects
On Wednesday, 29 October 2014 at 22:40:33 UTC, Paulo Pinto wrote: Am 29.10.2014 um 23:27 schrieb eles: On Wednesday, 29 October 2014 at 22:03:52 UTC, Paulo Pinto wrote: Am 29.10.2014 um 17:05 schrieb Russel Winder via Digitalmars-d: On Wed, 2014-10-29 at 15:09 +, eles via Digitalmars-d wrote: […] http://concepts.axiomatics.org/~ans/ Andrew's work on Concepts Lite may prove to be the saving of C++ templates… For those willing to wait until circa 2020. :( C'mon, the TR's are promised far sooner. Ubisoft presentation at CppCon and also the reality I knew as C++ dev: "Our standard is what all target compilers support". -- Paulo Hi Paulo. Amazingly, but i understand your feelings. Maybe I can help you, that compiler do you need? Seem you mentioned the Managed C++ ()?
Re: C++ developer choices in open source projects
On Thursday, 30 October 2014 at 08:03:30 UTC, Paulo Pinto wrote: On Thursday, 30 October 2014 at 04:51:33 UTC, rst256 wrote: On Wednesday, 29 October 2014 at 22:40:33 UTC, Paulo Pinto wrote: Am 29.10.2014 um 23:27 schrieb eles: On Wednesday, 29 October 2014 at 22:03:52 UTC, Paulo Pinto wrote: Am 29.10.2014 um 17:05 schrieb Russel Winder via Digitalmars-d: On Wed, 2014-10-29 at 15:09 +, eles via Digitalmars-d wrote: […] http://concepts.axiomatics.org/~ans/ Andrew's work on Concepts Lite may prove to be the saving of C++ templates… For those willing to wait until circa 2020. :( C'mon, the TR's are promised far sooner. Ubisoft presentation at CppCon and also the reality I knew as C++ dev: "Our standard is what all target compilers support". -- Paulo Hi Paulo. Amazingly, but i understand your feelings. Maybe I can help you, that compiler do you need? Seem you mentioned the Managed C++ ()? I don't get from where you got the point I am looking for compilers. sent to you by mistake. I'm sorry