Re: Breaking changes in Visual C++ 2015
On 05/08/2015 06:58 PM, Walter Bright wrote: On 5/8/2015 2:51 PM, deadalnix wrote: The way you end runnign all kind of test with the ones you are interested in makes no sense. dmd std/path -unittest -main runs just the unit tests in std/path. You can run tests in some modules, but not others, with: dmd -c a b c -unittest dmd d e f a.o ./d That breaks most build systems, including rdmd.
Re: Lambda functions in D
On 05/09/2015 05:52 PM, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 14:15:21 UTC, Ali Çehreli wrote: On 05/09/2015 04:59 AM, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 11:49:48 UTC, Timon Gehr wrote: assert((function int(int x)=x?x*__traits(parent,{})(x-1):1)(10)==3628800); Thanks. Yes, it is similar to what I wanted :) Also interesting: http://rosettacode.org/wiki/Y_combinator#D I think that code was improved by Timon Gehr as well. Ali Yes, it's much better. Well, it is much slower due to all the allocated closures, owed to the fact that the implementations of 'fix' on that page are expected to mirror a particular famous implementation in untyped lambda calculus. In case you have a use for 'fix', a more efficient implementation might be: auto fix(S,T...)(S delegate(T) delegate (S delegate(T)) f){ S delegate(T) g=(T a){ assert(0,f is too eager.); }; return g=f((T a)=g(a)); } (In particular, this will only allocate two closures for the plumbing instead of a number of them linear in the number of recursive invocations.) Even something like Common Lisp. (Be aware that Common Lisp implementations typically have better garbage collectors than what is available for D.)
Re: New adapter: std.allocator.quantizer
On 05/10/2015 12:38 AM, Timon Gehr wrote: 142| return parent.reallocate(b, gs); 172| return parent.alignedReallocate(b, gs, a); (Note that those code snippets also occur in their documentation.)
Re: How to translate this to D: const char *const* someConstPtr;
The second const isn't needed in D, the first one will carry through for it too. const char* in D is equivalent to that C declaration. const(char)* in D is what const char* in C would be.
Re: Spawning a console in Windows (similar to forkpty on linux)
On Saturday, 9 May 2015 at 13:00:01 UTC, wobbles wrote: On Linux, I'm able to edit a file descriptor after I've created it to tell it to read/write asynchronously, I cant seem to find anything similar on windows however. Asynchronous I/O on Windows is called Overlapped I/O. It is a bit involved to use though, especially since D by default doesn't come with all the necessary headers. You can download the win32 api bindings or you can just declare the bits as needed. My terminal emulator uses overlapped I/O and a spawned process (and on Linux, it uses forkpty!) to talk to ssh on Windows. https://github.com/adamdruppe/terminal-emulator/blob/master/terminalemulator.d I had to write a function to make an async pipe, then spawn a process using them, then get and send data. I also declared all the needed functions myself. A lot of code to go through but it is a working example... a few things to look for are MyCreatePipeEx, CreateProcess, the word 'overlapped', ReadFileEx, and the simpledisplay.d library it imports also uses SleepEx which lets other things trigger.
Re: Header Files
On Sat, 09 May 2015 21:09:33 -0400, Ali Çehreli acehr...@yahoo.com wrote: On 05/09/2015 07:01 AM, bitwise wrote: ./main.d ./pack/foo.d ./pack/sub/bar.d dmd main.d pack/foo.d pack/sub/bar.d -ofTest -H This dumps all the *.di files into the output directory ignoring the directory structure. Is there some rational for it being this way? Wouldn't it be much more useful if directories were preserved? Bit As far as I know, every other similar tool works the same way: $ gcc -c foo/foo.c foo.o is outputted to the current directory. The common solution that I know is to use makefiles to manage file dependencies. For example, the rule for .di specifies the file that it depends on (the .d corresponding to that .di) and 'make' handles it automatically. Ali I'm not sure I understand what you mean, but my point is, that as is, this feature of DMD is broken. If people are successfully using dmd -H right now, they must not be using packages, or their 'package.di' files would be overwritten. So I'm wondering if I should do a PR to fix this. Bit
Re: RFC: Pay-as-you-go, Portable D Runtime for Microcontrollers (and maybe more)
On Thursday, 7 May 2015 at 14:48:08 UTC, Jens Bauer wrote: I already have supplied those options in my toolchain. But does anyone know if this is advisable when using FreeRTOS (or any other RTOS for that matter) ? -I'm asking, because I'm not using any RTOS myself, but there are loads of people who do. In order to make the full stack in D, I think we eventually will need to make 2 toolchains: a bare-metal kernel toolchain, and an application programming toolchain. The bare-metal kernel toolchain would not have some of the high-level features of D, like threading and synchronization, as that has yet to be built. However, once a D RTOS is created with all necessary features for theading and synchronization, then the application programming toolchain can be made with a druntime ported the D RTOS's API. I've also considered another interesting approach. It seems possible to port all features of D right to the metal, essentially embedding the RTOS directly into the runtime. Then D is your RTOS :-) Mike
Re: how does 'shared' affect member variables?
On Sat, 09 May 2015 21:32:42 -0400, Mike n...@none.com wrote: it looks like what you are trying to implement is what `synchronized` already provides: http://ddili.org/ders/d.en/concurrency_shared.html#ix_concurrency_shared.synchronized Mike Yes, but synchronized uses a mutex. Spin locks can perform better in situations where there won't be much contention for the lock. Bit
Re: New adapter: std.allocator.quantizer
On 5/9/15 3:41 PM, Timon Gehr wrote: On 05/10/2015 12:38 AM, Timon Gehr wrote: 142| return parent.reallocate(b, gs); 172| return parent.alignedReallocate(b, gs, a); (Note that those code snippets also occur in their documentation.) Can't find gs in the doc comments, is it there? -- Andrei
Re: Breaking changes in Visual C++ 2015
On Friday, 8 May 2015 at 22:57:54 UTC, Walter Bright wrote: It works perfectly fine and obviates the need to create a separate test harness. As long as you are doing trivial toy programs, that is perfect. Try using gcov without going back to consult the manuals on it. Even if you have it installed. Coverage analyzers in other languages that I checked all required finding and installing some extra package, then trying to figure out how to hook it in. As mentioned elsewhere one want to compared itself to the guy in town, not the drunk hobbo. Last but not least, things like: if (foo bar) ...; Contains 2 branches. The output we have to not provide data about this, which makes the coverage infos lacking in some regard. Check before assuming -cov does it wrong. You'll find it counts the branches separately. It does sum them for the line count, but writing it as: if (foo bar) you'll get two counts. What I am disappointed in is the repeated default assumption, without bothering to check, that D's tools are guilty until proven innocent. My bad. It is still clowny that I have to format my code in a particular way to get that result. Not formatting my code that way, I never noticed that the result even existed in the first place. But still, that is clowny and confirms the general impression that these tools are bad. See, there are iPhone and nokia phones. They do the same thing: they load web pages, they do phone calls and sms, they runs various apps and so on. An iPhone more than twice the price of a nokia lumia. Still, people are willing to wait in line to buy the new iPhone while nokia is going bankrupt. Why is that ? Because in one case, the damn thing is thought through to the most insignificant details once the other works and that's good. You can do this if you format you code in some bizarre way is a bad excuse and nothing else. In java for instance, I could run tests (and not the whole program with test at startup) and get all the coverage infos directly in my editor with colors and stuff, include things like short circuit for boolean operators, which we don't have. We are miles (kilometers damn it !) away from this level of support. Here's a slice of a D coverage report: |static if (allSatisfy!(hasMobileElements, R)) |{ |RvalueElementType moveAt(size_t index) |{ 6|foreach (i, Range; R) |{ |static if (isInfinite!(Range)) |{ 000|return .moveAt(source[i], index); |} |else |{ 3|immutable length = source[i].length; 5|if (index length) return .moveAt(source[i], index); 1|index -= length; |} |} 000|assert(false); |} |} std\range\package.d is 91% covered It's not in color, I concede that. Saying this report is miles behind is ludicrous, besides the incorrect statement that short circuits are not supported. Color are beside the point. That is a good report. That is still miles behind what you can have in java for instance. I can't have the coverage per test case, to know what test is testing what for instance (which is arguably mostly due to how tests are ran in the first place). It does give me information depending on the formatting of my code. These may not seems like important things, but that is what makes the difference. 4. profiler Same things, this is a standard tool nowaday for any language worth considering. In fact, even if we had no specific support in D for it, C/C++ tooling could probably do it for us to some extent. Yah, I know about gprof. Try it (with a C or C++ program), without spending time with the manuals. Here's the manual for D: dmd -profile foo 1/ I usually use callgrind based tools rather than gcov, and then I can explore the result with something like KCacheGrind which can show me the informations in all kind of forms. http://edinburghhacklab.com/wp-content/uploads/2012/04/kcachegrind.png Not only this is more convenient to explore the data, but I get the same tool to work with PHP, C++ or whatever else. On the other hand, I have something like: $ cat trace.log -- 1 main _Dmain 1 45 45 -- main0 0 0 1 _Dmain Timer Is 3579545 Ticks/Sec, Times are in Microsecs Num TreeFuncPer CallsTimeTimeCall 1 12 12 12 _Dmain 1 0 0 0 main For reference, the format used is named callgrind and many tools can manipulate it: http://valgrind.org/docs/manual/cl-format.html 2/ Tested on SDC's test runner, it makes the test runner
Re: Breaking changes in Visual C++ 2015
On 5/9/2015 12:30 PM, Iain Buclaw via Digitalmars-d wrote: For the sake of argument (and genuine interest). I'd like to see a comparison of DMD coverage versus GDC coverage reporting. ie: Does DMD pick up anything GDC doesn't? Are there areas where GDC is more clearer? Color reports, html reports, all that is 1%. The largest problem we face with dmd -cov is simply getting people to use it as a matter of course. I know that it is not being used pervasively because when I run Phobos unit tests with -cov, large swaths of code are not tested. dmd -cov=nn will also cause the generated executable to exit with an error if the coverage is below nn%. I'd like this to be part of the the autotester so that backsliding can be detected automatically, but that's not on dmd, it's on how the test suite is put together and scripted.
Re: Calypso milestone hit: D adaptation of Qt5 tutorial working
On Saturday, 9 May 2015 at 19:16:33 UTC, Elie Morisse wrote: On Saturday, 9 May 2015 at 02:58:58 UTC, Mike wrote: Question: You are using a modified version of LDC, but is that compiler required to consume link to a library created with that custom compiler? What I mean is: Can you use this modified version of LDC to create a library, and then use a generic D compiler to build an application that links to that library? If you manage to hide every C++ symbol from the normal compiler I should have said, sorry for the vague answer. Linking would work like with normal D libraries, but the .d or .di files parsed by the normal compiler would have to be emptied of C++ imports so any symbol those imports provided shouldn't appear in the .di file.
Re: New adapter: std.allocator.quantizer
On 05/09/2015 06:09 PM, Andrei Alexandrescu wrote: On 5/9/15 6:27 AM, Timon Gehr wrote: On 05/07/2015 11:12 PM, Andrei Alexandrescu wrote: Helps an allocator without good reallocation capabilities: http://erdani.com/d/phobos-prerelease/std_experimental_allocator_quantizer.html Destruction welcome. Andrei quantizer.d is not in the commit: https://github.com/andralex/phobos/commit/1b75d3e9dfc37f1d074e217dee2931463dec5191 How embarrassing. Thanks for letting me know. https://github.com/D-Programming-Language/phobos/commit/c23913b9082a4dda9156314645e011eaa0a3af8c Andrei Thanks! Looks good, except: 106| if (!parent.expand(b, goodAllocSize(needed) - b.length)) 142| return parent.reallocate(b, gs); 172| return parent.alignedReallocate(b, gs, a); Those should be more like: 182| parent.deallocate(b.ptr[0 .. goodAllocSize(b.length)]); Another point is that the documented/checked constraints on the rounding function are too weak. A rounding function should be monotone increasing and piecewise constant with one fixed point per piece. In case the given function does not have those properties, a call to 'expand' can destroy the invariant that the memory block of b is always of size goodAllocSize(b.length). And then, there's this, of course: size_t goodAllocSize(size_t n); Returns roundingFunction(n). It is required that roundingFunction(n) = n. For efficiency reasons, this is only asserted (checked in debug mode). Is this meant to be a complete specification of 'assert'? :o) What is 'debug mode'?
Re: Breaking changes in Visual C++ 2015
On Saturday, 9 May 2015 at 22:44:28 UTC, Walter Bright wrote: Build systems cannot handle giving different compile flags to different files? Back to using 'make' :-) Compiling different object files with different version flags is current illegal in D and may result in linking errors.
Re: Spawning a console in Windows (similar to forkpty on linux)
On Saturday, 9 May 2015 at 18:19:16 UTC, Baz wrote: You need a loop that run until the PID is invalid. You could also call WaitForSingleObject on the process handle https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032%28v=vs.85%29.aspx The HANDLE it expects can be gotten from std.process with this http://dlang.org/phobos/std_process.html#osHandle But then you'll block for it to end so it probably isn't what you really want...
Re: How to translate this to D: const char *const* someConstPtr;
On 05/09/2015 04:18 PM, ParticlePeter wrote: const char *const* someConstPtr; Disecting: 1) const char : There are these chars that cannot be modified 2) * : There are these pointers to such const chars. 3) const: Those pointers cannot point to anything else 4) * : There are these pointers that can point to previously described pointers. The following are the D equivalents, adding more at each step: 1) const(char) 2) const(char)* 3) const(const(char)*) 4) const(const(char)*)* As Adam Ruppe said, the first const (the inner-most in the D version) is redundant: const(char*)* Ali
Re: The most awesome forward to member solution?
On Sunday, 3 May 2015 at 00:19:37 UTC, Andrei Alexandrescu wrote: Hey folks, So in working with the allocator, a common matter has come again to the fore: I need to forward certain functions to a member. So I'm thinking of defining a mixin that would be used like this: struct FreeTree(ParentAllocator) { ... mixin(forwardIfDefined(parent, expand, reallocate, allocateAll)); } This was very useful, by the way, with synchronicitous timing. I have various derivative instruments made up of legs. For example an interest rate swap where I pay fixed cash flows on one leg and receive floating cash flows on another. So each swap leg is itself an entity (I made them structs), and there are a collection of such legs (of differing types) comprising a swap (or FRA, FX trade etc). The parent entity (eg a swap with a fixed leg and a float leg; or with two float legs) needs to forward calls to the legs. Eg if you change the notional or maturity of the parent, you probably want to change the notionals of the component legs, although in special cases they might be different. I don't want to muck about with Byzantine inheritance systems I won't likely myself remember in a year (people seem to underrate the value of coherence these days, and fragmentation doesn't help). On the other hand I didn't fancy writing lots of boilerplate code just to forward calls to each leg (or to only one where it made sense). So I modified forwardToMember to forwardToLegs (I need to return a Swap object, since I want to return the Swap for UFCS and the calls to leg methods return the leg itself). setMaturityDate(DateTime maturity( calls fixLeg.setMaturity(maturity) and floatLeg.setMaturity. And setFloatMaturity(DateTime maturity) just calls floatLeg.setMaturity(maturity) - ie the call is remapped to a different name when forwarding, so the user doesn't need to get her hands messy with the nitty gritty of the individual legs. So now all the glue logic is specified in simple arrays that produce the requisite code at compile time. It's easy to see what is going on, maintainable, and the parents are only a very spaced-out 100 lines. So thank you for this, and for all the other nice features in D.
Re: Breaking changes in Visual C++ 2015
Contrived example: // mymod.h #ifdef UseFloat extern float x; #else extern int x; #endif // main.c #include stdio.h #include mymod.h void main() { x = 0; printf(%d\n, x); } Compile commands: gcc -c mymod.c gcc -c -DUseFloat main.c# -- oops gcc main.o mymod.o The thing is, every day I compile some modules with -unittest, and some without, and link together together. Even if the ones without -unittest are the linked in Phobos modules. The autotester does it all day every day, too. If this didn't work, D's unit tests indeed would be rather useless.
Re: Breaking changes in Visual C++ 2015
On 5/9/2015 6:25 PM, Dicebot wrote: https://issues.dlang.org/show_bug.cgi?id=13454 Thanks for the link. Thought it best to reply there.
[Issue 13454] Unit tests should be compiled in a module, where they are declared
https://issues.dlang.org/show_bug.cgi?id=13454 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #7 from Walter Bright bugzi...@digitalmars.com --- When designing unit tests for templates, a decision must be made: 1. are the unit tests to be run for specified instantiations only? 2. are the unit tests to be run for all instantiations? For (1), put them outside the template body. For (2), put the unit tests inside the template body. In the example code, the unit test code is in both places and both are expected to exist, and as you discovered, such does not work. The solution is either put all the unit test code outside the template for option (1), or all inside for option (2). I almost always go with (1) for my template code, and it works fine. It's questionable that duplicating tests for each instantiation of a template is intended. Right, that's the (1) or (2) decision above, and only the programmer can make that decision. too many issues with random imports bad practice -- version (unittest) import std.stdio; unittest { writeln(hello); } better practice - unittest { import std.stdio; writeln(hello); } --
Re: duml to generate UML diagrams in HTML format
On 10/05/2015 1:44 a.m., tcak wrote: On Saturday, 9 May 2015 at 11:58:41 UTC, Rikki Cattermole wrote: On 9/05/2015 11:43 p.m., Rikki Cattermole wrote: On 9/05/2015 11:40 p.m., tcak wrote: On Saturday, 9 May 2015 at 11:37:57 UTC, Rikki Cattermole wrote: On 9/05/2015 11:32 p.m., tcak wrote: I have created my first project in github, and I wanted to share it. https://github.com/tcak/duml I started working on it today morning, and completed in midday. But it is still in very early stages. So, I wanted to take thoughts of you guys. Purpose of this project is to put XML based comments into a text file (source code for programmers), and it generates UML diagram in a single HTML file. This is the result of duml's own source code at this point: http://imgur.com/0kfK9Xu Do you guys think that this will be any use as a D tool maybe? I am planning to add activity decisions, and linking actions to other HTML files. So, a general function that uses sub functions can link to activity diagram of those functions as well. Awkward. https://github.com/rikkimax/duml Whops! I better change name of mine to DUML: Age of Ultron Haha! Yeah just make it a little unique to the project and it'll be all good. After all, no need to confuse a dead end project and one that has a good chance of being used ;) Just to make sure since no reply. Mine is the dead end one. :) I was outside. Lastly, only one year ago it was updated. I don't think it is that much dead. Problem is being able to make use of tools. When nobody cares, even the best tool doesn't have any importance. Nah, the wrong approach was to use CTFE. Instead the right approach would be adding a new step in the compile process and lexing ext. the files.
Re: New adapter: std.allocator.quantizer
On 5/9/15 3:54 PM, Timon Gehr wrote: On 05/10/2015 12:38 AM, Timon Gehr wrote: monotone increasing and piecewise constant with one fixed point per piece. (Note that monotone increasing is implied by piecewise constant with one fixed point per piece, so it does not necessarily need to be documented separately.) I think the only requirements are (a) roundingFunction is pure, (b) roundingFunction(n) = n. E.g. the identity function works, although it's not terribly useful. These could be enforced by Quantizer, but it doesn't feel right. A designer who is at the same time sophisticated enough to need Quantizer yet naïve enough to choose a lousy one is quite unlikely. On the other hand, I can imagine stuff like this could be useful to some: __gshared uint SMALL_ALLOC = 64; ... configure it via an application-level flag... alias MyAlloc = Quantizer!( FreeTree!GCAllocator, n = n.roundUpToMultipleOf(n = SMALL_ALLOC ? 64 : 4096)); That's technically not pure but works, and might be appreciated. Andrei
Re: how does 'shared' affect member variables?
On Sat, 09 May 2015 15:38:05 -0400, Mike n...@none.com wrote: On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful. Here are a few interesting links: Iain Buclaw (lead developer for GDC) with his interpretation: http://forum.dlang.org/post/mailman.739.1431034764.4581.digitalmar...@puremagic.com Andrei Alexandrescu highlighting a critical flaw with `shared` http://forum.dlang.org/post/lruc3n$at1$1...@digitalmars.com The truth about shared http://p0nce.github.io/d-idioms/#The-truth-about-shared Interesting deprecation warning in latest compiler (See compiler output): http://goo.gl/EGvK72 But I don't know what the semantics are *supposed* to be, and I get the impression noone else knows either. I'll be watching this thread myself to see if someone can provide some insight. Mike So it seems that although it's not properly implemented, it's still not completely benign, right? I am trying to create a shared queue/array of delegates that run on the main thread. I don't know if D's 'shared' semantics will affect it or not, and whether or not casting to/from shared will cause problems with 'cas' or 'atomicStore' Would the following code work as expected? A simplified example: struct SpinLock { private int _lock = 0; void lock() { while(!cas(cast(shared(int)*)_lock, 0, 1)) {} } void unlock() { atomicStore(*cast(shared(int)*)_lock, 0); } } struct LockGuard(T) { private T* _lock; this(ref T lock) { _lock = lock; _lock.lock(); } ~this() { _lock.unlock(); } } class App { public: @property public static App instance() { return _instance; } this() { assert(!_instance); _instance = this; } ~this() { _instance = null; } void run(void delegate() dg) { auto lk = LockGuard!SpinLock(_lock); _actions.insertBack(dg); } void update() { auto lk = LockGuard!SpinLock(_lock); foreach(act; _actions) act(); _actions.clear(); } package: __gshared App _instance = null; SpinLock _lock; Array!(void delegate()) _actions; } Thread1: App.instance.run({ doSomething1(); }); Thread2: App.instance.run({ doSomething2(); }); Main Thread: App app = new MyAppType(); while(true) { app.update(); } Thanks, Bit
Re: New adapter: std.allocator.quantizer
On 05/10/2015 12:38 AM, Timon Gehr wrote: monotone increasing and piecewise constant with one fixed point per piece. (Note that monotone increasing is implied by piecewise constant with one fixed point per piece, so it does not necessarily need to be documented separately.)
Segfaults in std.net.curl default onReceiveHeader
Hey, I currently have an application that's been running for a couple months in production without an issue. Recently, we made a couple changes unrelated to our network layer, and are currently getting segfaults in std.net.curl's HTTP, with the mostly default settings. I don't believe the changes we made would relate to this, but is it possible this is a user error? We do not set onReceiveHeader in our application. They may be several hundred concurrent connections open, but they are carefully isolated within their own thread's with CurlOption.nosignal set. This is a backtrace I got from one of the core dumps, they all look similar: (gdb) bt #0 0x005e1242 in std.net.curl.Curl.throwOnStopped() () #1 0x005e1676 in std.net.curl.Curl.onReceiveHeader() () #2 0x005e1927 in std.net.curl.Curl._receiveHeaderCallback() () #3 0x7fede92b1d2d in Curl_client_chop_write (conn=conn@entry=0x7fea64059210, type=type@entry=2, ptr=0x5ea5940 @W\272+\355\177, len=17) at sendf.c:457 #4 0x7fede92b1eb0 in Curl_client_write (conn=conn@entry=0x7fea64059210, type=type@entry=2, ptr=optimized out, len=optimized out) at sendf.c:514 #5 0x7fede92b03c5 in Curl_http_readwrite_headers (data=data@entry=0x5ea5d40, conn=conn@entry=0x7fea64059210, nread=nread@entry=0x7fe7f5780d18, stop_reading=stop_reading@entry=0x7fe7f5780d17) at http.c:3744 #6 0x7fede92c6418 in readwrite_data (done=0x7fe7f5780da3, didwhat=synthetic pointer, k=0x5ea5db8, conn=0x7fea64059210, data=0x5ea5d40) at transfer.c:482 #7 Curl_readwrite (conn=0x7fea64059210, done=done@entry=0x7fe7f5780da3) at transfer.c:1066 #8 0x7fede92d037a in multi_runsingle (multi=multi@entry=0x7fea6400bb30, now=..., data=data@entry=0x5ea5d40) at multi.c:1521 #9 0x7fede92d0b69 in curl_multi_perform (multi_handle=multi_handle@entry=0x7fea6400bb30, running_handles=running_handles@entry=0x7fe7f5780e74) at multi.c:1802 #10 0x7fede92c7ffc in easy_transfer (multi=0x7fea6400bb30) at easy.c:717 #11 easy_perform (events=false, data=0x5ea5d40) at easy.c:805 #12 curl_easy_perform (easy=0x5ea5d40) at easy.c:824 #13 0x005e14a6 in std.net.curl.Curl.perform() () #14 0x005df041 in std.net.curl.HTTP.perform() () Another one which looks slightly different: #0 0x005de6f3 in std.net.curl.HTTP.Impl.onReceiveHeader() () #1 0x005e16ee in std.net.curl.Curl.onReceiveHeader() () #2 0x005e1987 in std.net.curl.Curl._receiveHeaderCallback() () #3 0x7f0ad8140d2d in Curl_client_chop_write (conn=conn@entry=0x7f05e819e190, type=type@entry=2, ptr=0x7f0a1a4e0200 , len=23) at sendf.c:457 #4 0x7f0ad8140eb0 in Curl_client_write (conn=conn@entry=0x7f05e819e190, type=type@entry=2, ptr=optimized out, len=optimized out) at sendf.c:514 #5 0x7f0ad813f3c5 in Curl_http_readwrite_headers (data=data@entry=0x3ec64b0, conn=conn@entry=0x7f05e819e190, nread=nread@entry=0x7f061bffddf8, stop_reading=stop_reading@entry=0x7f061bffddf7) at http.c:3744 #6 0x7f0ad8155418 in readwrite_data (done=0x7f061bffde83, didwhat=synthetic pointer, k=0x3ec6528, conn=0x7f05e819e190, data=0x3ec64b0) at transfer.c:482 #7 Curl_readwrite (conn=0x7f05e819e190, done=done@entry=0x7f061bffde83) at transfer.c:1066 #8 0x7f0ad815f37a in multi_runsingle (multi=multi@entry=0x7f05e80bae70, now=..., data=data@entry=0x3ec64b0) at multi.c:1521 #9 0x7f0ad815fb69 in curl_multi_perform (multi_handle=multi_handle@entry=0x7f05e80bae70, running_handles=running_handles@entry=0x7f061bffdf54) at multi.c:1802 #10 0x7f0ad8156ffc in easy_transfer (multi=0x7f05e80bae70) at easy.c:717 #11 easy_perform (events=false, data=0x3ec64b0) at easy.c:805 #12 curl_easy_perform (easy=0x3ec64b0) at easy.c:824 #13 0x005e1506 in std.net.curl.Curl.perform() () #14 0x005df0a1 in std.net.curl.HTTP.perform() ()
[Issue 14564] New: dmd -property -unittest combination causes compiler error
https://issues.dlang.org/show_bug.cgi?id=14564 Issue ID: 14564 Summary: dmd -property -unittest combination causes compiler error Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: ljdeli...@gmail.com I see the below errors when compiling a simple file using -property -unittest argument combination. Using either one individually creates a functional binary. A simple main.d: import std.stdio; void main() { writeln(Hello world); } dmd -property -unittest ./main.d /usr/include/dmd/phobos/std/uni.d(5736): Error: not a property c.isWhite /usr/include/dmd/phobos/std/uni.d(5738): Error: not a property a.map!(toLower) /usr/include/dmd/phobos/std/uni.d(5738): Error: not a property map(a).filter!(pred) /usr/include/dmd/phobos/std/uni.d(5739): Error: not a property b.map!(toLower) /usr/include/dmd/phobos/std/uni.d(5739): Error: not a property map(b).filter!(pred) /usr/include/dmd/phobos/std/uni.d(6028): Error: template instance std.uni.comparePropertyName!(char, char) error instantiating /usr/include/dmd/phobos/std/algorithm/searching.d(1494):instantiated from here: __lambda2!string /usr/include/dmd/phobos/std/uni.d(6028):instantiated from here: find!((x) = comparePropertyName(x, name) == 0, string[]) /usr/include/dmd/phobos/std/uni.d(6213):instantiated from here: isPrettyPropertyName!char /usr/include/dmd/phobos/std/uni.d(5897): Error: template std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda2).SortedRange.lowerBound cannot deduce function from argument types !()(const(char[])), candidates are: /usr/include/dmd/phobos/std/range/package.d(6942): std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda2).SortedRange.lowerBound(SearchPolicy sp = SearchPolicy.binarySearch, V)(V value) if (isTwoWayCompatible!(predFun, ElementType!Range, V) hasSlicing!Range) /usr/include/dmd/phobos/std/uni.d(6035): Error: template instance std.uni.findUnicodeSet!(tab, char) error instantiating /usr/include/dmd/phobos/std/uni.d(6214):instantiated from here: findSetName!(tab, char) /usr/include/dmd/phobos/std/uni.d(5897): Error: template std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda2).SortedRange.lowerBound cannot deduce function from argument types !()(const(char[])), candidates are: /usr/include/dmd/phobos/std/range/package.d(6942): std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda2).SortedRange.lowerBound(SearchPolicy sp = SearchPolicy.binarySearch, V)(V value) if (isTwoWayCompatible!(predFun, ElementType!Range, V) hasSlicing!Range) /usr/include/dmd/phobos/std/uni.d(6035): Error: template instance std.uni.findUnicodeSet!(tab, char) error instantiating /usr/include/dmd/phobos/std/uni.d(6214):instantiated from here: findSetName!(tab, char) /usr/include/dmd/phobos/std/uni.d(5897): Error: template std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda2).SortedRange.lowerBound cannot deduce function from argument types !()(const(char[])), candidates are: /usr/include/dmd/phobos/std/range/package.d(6942): std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda2).SortedRange.lowerBound(SearchPolicy sp = SearchPolicy.binarySearch, V)(V value) if (isTwoWayCompatible!(predFun, ElementType!Range, V) hasSlicing!Range) /usr/include/dmd/phobos/std/uni.d(6035): Error: template instance std.uni.findUnicodeSet!(tab, char) error instantiating /usr/include/dmd/phobos/std/uni.d(6215):instantiated from here: findSetName!(tab, char) /usr/include/dmd/phobos/std/uni.d(6114):called from here: findAny(Cyrillic) /usr/include/dmd/phobos/std/uni.d(6117): Error: static assert No unicode set by name Cyrillic was found. /usr/include/dmd/phobos/std/uni.d(2236):instantiated from here: opDispatch!Cyrillic /usr/include/dmd/phobos/std/uni.d(1853):instantiated from here: InversionList!(GcPolicy) --
Re: Tuple assignment
On 5/9/2015 10:16 AM, Russel Winder via Digitalmars-d wrote: Python has tuple assignment so you see things like: previous, current = current, previous + current especially if you are doing silly things like calculating Fibonacci Sequence values. Translating this to D, you end up with: TypeTuple!(current, next) = tuple(next , current +next); I am assuming this is horrendously inefficient at run time compared to having the intermediate value explicit: auto t = next; next = current + next; current = t; or is it? It probably depends on the compiler. The way to find out is to look at the generated assembler. Tuples are implemented as structs. I know that ldc is capable of slicing structs into register-sized pieces and optimizing them independently, dmd does not. So ldc would very possibly generate the kind of code for that that you'd like.
Re: how does 'shared' affect member variables?
On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: What does 'shared' do to member variables? Makes them `shared`. :P It makes sense to me to put it on a global variable, but what sense does it make putting it on a member of a class? Globals are not the only way to pass data to other threads. E.g., you can std.concurrency.send a shared Object: import core.thread: thread_joinAll; import std.concurrency; class C {int x;} void main() { auto c = new shared C; c.x = 1; auto tid = spawn(() { receive( (shared C c) {c.x = 2;} ); }); send(tid, c); thread_joinAll(); assert(c.x == 2); } That shared C could come from a class/struct member, of course. What happens if you try to access a member of a class/struct instance from another thread that is not marked 'shared'? I think you're not supposed to be able to do that.
Re: how does 'shared' affect member variables?
On Saturday, 9 May 2015 at 19:59:58 UTC, tcak wrote: Stupidly, shared variables' value cannot be increased/decreased directly. Compiler says it is deprecated, and tells me to use core.atomic.atomicop. You will see this as well. How's that stupid? Sounds like the compiler is doing its job guarding you from races. Hey compiler! I know 100% that no other thing will be touching this variable. Informing the compiler about this is done by casting shared away.
How to translate this to D: const char *const* someConstPtr;
Hi, const char *const* someConstPtr; Error: no identifier for declarator char* Error: declaration expected, not '*' How would I translate this properly to d? Cheers, PP
Re: Header Files
On 05/09/2015 07:01 AM, bitwise wrote: ./main.d ./pack/foo.d ./pack/sub/bar.d dmd main.d pack/foo.d pack/sub/bar.d -ofTest -H This dumps all the *.di files into the output directory ignoring the directory structure. Is there some rational for it being this way? Wouldn't it be much more useful if directories were preserved? Bit As far as I know, every other similar tool works the same way: $ gcc -c foo/foo.c foo.o is outputted to the current directory. The common solution that I know is to use makefiles to manage file dependencies. For example, the rule for .di specifies the file that it depends on (the .d corresponding to that .di) and 'make' handles it automatically. Ali
Re: Breaking changes in Visual C++ 2015
On Sunday, 10 May 2015 at 01:04:31 UTC, Walter Bright wrote: On 5/9/2015 5:26 PM, Dicebot wrote: Until it breaks. And it breaks pretty fast with version(unittest) if you start using it as a common idiom. It's no harder to get right than -DWHATEVER in C and C++. Any system that has separate compilation and conditional compilation means taking a bit of care when mixing them. https://issues.dlang.org/show_bug.cgi?id=13454
Re: Breaking changes in Visual C++ 2015
On Friday, 8 May 2015 at 19:59:35 UTC, Walter Bright wrote: On 5/8/2015 7:03 AM, Chris wrote: The funny thing is that people keep complaining about the lack of tools for D, and when a tool is built into the language they say That tool shouldn't be part of the language. Yet, if it were omitted, people would say Why doesn't D have this tool built in?. Human nature, I guess. I see it slightly differently. If the tool is built in to the language, people do not regard it as a tool anymore when preparing a mental checklist of available tooling. Warning! Another Boring Walter Cutaway - It reminds me of back when we were selling the Zortech C++ compiler, we included complete runtime library source with the compiler. This was back in the days when most compilers' library source code was a closely held trade secret. Nobody noticed that we included the runtime library source. Then, one day, Borland decided to make their previously trade secret library source code available as a separate purchase. They did an amazing job marketing this, and journalists everywhere celebrated the forward thinking breakthrough. Even in magazine compiler roundup reviews, the journalists would breathlessly note that one could now buy Borland's library source code, but Zortech C++ including it for free was never mentioned. We threw in the towel, and made the library source code a separately priced add on. This was a big success for us! No, I'm not suggesting we unbundle unit testing, Ddoc, coverage analysis, profiling, etc., into separate tools for marketing purposes. I'm just bemused by how perceptions work. -- I love these war stories :)
[Issue 14558] Attempts to link with DMD when using MSVC LDC under VisualD
https://issues.dlang.org/show_bug.cgi?id=14558 Rainer Schuetze r.sagita...@gmx.de changed: What|Removed |Added CC||r.sagita...@gmx.de --- Comment #1 from Rainer Schuetze r.sagita...@gmx.de --- Looks like you are trying to link a library. LDC probably needs lib.exe from the VC distribution, but it picks up lib.exe from the DMD bin folder. I suspect you have the DMD folder in your PATH or it is added to the Executable Paths. --
Re: how does 'shared' affect member variables?
On Sat, 09 May 2015 15:59:57 -0400, tcak t...@gmail.com wrote: If a variable/class/struct etc is not shared, for variables and struct, you find their initial value. For class, you get null. For first timers (I started using shared keyword more than 2 years ago), do not forget that: a shared method is all about saying that this method is defined for shared object. So, do not get confused. It happened to me a lot. Bad part of shared is that, you will be repeating it again, and again, and again, and again, everywhere. So, try to be patient if you are going to be using it for a long time. Stupidly, shared variables' value cannot be increased/decreased directly. Compiler says it is deprecated, and tells me to use core.atomic.atomicop. You will see this as well. Hey compiler! I know 100% that no other thing will be touching this variable. using the SpinLock and LockGuard from my code above, I created a working test case. It works as expected, with no shared keyword on anything. The variable App._instance is __gshared, but that's about all. /// import spinlock; import std.stdio; import std.concurrency; import std.container; import core.thread; class App { SpinLock _lock; Array!(void delegate()) _actions; __gshared App _instance = null; this() { assert(!_instance); _instance = this; } ~this() { _instance = null; } @property public static App instance() { return _instance; } void run(void delegate() dg) { auto lk = LockGuard!SpinLock(_lock); _actions.insertBack(dg); writeln(queued delegate); } void update() { writeln(updating); auto lk = LockGuard!SpinLock(_lock); foreach(act; _actions) act(); _actions.clear(); } } void WorkerThread() { writeln(started worker, going to sleep); Thread.sleep(500.msecs); App.instance.run({ writeln(running delegate queued from thread); }); } void main() { App app = new App(); Thread workerThread = new Thread(WorkerThread).start(); int ms = 0; while(ms 1000) { app.update(); Thread.sleep(100.msecs); ms += 100; } workerThread.join(); } // OUTPUT: updating started worker, going to sleep updating updating updating updating queued delegate updating running delegate queued from thread updating updating updating updating // No null references or 'init' values. A little confused now, but at least it works. Finally, I tested to see if the lock was actually working: void WorkerThread() { writeln(worker aquiring lock); App.instance._lock.lock(); writeln(worker aquired lock); App.instance._lock.unlock(); } void main() { App app = new App(); writeln(main locked); App.instance._lock.lock(); Thread workerThread = new Thread(WorkerThread).start(); writeln(main sleeping); Thread.sleep(2.seconds); writeln(main woke); App.instance._lock.unlock(); writeln(main unlocked); workerThread.join(); } As expected, output was: main locked main sleeping worker aquiring lock main woke main unlocked worker aquired lock And no 'shared' in sight. So now I'm confused as to when it has the affect that you were describing with null/init. Bit
Re: Breaking changes in Visual C++ 2015
On 5/9/2015 1:57 PM, Nick Sabalausky wrote: On 05/08/2015 06:58 PM, Walter Bright wrote: On 5/8/2015 2:51 PM, deadalnix wrote: The way you end runnign all kind of test with the ones you are interested in makes no sense. dmd std/path -unittest -main runs just the unit tests in std/path. You can run tests in some modules, but not others, with: dmd -c a b c -unittest dmd d e f a.o ./d That breaks most build systems, including rdmd. Build systems cannot handle giving different compile flags to different files? Back to using 'make' :-)
Re: Breaking changes in Visual C++ 2015
On Sat, May 09, 2015 at 03:44:40PM -0700, Walter Bright via Digitalmars-d wrote: On 5/9/2015 1:57 PM, Nick Sabalausky wrote: On 05/08/2015 06:58 PM, Walter Bright wrote: On 5/8/2015 2:51 PM, deadalnix wrote: The way you end runnign all kind of test with the ones you are interested in makes no sense. dmd std/path -unittest -main runs just the unit tests in std/path. You can run tests in some modules, but not others, with: dmd -c a b c -unittest dmd d e f a.o ./d That breaks most build systems, including rdmd. Build systems cannot handle giving different compile flags to different files? Back to using 'make' :-) Of course it can. I have done it before, it's not that hard. (And build systems that don't support that, suck. :-P) The more enlightening question is, why is it a bad idea to give different compile flags to different files? And the answer is that it's not a recommended setup, as you may cause subtle breakage between modules that may lead to hard-to-find heisenbugs that only show up at runtime but don't exist in code. Contrived example: module mymod; version(UseFloat) float x; else int x; module main; import mymod; void main() { x = 0; writeln(x); } Compile commands: dmd -c mymod.d dmd -c -version=UseFloat main.d # -- oops dmd -ofprog main.o mymod.o T -- A linguistics professor was lecturing to his class one day. In English, he said, A double negative forms a positive. In some languages, though, such as Russian, a double negative is still a negative. However, there is no language wherein a double positive can form a negative. A voice from the back of the room piped up, Yeah, yeah.
Re: Breaking changes in Visual C++ 2015
On 5/9/2015 4:10 PM, Dicebot wrote: On Saturday, 9 May 2015 at 22:44:28 UTC, Walter Bright wrote: Build systems cannot handle giving different compile flags to different files? Back to using 'make' :-) Compiling different object files with different version flags is current illegal in D and may result in linking errors. That's true with many flags for C and C++ compilers, too. But it doesn't stop anyone from routinely using different flags for different source files. (dmd's makefiles, for example)
Re: Header Files
On 05/09/2015 06:18 PM, bitwise wrote: I'm not sure I understand what you mean, but my point is, that as is, this feature of DMD is broken. Arguably broken but compared to other tools it behaves in the same way. If people are successfully using dmd -H right now, they must not be using packages, or their 'package.di' files would be overwritten. So I'm wondering if I should do a PR to fix this. The same can be said for gcc and other tools as well and it is not limited to package.d: any two files with the same name would have the same problem, meaning that the particular build system that puts those unrelated files in the same directory is in error, not the compiler. The way I see it, the right solution is to provide correct paths to dmd for each file. Ali
Re: how does 'shared' affect member variables?
On Saturday, 9 May 2015 at 20:17:59 UTC, bitwise wrote: On Sat, 09 May 2015 15:38:05 -0400, Mike n...@none.com wrote: On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful. Here are a few interesting links: Iain Buclaw (lead developer for GDC) with his interpretation: http://forum.dlang.org/post/mailman.739.1431034764.4581.digitalmar...@puremagic.com Andrei Alexandrescu highlighting a critical flaw with `shared` http://forum.dlang.org/post/lruc3n$at1$1...@digitalmars.com The truth about shared http://p0nce.github.io/d-idioms/#The-truth-about-shared Interesting deprecation warning in latest compiler (See compiler output): http://goo.gl/EGvK72 But I don't know what the semantics are *supposed* to be, and I get the impression noone else knows either. I'll be watching this thread myself to see if someone can provide some insight. Mike So it seems that although it's not properly implemented, it's still not completely benign, right? I am trying to create a shared queue/array of delegates that run on the main thread. I don't know if D's 'shared' semantics will affect it or not, and whether or not casting to/from shared will cause problems with 'cas' or 'atomicStore' Would the following code work as expected? I'm not sure if it would or no, as I haven't used these features of D before, but it looks like what you are trying to implement is what `synchronized` already provides: http://ddili.org/ders/d.en/concurrency_shared.html#ix_concurrency_shared.synchronized Mike
Re: Header Files
On Sat, 09 May 2015 21:31:20 -0400, Ali Çehreli acehr...@yahoo.com wrote: On 05/09/2015 06:18 PM, bitwise wrote: I'm not sure I understand what you mean, but my point is, that as is, this feature of DMD is broken. Arguably broken but compared to other tools it behaves in the same way. dmd is the reference compiler, so the other compilers _should_ behave the same way. I suppose this could be considered arguable, because there may exist a build system(I don't know of any) that will plan for this defect and generate the headers one by one while building out the directories on it's own. So my options are to be burdened by some build tool I don't need just for this one feature, or waste my time writing custom build scripts when this is something that can trivially be implemented in the compiler. In the interest of not breaking existing build systems, an additional flag could be added to dmd. Something like -Hp for preserve paths when outputting headers. The way I see it, the right solution is to provide correct paths to dmd for each file. Given a build command like the one below, I don't understand how you would achieve this without building the files one by one. ./main.d ./pack/foo.d ./pack/sub/bar.d dmd main.d pack/foo.d pack/sub/bar.d -ofTest -H The output is: ./main.di ./foo.di ./bar.di And it should be(or could be, if -Hp was passed) ./main.di ./pack/foo.di ./pack/sub/bar.di Bit
[Issue 14560] Strange -inline behavior
https://issues.dlang.org/show_bug.cgi?id=14560 Vladimir Panteleev thecybersha...@gmail.com changed: What|Removed |Added CC||thecybersha...@gmail.com --- Comment #1 from Vladimir Panteleev thecybersha...@gmail.com --- Introduced in https://github.com/D-Programming-Language/dmd/commit/90a9638d60bf335789fb0cc1d7a03aade386d927 --
Re: Lambda functions in D
On Saturday, 9 May 2015 at 21:48:05 UTC, Timon Gehr wrote: Well, it is much slower due to all the allocated closures, owed to the fact that the implementations of 'fix' on that page are expected to mirror a particular famous implementation in untyped lambda calculus. In case you have a use for 'fix', a more efficient implementation might be: auto fix(S,T...)(S delegate(T) delegate (S delegate(T)) f){ S delegate(T) g=(T a){ assert(0,f is too eager.); }; return g=f((T a)=g(a)); } (In particular, this will only allocate two closures for the plumbing instead of a number of them linear in the number of recursive invocations.) Even something like Common Lisp. (Be aware that Common Lisp implementations typically have better garbage collectors than what is available for D.) Maybe in the future, that D will be added to optimize tail recursion delegates? And why garbage collectors in Lisp is better?
Re: Breaking changes in Visual C++ 2015
Warning! Another Boring Walter Cutaway - Very interesting story. No, I'm not suggesting we unbundle unit testing, Ddoc, coverage analysis, profiling, etc., into separate tools for marketing purposes. I'm just bemused by how perceptions work. Affect is like an iceberg - 90% below conscious awareness - but it shapes global perceptions, processing, and decision-making in the brain. (See Camerer et al review paper). What is not widely appreciated even by putative experts is that affect shapes perceptions themselves, not just the hedonic evaluation of those perceptions. And people feel a certain way towards D and look for reasons to explain their affect - it's affect that is primary, not the rationalizations given. But affect towards entities and institutions can and does change, sometimes for mysterious reasons (although the 'facts' tend to change in line with the perceptions). This is all in gestalt psychology, and some of the work on mass psychological behaviour done since then. This is also a neglected facet of financial market behaviour. In 2002 Germany was the sick man of Europe according to the Economist. But really, this was the moment of greatest error in articulating that perception, because she was at that moment beginning reforms that would lead to her prosperity today. It's how one responds to challenges that is important. Perhaps D might be on a similar path (not sick, but maturing, with concern over immaturity not fitting the nascent blossoming of new tooling, library interfaces, GC improvements, memory allocators, etc).
Re: Breaking changes in Visual C++ 2015
On 5/9/2015 8:56 PM, deadalnix wrote: As long as you are doing trivial toy programs, that is perfect. The compiler is not a trivial toy program - it's how I made DMC++ still the fastest C++ compiler available. I also used it on dmd. dmd being very fast is not an accident. My bad. It is still clowny that I have to format my code in a particular way to get that result. Not formatting my code that way, I never noticed that the result even existed in the first place. Consider: 5| foo(); 7| if (a b) If you were examining the line counts, wouldn't you notice something like that? It's pretty obvious that a is executed 5 times and b twice. I use this tool a lot. I get what's needed out of them, while keeping the report as a simple printout. I can't have the coverage per test case, to know what test is testing what for instance (which is arguably mostly due to how tests are ran in the first place). It does give me information depending on the formatting of my code. These may not seems like important things, but that is what makes the difference. I saw the report in the picture you linked to. It looks nice. How will it make me more productive? On the other hand, I have something like: $ cat trace.log -- 1main _Dmain14545 -- main000 1_Dmain Timer Is 3579545 Ticks/Sec, Times are in Microsecs Num TreeFuncPer CallsTimeTimeCall 1 12 12 12 _Dmain 1 0 0 0 main All that's needed to make DMC++ still the fastest C++ compiler. (The dmd profiler is the same as the DMC++ one, but fixed for multithreading.) It tracks who are the top time users, and how they get called in a simple format. I understand that those colorful graphical displays look pretty, and are fun to browse around on. What I don't understand is how that translates into a programmer being more productive with those results, let alone miles more productive. For reference, the format used is named callgrind and many tools can manipulate it: http://valgrind.org/docs/manual/cl-format.html Thanks for the link, I've never heard of that before. Switching to it, however, now means that the poor user has to download and install more tools to get results, and the process of using it is no longer one step. [If cl-format is really miles better, why not submit a PR to have the dmd report generator output that?] One output from -profile you might not have noticed is a .def file. This sets the link order for functions, so that functions that are strongly connected at runtime are located adjacent to each other. Makes for much better virtual paging and cache performance. It currently only works for Optlink, because nobody cares about it. I can use both tcmalloc and jemalloc on WAY MORE plateforms that D supports. My point is you are guaranteed to have the D tools with every D compiler, regardless of what platform it is on. And of course you can use tcmalloc and jemalloc with D, if you want to. Tested on SDC's test runner, it makes the test runner segfault. The only known cause of -profile seg faulting was running it on multithreaded programs. That's been corrected. If this is something else, without a bugzilla report, nothing will happen. And that's true with every language.
Re: Calypso milestone hit: D adaptation of Qt5 tutorial working
On 5/8/2015 7:31 PM, Elie Morisse wrote: Hi! Calypso just got a D translation of the first Qt5 Widgets tutorial building and running: https://github.com/Syniurge/Calypso/blob/master/tests/calypso/qt5/qt5demo.d Result: http://homo-nebulus.fr/dlang/oh%20my.webm Compilation log: https://paste.kde.org/pewbbsw45 Previously Calypso was merely able to work with STL types, this is the first time a large C++ library is successfully mapped and used by D code (Ogre3D is probably close as well, but after Kagamin's suggestion and for a change of scene I switched my focus from Ogre3D to Qt). This is really quite dazz. I'm looking forward to meeting you at DConf!
Re: Breaking changes in Visual C++ 2015
On Saturday, 9 May 2015 at 23:36:03 UTC, Walter Bright wrote: On 5/9/2015 4:10 PM, Dicebot wrote: On Saturday, 9 May 2015 at 22:44:28 UTC, Walter Bright wrote: Build systems cannot handle giving different compile flags to different files? Back to using 'make' :-) Compiling different object files with different version flags is current illegal in D and may result in linking errors. That's true with many flags for C and C++ compilers, too. But it doesn't stop anyone from routinely using different flags for different source files. (dmd's makefiles, for example) Until it breaks. And it breaks pretty fast with version(unittest) if you start using it as a common idiom.
Re: Breaking changes in Visual C++ 2015
On 5/9/2015 5:26 PM, Dicebot wrote: Until it breaks. And it breaks pretty fast with version(unittest) if you start using it as a common idiom. It's no harder to get right than -DWHATEVER in C and C++. Any system that has separate compilation and conditional compilation means taking a bit of care when mixing them.
Re: Header Files
On Sat, 09 May 2015 10:01:25 -0400, bitwise bitwise@gmail.com wrote: ./main.d ./pack/foo.d ./pack/sub/bar.d dmd main.d pack/foo.d pack/sub/bar.d -ofTest -H This dumps all the *.di files into the output directory ignoring the directory structure. Is there some rational for it being this way? Wouldn't it be much more useful if directories were preserved? Bit At this point, I'm thinking I should file a bug report for this. You can't build a codebase with multiple packages because package.d or any other files that share the same filename will be overwritten. Is there really no way to preserve the directory structure when creating .di files? Bit
Re: New adapter: std.allocator.quantizer
On 5/9/15 3:38 PM, Timon Gehr wrote: Thanks! Looks good, except: 106| if (!parent.expand(b, goodAllocSize(needed) - b.length)) Let's see, this is a tad tricky. needed is the needed size, i.e. b.length + delta. We want to expand to a final size of goodAllocSize(needed). So we need to pass the appropriate delta to expand, i.e. goodAllocSize(needed) - b.length. (recall that expand() takes the delta, not the new size) 142| return parent.reallocate(b, gs); gs is precomputed at the top of the function to be goodAllocSize(s), so this seems to be in good shape. 172| return parent.alignedReallocate(b, gs, a); Same here, the intent is to reallocate to goodAllocSize(s), which is precomputed in gs. Those should be more like: 182| parent.deallocate(b.ptr[0 .. goodAllocSize(b.length)]); Another point is that the documented/checked constraints on the rounding function are too weak. A rounding function should be monotone increasing and piecewise constant with one fixed point per piece. Agreed, I see there's a bit of follow-up so I'll reply to that. And then, there's this, of course: size_t goodAllocSize(size_t n); Returns roundingFunction(n). It is required that roundingFunction(n) = n. For efficiency reasons, this is only asserted (checked in debug mode). Is this meant to be a complete specification of 'assert'? :o) What is 'debug mode'? Good point. Fixed the docs: https://github.com/andralex/phobos/blob/allocator/std/experimental/allocator/quantizer.d Andrei
[Issue 14558] Attempts to link with DMD when using MSVC LDC under VisualD
https://issues.dlang.org/show_bug.cgi?id=14558 --- Comment #2 from Manu turkey...@gmail.com --- That sounds like the problem. It is in the path. I don't think it's good to rely on user path configuration for this to work. There is already code where VisualD overrides the VS tool paths with the proper locations relative to the version of VS the user is running right? Linking LDC can never work with DMD's lib.exe, so it should probably be jigged so that it uses the same linker that DMD-Win64 uses when building libs, irrespective of the users path settings? --
Re: mscoff x86 invalid pointers
On 2015-05-09 05:44, Baz wrote: On Saturday, 9 May 2015 at 06:21:11 UTC, extrawurst wrote: On Saturday, 9 May 2015 at 00:16:28 UTC, Etienne wrote: I'm trying to compile a library that I think used to work with -m32mscoff flag before I reset my machine configurations. https://github.com/etcimon/memutils Whenever I run `dub test --config=32mscoff` it gives me an assertion failure, which is a global variable that already has a pointer value for some reason.. I'm wondering if someone here could test this out on their machine with v2.067.1? There's no reason why this shouldn't work, it runs fine in DMD32/optlink and DMD64/mscoff, just not in DMD32/mscoff. Thanks! you can always use travis-ci to do such a job for you ;) doesn't -m32mscoff recquire phobos to be compiled as COFF too ? I think that travis uses the official releases (win32 releases have phobos as OMF) so he can't run the unittests like that... The dark side of the story is that you have to recompile phobos by hand with -m32mscoff...I'm not even sure that there is a option for this in the win32.mak... Meh, I ended up upgrading to 2.068 and everything went well. I clearly remember 2.067.1 working but spent a whole day recompiling druntime/phobos COFF versions in every configuration possible and never got it working again
[Issue 14564] dmd -property -unittest combination causes compiler error
https://issues.dlang.org/show_bug.cgi?id=14564 --- Comment #1 from Lucas Burson ljdeli...@gmail.com --- I forgot to note that the arg combination compiles using the previous version of dmd v2.066.1, and failure in v2.067.1. --
Re: D for Android
On Friday, 8 May 2015 at 16:42:21 UTC, Dan Olson wrote: Joakim, the ldc merge-2.067 branch works well and has updated druntime/phobos. I know it has some of your Android updates. You may have more fun working with it. OK, I'll try it. I didn't want to run into bugs unrelated to cross-compiling, so I hadn't tried it yet. I wonder if we should keep a common LLVM fork with changes to support D on targets without builtin TLS? I did another LLVM hack in x86 backend to support TLS on iPhone sim, and have been thinking about adding a fallback TLS, like emulated tls that gcc and gdc has, to support TLS using a target plugin to get lookup address. That way it could be wired into any old embedded multi thread RTOS with some sort of thread-local support. Maybe someday could even get LLVM to accept some patches. Sounds like a worthwhile idea, though my patches to llvm are minimal. I'm sure they'd seriously consider accepting such patches, since the gcc backend already has this built in. I just checked last week and the recent Android NDK's gcc has emulated TLS enabled by default, while the same C/C++ source employing TLS __thread and compiled with the NDK's clang will segfault because it doesn't have emulated TLS. Emulated TLS wasn't added to the NDK's gcc by google either: it appears to have just slipped in from upstream, which is perhaps why they seem to be unaware that it works for one compiler in the NDK and not the other. Let the llvm guys know of this disparity, and I'm sure they'll be up for remedying it.
Re: Breaking changes in Visual C++ 2015
On Fri, May 08, 2015 at 10:36:28PM -0700, Walter Bright via Digitalmars-d wrote: On 5/8/2015 10:09 PM, H. S. Teoh via Digitalmars-d wrote: The built-in dmd profiler is unfortunately unusable for me because its function call counters wrap around far too early (IIRC they use 16-bit counters or something like that), 32 bit counters https://github.com/D-Programming-Language/druntime/blob/master/src/rt/trace.d#L38 whereas the test cases I need to optimize for are the long-running, steady state test cases in which millions or billions of function calls are made. Will this ever be improved? if (bugzilla report submitted || developers are mind readers) { maybe it'll get fixed! } else { nobody knows there's a problem } Feel free to submit a PR to make 'count' a ulong. https://issues.dlang.org/show_bug.cgi?id=14565 I also just realized that on Posix the profiling code apparently relies on the rdtsc instruction, which counts CPU cycles in a 64-bit counter -- given the high frequencies of modern CPUs, moderately long-running CPU-intensive processes easily overflow this counter, leading to wrapped-around timing values and completely garbled output. gprof, for all of its flaws, does not suffer from this problem. T -- Curiosity kills the cat. Moral: don't be the cat.
[Issue 14565] New: dmd -profile produces garbled output for long-running CPU-intensive processes
https://issues.dlang.org/show_bug.cgi?id=14565 Issue ID: 14565 Summary: dmd -profile produces garbled output for long-running CPU-intensive processes Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: hst...@quickfur.ath.cx Currently, the profiling harness generated by dmd -profile uses uint (32-bit) for counting the number of times a function gets called. For profiling the steady-state of long-running, CPU-intensive code, 32-bit counters are easily overflowed, causing the profile output to be useless because some counters may have wrapped around, thus distorting the output (counts, ordering of functions that consumed the most time, etc.). Furthermore, due to the reliance on the rdtsc instruction which counts CPU cycles, given the high clock frequency of modern CPU's, even with a 64-bit counter a moderately long-running process will overflow this counter, causing time measurements to wrap around and again producing garbled output. This makes dmd -profile useless in profiling long-running CPU-intensive processes, as there is no way to measure the steady state of the process before the output gets garbled by wrapped-around counters. --
[Issue 14564] dmd -property -unittest combination causes compiler error
https://issues.dlang.org/show_bug.cgi?id=14564 Lucas Burson ljdeli...@gmail.com changed: What|Removed |Added Hardware|x86_64 |All --
Re: RFC: Pay-as-you-go, Portable D Runtime for Microcontrollers (and maybe more)
On Friday, 8 May 2015 at 02:25:48 UTC, Mike wrote: The ports folder in this experiment is essentially the platform abstraction layer. However, it's resolved at link-time. What do you suggest: A reserved module/package implementing a standard interface that is imported at compile-time? I could do that. I'd like to help out (where I can). As far as I remember, you have a STM32F4xx, correct ? If we all have the same model STM32F4xx and we all have one or more different MCUs, we could probably do some initial drafts. -Because I'm sure there are obstacles we do not think about in advance. Testing some drafts on several MCUs in the beginning, will help us avoid a lot of trouble later on. I have STM32F407, STM32F427, STM32F429 (I use these regularly). On the shelf, I have LPC812, LPC1114, LPC1342 (seems to be dead though), LPC1549 (I don't have any libraries for this one yet), LPC1751, LPC1768, LPC1788 and LPC4337. Though I have a few from Freescale, I am not able to flash-program them, as I have no driver for them in OpenOCD.
Re: Compile Times on Windows
On Sat, 09 May 2015 10:17:29 +, weaselcat wrote: On Saturday, 9 May 2015 at 10:00:53 UTC, Manfred Nowak wrote: zebrazebra wrote: $ time dmd hello.d real0m4.243s user0m0.015s sys 0m0.031s $ time ./hello.d Hello, world! real0m0.039s user0m0.000s sys 0m0.015s Why is the Hello, world! missing in your post? -manfred he's timing compilation, not runtime. $ time dmd hello.d 0.30user 0.08system 0:00.40elapsed might be a windows issue? weaselcat: Are you running windows 8.1 as well? It might be disk access time. Or an anti-virus program interfearing?
Re: [hackathon] FreeTree is FreeList on autotune
On 05/07/2015 04:49 PM, Andrei Alexandrescu wrote: - The implementation of 'allocate' appears to be buggy: If no memory block of a suitable size is found, the entire free tree is released. (There is only one occurrence of parent.allocate in the code and it appears right after a call to 'clear'.) If the parent allocator does not define the 'deallocate' method, the allocator will always return 'null' instead. The idea here is that if no memory block is found in either the tree or the parent, the memory the tree is holding to is useless and fragments the parent unnecessarily. So the entire tree is thrown away, returning memory to the parent. Then allocation from the parent is tried again under the assumption that the parent might have coalesced freed memory. If the parent doesn't define deallocate, it can't accept back the memory kept by the tree. LMK if I'm missing something. The comment says: Allocates $(D n) bytes of memory. First consults the free tree, and returns from it if a suitably sized block is found. Otherwise, the parent allocator is tried. If allocation from the parent succeeds, the allocated block is returned. Otherwise, the free tree tries an alternate strategy: If $(D ParentAllocator) defines $(D deallocate), $(D FreeTree) releases all of its contents and tries again. Unless I am the one missing something, the implementation does the following instead: Allocates $(D n) bytes of memory. First consults the free tree, and returns from it if a suitably sized block is found. Otherwise, the free tree tries an alternate strategy: If $(D ParentAllocator) defines $(D deallocate), $(D FreeTree) releases all of its contents and tries again. (findAndRemove never allocates new memory from the parent, it just gets you memory already stored in the tree, if the right allocation size is present.) Thanks for the review! My pleasure!
Re: duml to generate UML diagrams in HTML format
On 9/05/2015 11:32 p.m., tcak wrote: I have created my first project in github, and I wanted to share it. https://github.com/tcak/duml I started working on it today morning, and completed in midday. But it is still in very early stages. So, I wanted to take thoughts of you guys. Purpose of this project is to put XML based comments into a text file (source code for programmers), and it generates UML diagram in a single HTML file. This is the result of duml's own source code at this point: http://imgur.com/0kfK9Xu Do you guys think that this will be any use as a D tool maybe? I am planning to add activity decisions, and linking actions to other HTML files. So, a general function that uses sub functions can link to activity diagram of those functions as well. Awkward. https://github.com/rikkimax/duml
Re: Lambda functions in D
On Saturday, 9 May 2015 at 11:20:10 UTC, Dennis Ritchie wrote: Hi, Can lambda functions or delegates in D to call themselves? Can I write something like this: - import std.stdio; void main() { auto fact = function (int x) = x * { if (x) fact(x - 1); }; assert(fact(10) == 3628800); } dmd says no.
Re: duml to generate UML diagrams in HTML format
On 9/05/2015 11:40 p.m., tcak wrote: On Saturday, 9 May 2015 at 11:37:57 UTC, Rikki Cattermole wrote: On 9/05/2015 11:32 p.m., tcak wrote: I have created my first project in github, and I wanted to share it. https://github.com/tcak/duml I started working on it today morning, and completed in midday. But it is still in very early stages. So, I wanted to take thoughts of you guys. Purpose of this project is to put XML based comments into a text file (source code for programmers), and it generates UML diagram in a single HTML file. This is the result of duml's own source code at this point: http://imgur.com/0kfK9Xu Do you guys think that this will be any use as a D tool maybe? I am planning to add activity decisions, and linking actions to other HTML files. So, a general function that uses sub functions can link to activity diagram of those functions as well. Awkward. https://github.com/rikkimax/duml Whops! I better change name of mine to DUML: Age of Ultron Haha! Yeah just make it a little unique to the project and it'll be all good. After all, no need to confuse a dead end project and one that has a good chance of being used ;)
[Issue 14497] Disassembly view
https://issues.dlang.org/show_bug.cgi?id=14497 --- Comment #10 from Rainer Schuetze r.sagita...@gmx.de --- You can assign a hotkey to the command in the global keybord settings of VS. Search for VisualD.CompileAndDisasm. I have not predefined hotkeys to avoid breaking other people assignments. You can assign Ctrl+F7 just as well, though that might break compiling C++ files. Background compilation might be possible, but I avoided that for now to not cause spurious delays during editing due to the compilation. There will also be many failing builds. Oh yeah, and the other thing was that every time I hit Compile and Disassemble, it prompts me if I want to reload the file. That's a bit annoying. Yeah, I noticed that, too, though it does not seem to happen every time. I'll have to figure out how to avoid that... --
Re: mscoff x86 invalid pointers
On Saturday, 9 May 2015 at 06:21:11 UTC, extrawurst wrote: On Saturday, 9 May 2015 at 00:16:28 UTC, Etienne wrote: I'm trying to compile a library that I think used to work with -m32mscoff flag before I reset my machine configurations. https://github.com/etcimon/memutils Whenever I run `dub test --config=32mscoff` it gives me an assertion failure, which is a global variable that already has a pointer value for some reason.. I'm wondering if someone here could test this out on their machine with v2.067.1? There's no reason why this shouldn't work, it runs fine in DMD32/optlink and DMD64/mscoff, just not in DMD32/mscoff. Thanks! you can always use travis-ci to do such a job for you ;) doesn't -m32mscoff recquire phobos to be compiled as COFF too ? I think that travis uses the official releases (win32 releases have phobos as OMF) so he can't run the unittests like that... The dark side of the story is that you have to recompile phobos by hand with -m32mscoff...I'm not even sure that there is a option for this in the win32.mak...
Re: Calypso milestone hit: D adaptation of Qt5 tutorial working
On 09.05.2015 04:58, Mike wrote: On Saturday, 9 May 2015 at 02:31:09 UTC, Elie Morisse wrote: Hi! Calypso just got a D translation of the first Qt5 Widgets tutorial building and running: https://github.com/Syniurge/Calypso/blob/master/tests/calypso/qt5/qt5demo.d Result: http://homo-nebulus.fr/dlang/oh%20my.webm Compilation log: https://paste.kde.org/pewbbsw45 Previously Calypso was merely able to work with STL types, this is the first time a large C++ library is successfully mapped and used by D code (Ogre3D is probably close as well, but after Kagamin's suggestion and for a change of scene I switched my focus from Ogre3D to Qt). Wow! Game changing work here, IMO! Question: You are using a modified version of LDC, but is that compiler required to consume link to a library created with that custom compiler? What I mean is: Can you use this modified version of LDC to create a library, and then use a generic D compiler to build an application that links to that library? Mike Very impressive indeed! Probably discussed before, but as an alternative to a library, would it be possible to use the header generation (-H) to emit .di files compatible with other compilers?
duml to generate UML diagrams in HTML format
I have created my first project in github, and I wanted to share it. https://github.com/tcak/duml I started working on it today morning, and completed in midday. But it is still in very early stages. So, I wanted to take thoughts of you guys. Purpose of this project is to put XML based comments into a text file (source code for programmers), and it generates UML diagram in a single HTML file. This is the result of duml's own source code at this point: http://imgur.com/0kfK9Xu Do you guys think that this will be any use as a D tool maybe? I am planning to add activity decisions, and linking actions to other HTML files. So, a general function that uses sub functions can link to activity diagram of those functions as well.
Re: duml to generate UML diagrams in HTML format
On Saturday, 9 May 2015 at 11:37:57 UTC, Rikki Cattermole wrote: On 9/05/2015 11:32 p.m., tcak wrote: I have created my first project in github, and I wanted to share it. https://github.com/tcak/duml I started working on it today morning, and completed in midday. But it is still in very early stages. So, I wanted to take thoughts of you guys. Purpose of this project is to put XML based comments into a text file (source code for programmers), and it generates UML diagram in a single HTML file. This is the result of duml's own source code at this point: http://imgur.com/0kfK9Xu Do you guys think that this will be any use as a D tool maybe? I am planning to add activity decisions, and linking actions to other HTML files. So, a general function that uses sub functions can link to activity diagram of those functions as well. Awkward. https://github.com/rikkimax/duml Whops! I better change name of mine to DUML: Age of Ultron
[Issue 14519] [Enh] foreach on strings should return replacementDchar rather than throwing
https://issues.dlang.org/show_bug.cgi?id=14519 --- Comment #28 from Martin Nowak c...@dawg.eu --- (In reply to Vladimir Panteleev from comment #25) Here, neither converting everything to UTF-8 or verifying that it is valid UTF-8 works, because text-based protocols often embed raw binary data. The program only needs to parse the ASCII text parts, so the ideal solution would be a string handling library which never decodes UTF-8 (something D doesn't have). Yes, and you would be better off to handle such protocols as ubyte. --
Compile Times on Windows
Wondering what is the average compile time users face on Wdinows is. I just downloaded dmd today to start learning some d and it takes 5 seconds for me to compile a simple hello, world. Wondering if I have something messed up? My laptop is Windows laptop, Win 8.1, 4th gen i7 intel processor and plenty of rAM. [Sat May 09 00:32:20 zebra@ZEBRA:~/personal/d ] $ cat hello.d #!/usr/bin/env rdmd import std.stdio; void main() { writeln(Hello, world!); }[Sat May 09 00:32:23 zebra@ZEBRA:~/personal/d ] $ dmd --version DMD32 D Compiler v2.067.1 Copyright (c) 1999-2014 by Digital Mars written by Walter Bright [Sat May 09 00:32:27 zebra@ZEBRA:~/personal/d ] $ which dmd /c/D/dmd2/windows/bin/dmd [Sat May 09 00:32:29 zebra@ZEBRA:~/personal/d ] $ time dmd hello.d real0m4.243s user0m0.015s sys 0m0.031s [Sat May 09 00:35:00 zebra@ZEBRA:~/personal/d ] $ time gdc hello.d real0m12.301s user0m0.015s sys 0m0.030s
[Issue 12260] Improve error of std.stdio.readf when involving whitespace
https://issues.dlang.org/show_bug.cgi?id=12260 Dave Akers d...@dazoe.net changed: What|Removed |Added CC||d...@dazoe.net --- Comment #1 from Dave Akers d...@dazoe.net --- Current version of d 2.67.1 will skip the \n, for example the program... -- void main() { import std.stdio; int input; readf(%s, input); readf(%s, input); } -- Given the input... -- 1 2 -- Will emit the error... -- std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '2' when converting from type LockingTextReader to type int -- --
[Issue 12260] Improve error of std.stdio.readf when involving whitespace
https://issues.dlang.org/show_bug.cgi?id=12260 Dave Akers d...@dazoe.net changed: What|Removed |Added Severity|enhancement |minor --
Re: Compile Times on Windows
zebrazebra wrote: $ time dmd hello.d real0m4.243s user0m0.015s sys 0m0.031s $ time ./hello.d Hello, world! real0m0.039s user0m0.000s sys 0m0.015s Why is the Hello, world! missing in your post? -manfred
Re: Dare I ... another volatile discussion ?
On Thursday, 7 May 2015 at 21:42:08 UTC, Iain Buclaw wrote: On 7 May 2015 at 23:39, Iain Buclaw ibuc...@gdcproject.org wrote: When used properly though, it's properties make it a prime candidate for the foundation of libraries/programs that centre around the use of atomics. However, shared is not to be confused with a thread-safe atomic type. Thread-safety is left to the end-user on such matters of access. That last sentence should also include a mention of memory ordering too being left to the end-user. Thank you for explaining this; it does make sense. :) -So 'shared' is not to be confused with 'atomic'; its behaviour seems closer to C's extern, do I understand this correctly ? One of the reasons I asked the question, is because no doubt D will need to write to hardware on any kind of platform, and I'd like it to be the same on both microcontrollers and a Personal Computer (not limited to a specific kind of processor). Another thing, slightly related, is 'atomic'. C's implementation allows you to have a function, which reads/modifies/writes a value atomically. This is all implemented 'outside' the C language. Would it make sense to mark a variable 'atomic', or would it be rather crazy, because if it's extern(C) anyway, C wouldn't access it atomically ?
Re: std.xml2 (collecting features)
On Monday, 4 May 2015 at 18:50:43 UTC, Marco Leise wrote: On Sunday, 3 May 2015 at 17:47:15 UTC, Joakim wrote: My request: just skip it. XML is a horrible waste of space for a standard, better D doesn't support it well, anything to discourage it's use. I'd rather see you spend your time on something worthwhile. If data formats are your thing, you could help get Ludwig's JSON stuff in, or better yet, enable some nice binary data format. You two are terrible at motivating people. Better D doesn't support it well and JSON is superior through-and-through is overly dismissive. To me it sounds like someone saying replace C++ with JavaScript, because C++ is a horrible standard and JavaScript is so much superior. Honestly. You seem to have missed the point of my post, which was to discourage him from working on an XML module for phobos. As for motivating him, I suggested better alternatives. And I never said JSON was great, but it's certainly _much_ more readable than XML, which is one of the basic goals of a text format. Remember that while JSON is simpler, XML is not just a structured container for bool, Number and String data. It comes with many official side kicks covering a broad range of use cases: XPath: * allows you to use XML files like a textual database * complex enough to allow for almost any imaginable query * many tools emerged to test XPath expressions against XML documents * also powers XSLT (http://www.liquid-technologies.com/xpath-tutorial.aspx) XSL (Extensible Stylesheet Language) and XSLT (XSL Transformations): * written as XML documents * standard way to transform XML from one structure into another * convert or compile data to XHTML or SVG for display in a browser * output to XSL-FO XSL-FO (XSL formatting objects): * written as XSL * type-setting for XML; a XSL-FO processor is similar to a LaTex processor * reads an XML document (a Format document) and outputs to a PDF, RTF or similar format XML Schema Definition (XSD): * written as XML * linked in by an XML file * defines structure and validates content to some extent * can set constraints on how often an element can occur in a list * can validate data type of values (length, regex, positive, etc.) * database like unique IDs and references These are all incredibly dumb ideas. I don't deny that many people may use these things, but then people use hammers for all kinds of things they shouldn't use them for too. :) I think XML is the most eat-your-own-dog-food language ever and nicely covers a wide range of use cases. The problem is you're still eating dog food. ;) In any case there are many XML based file formats that we might want to parse. Amongst them SVG, OpenDocument (Open/LibreOffics), RSS feeds, several US Offices, XMP and other meta data formats. Sure, and if he has any real need for any of those, who are we to stop him? But if he's just looking for some way to contribute, there are better ways. On Monday, 4 May 2015 at 20:44:42 UTC, Jonathan M Davis wrote: Also true. Many of us just don't find enough time to work on D, and we don't seem to do a good job of encouraging larger contributions to Phobos, so newcomers don't tend to contribute like that. And there's so much to do all around that the big stuff just falls by the wayside, and it really shouldn't. This is why I keep asking Walter and Andrei for a list of big stuff on the wiki- they don't have to be big, just important- so that newcomers know where help is most needed. Of course, it doesn't have to be them, it could be any member of the D core team, though whatever the BDFLs push for would have a bit more weight.
Re: readf error bug?
On Saturday, 9 May 2015 at 08:30:31 UTC, Dave Akers wrote: The following... import std.stdio; void main() { write(How many students are there? ); int studentCount; readf(%s, studentCount); write(How many teachers are there? ); int teacherCount; readf(%s, teacherCount); writefln(Got it: there are %d students., studentCount); writefln(And there are %d teachers., teacherCount); } When given the input... 10 42 will produce the error... std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '4' when converting from type LockingTextReader to type int I understand what is wrong and how to fix it but the produced error is incorrect. To '\ n' does not remain in the input stream, it is necessary to write so: - readf(%s , studentCount);
readf error bug?
The following... import std.stdio; void main() { write(How many students are there? ); int studentCount; readf(%s, studentCount); write(How many teachers are there? ); int teacherCount; readf(%s, teacherCount); writefln(Got it: there are %d students., studentCount); writefln(And there are %d teachers., teacherCount); } When given the input... 10 42 will produce the error... std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '4' when converting from type LockingTextReader to type int I understand what is wrong and how to fix it but the produced error is incorrect.
Re: readf error bug?
On Saturday, 9 May 2015 at 08:41:49 UTC, Dave Akers wrote: On Saturday, 9 May 2015 at 08:34:42 UTC, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 08:30:31 UTC, Dave Akers wrote: The following... import std.stdio; void main() { write(How many students are there? ); int studentCount; readf(%s, studentCount); write(How many teachers are there? ); int teacherCount; readf(%s, teacherCount); writefln(Got it: there are %d students., studentCount); writefln(And there are %d teachers., teacherCount); } When given the input... 10 42 will produce the error... std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '4' when converting from type LockingTextReader to type int I understand what is wrong and how to fix it but the produced error is incorrect. To '\ n' does not remain in the input stream, it is necessary to write so: - readf(%s , studentCount); I was meaning this as a bug report. issues.dlang.org please, otherwise no-one will remember to fix it.
Re: readf error bug?
On Sat, 09 May 2015 09:23:23 +, John Colvin wrote: On Saturday, 9 May 2015 at 08:41:49 UTC, Dave Akers wrote: On Saturday, 9 May 2015 at 08:34:42 UTC, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 08:30:31 UTC, Dave Akers wrote: The following... import std.stdio; void main() { write(How many students are there? ); int studentCount; readf(%s, studentCount); write(How many teachers are there? ); int teacherCount; readf(%s, teacherCount); writefln(Got it: there are %d students., studentCount); writefln(And there are %d teachers., teacherCount); } When given the input... 10 42 will produce the error... std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '4' when converting from type LockingTextReader to type int I understand what is wrong and how to fix it but the produced error is incorrect. To '\ n' does not remain in the input stream, it is necessary to write so: - readf(%s , studentCount); I was meaning this as a bug report. issues.dlang.org please, otherwise no-one will remember to fix it. Submitted... or rather found a similar one and updated it. https://issues.dlang.org/show_bug.cgi?id=12260
Re: Breaking changes in Visual C++ 2015
On Saturday, 9 May 2015 at 02:08:54 UTC, weaselcat wrote: On Friday, 8 May 2015 at 08:51:24 UTC, Walter Bright wrote: On 5/8/2015 12:45 AM, weaselcat wrote: some of these really are klunky though. Nobody's ever satisfied. Doesn't mean the tools aren't effective, and doesn't mean a complete lack of tooling. I think it's important to air grievances with the language because it won't get better by sticking our heads in the sand. Stating things like unit tests could have better reporting capabilities etc, sparks a good discussion on how to improve them, and I think this thread is proof of that. I think it's good to have an honest discussion about these issues, but there is also a tendency of some to go overboard. At times it crosses into trolling territory where they'll post something negative just to be posting something negative. One incident that stands out followed an announcement that got a lot of press for D, and someone thought it was a good use of his time to post a laundry list of problems with the language in that thread, much of which was pure crap. Those posts do not contribute anything.
Re: Multiple template alias parameters
On 05/08/15 23:56, Brian Schott via Digitalmars-d-learn wrote: On Friday, 8 May 2015 at 12:44:31 UTC, Artur Skawina wrote: On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: The problem occurs when I want to register multiple modules to scan for functions. The grammar does not allow this syntax: ``` template (alias Modules ...) { ... ``` The grammar allows omitting the 'alias' keyword. artur alias parameters are different from normal template parameters. They're not necessary for this problem, but they are for others. I was trying to hint at the fact that D's template tuple parameters already have the required magic. Hence, the trailing '...' makes that 'alias' unnecessary. As an example: void traceVar(alias var, size_t line = __LINE__, string file = __FILE__)() { import std.stdio: stderr; stderr.writeln(file, (, line, ) , var.stringof, : , var); } This allows you to print a variable's name and value by only passing the variable once as a template argument. Allowing template Tem(alias Args ...) syntax would let me trace multiple variables at once. If you omit alias, var.stringof evaluates to var instead of its name in the calling context. template traceVar(VARS...) { void traceVar(size_t line = __LINE__, string file = __FILE__)() { import std.stdio: stderr; foreach (I, ref var; VARS) stderr.writeln(file, (, line, ) , VARS[I].stringof, : , var); } } artur
Lambda functions in D
Hi, Can lambda functions or delegates in D to call themselves? Can I write something like this: - import std.stdio; void main() { auto fact = function (int x) = x * { if (x) fact(x - 1); }; assert(fact(10) == 3628800); }
Re: Lambda functions in D
Dennis Ritchie wrote: auto fact = function (int x) = x * { if (x) fact(x - 1); }; int fact (int x) { return x * ( x1 ? fact(x - 1): 1); }; -manfred
Re: DMD phobos built with contracts check for win?
On 05.05.2015 02:03, Dzugaru wrote: I have to compile it myself from sources or is it available somewhere? Was playing with fibers using VisualD + DMD and lack of contract checking (for example call() on fiber in state TERM) leads to bizarre crashes :( The latest (beta) version of Visual D comes with a new linker option build and use local phobos library that builds phobos with the options of the current project and links against it. https://github.com/D-Programming-Language/visuald/releases
Re: readf error bug?
On Saturday, 9 May 2015 at 08:34:42 UTC, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 08:30:31 UTC, Dave Akers wrote: The following... import std.stdio; void main() { write(How many students are there? ); int studentCount; readf(%s, studentCount); write(How many teachers are there? ); int teacherCount; readf(%s, teacherCount); writefln(Got it: there are %d students., studentCount); writefln(And there are %d teachers., teacherCount); } When given the input... 10 42 will produce the error... std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '4' when converting from type LockingTextReader to type int I understand what is wrong and how to fix it but the produced error is incorrect. To '\ n' does not remain in the input stream, it is necessary to write so: - readf(%s , studentCount); I was meaning this as a bug report. But wanted to point out your solution does not work. I was interested in D back in 1.0 days but soo much has changed in d 2.0 that I'm reading through the Programming in D book to learn all the new stuff and came across this odd un-helpful error. ... readf( %s, studentCount); ... readf( %s, teacherCount); ... that way it will ignore any non int chars left on the stdin stream.
Re: Breaking changes in Visual C++ 2015
On Saturday, 9 May 2015 at 05:12:28 UTC, H. S. Teoh wrote: On Fri, May 08, 2015 at 09:51:23PM +, deadalnix via Digitalmars-d wrote: [...] 4. profiler Same things, this is a standard tool nowaday for any language worth considering. In fact, even if we had no specific support in D for it, C/C++ tooling could probably do it for us to some extent. [...] I use dmd with gprof with not-bad results. It's not perfect, but at least I can get some useful info out of it. The built-in dmd profiler is unfortunately unusable for me because its function call counters wrap around far too early (IIRC they use 16-bit counters or something like that), whereas the test cases I need to optimize for are the long-running, steady state test cases in which millions or billions of function calls are made. Will this ever be improved? T have you tried oprofile? It's embarrassingly simple to use, especially compared to perf. oprofile used to be much worse though
Re: Compile Times on Windows
On Saturday, 9 May 2015 at 10:00:53 UTC, Manfred Nowak wrote: zebrazebra wrote: $ time dmd hello.d real0m4.243s user0m0.015s sys 0m0.031s $ time ./hello.d Hello, world! real0m0.039s user0m0.000s sys 0m0.015s Why is the Hello, world! missing in your post? -manfred he's timing compilation, not runtime. $ time dmd hello.d 0.30user 0.08system 0:00.40elapsed might be a windows issue?
Re: Calypso milestone hit: D adaptation of Qt5 tutorial working
On Saturday, 9 May 2015 at 02:58:58 UTC, Mike wrote: Question: You are using a modified version of LDC, but is that compiler required to consume link to a library created with that custom compiler? What I mean is: Can you use this modified version of LDC to create a library, and then use a generic D compiler to build an application that links to that library? Should be possible. If you properly encapsulate language extensions, nothing should prevent using the library.
Re: Compile Times on Windows
On 5/9/2015 3:44 AM, Dave Akers wrote: Or an anti-virus program interfearing? I had to disable Windows' built in antivirus because it is an anathema to a program that creates .exe files.
Re: Compile Times on Windows
On Saturday, 9 May 2015 at 10:44:29 UTC, Dave Akers wrote: On Sat, 09 May 2015 10:17:29 +, weaselcat wrote: On Saturday, 9 May 2015 at 10:00:53 UTC, Manfred Nowak wrote: zebrazebra wrote: $ time dmd hello.d real0m4.243s user0m0.015s sys 0m0.031s $ time ./hello.d Hello, world! real0m0.039s user0m0.000s sys 0m0.015s Why is the Hello, world! missing in your post? -manfred he's timing compilation, not runtime. $ time dmd hello.d 0.30user 0.08system 0:00.40elapsed might be a windows issue? weaselcat: Are you running windows 8.1 as well? No, I use Arch Linux.
Re: Lambda functions in D
On 05/09/2015 01:20 PM, Dennis Ritchie wrote: Hi, Can lambda functions or delegates in D to call themselves? Can I write something like this: - import std.stdio; void main() { auto fact = function (int x) = x * { if (x) fact(x - 1); }; assert(fact(10) == 3628800); } assert((function int(int x)=x?x*__traits(parent,{})(x-1):1)(10)==3628800);
Re: duml to generate UML diagrams in HTML format
On 9/05/2015 11:43 p.m., Rikki Cattermole wrote: On 9/05/2015 11:40 p.m., tcak wrote: On Saturday, 9 May 2015 at 11:37:57 UTC, Rikki Cattermole wrote: On 9/05/2015 11:32 p.m., tcak wrote: I have created my first project in github, and I wanted to share it. https://github.com/tcak/duml I started working on it today morning, and completed in midday. But it is still in very early stages. So, I wanted to take thoughts of you guys. Purpose of this project is to put XML based comments into a text file (source code for programmers), and it generates UML diagram in a single HTML file. This is the result of duml's own source code at this point: http://imgur.com/0kfK9Xu Do you guys think that this will be any use as a D tool maybe? I am planning to add activity decisions, and linking actions to other HTML files. So, a general function that uses sub functions can link to activity diagram of those functions as well. Awkward. https://github.com/rikkimax/duml Whops! I better change name of mine to DUML: Age of Ultron Haha! Yeah just make it a little unique to the project and it'll be all good. After all, no need to confuse a dead end project and one that has a good chance of being used ;) Just to make sure since no reply. Mine is the dead end one.
Re: Lambda functions in D
On Saturday, 9 May 2015 at 11:49:48 UTC, Timon Gehr wrote: assert((function int(int x)=x?x*__traits(parent,{})(x-1):1)(10)==3628800); Thanks. Yes, it is similar to what I wanted :)
Spawning a console in Windows (similar to forkpty on linux)
This isn't specifically a D question, but seeing as it's for a D library I figure it can go here :) On Windows, I want to be able to spawn a console and then interact with its stdin/out asynchronously, similar to how forkpty [1] works on linux. I'm improving my dexpect library [2] to work with windows machines and this bit has me stumped. There doesnt seem to be much info about it that I can find (though my google-fu mightn't be good enough!!) I'm sure theres someone here who knows something? Thanks! [1] http://linux.die.net/man/3/forkpty [2] https://github.com/grogancolin/dexpect
Re: Dare I ... another volatile discussion ?
On Thursday, 7 May 2015 at 16:04:56 UTC, Jens Bauer wrote: Regarding (1), because marking a variable 'shared' is not enough (it allows instructions to be moved around), Johannes already made a volatileLoad and volatileStore, which will be usable for microcontrollers, though for convenience, it requires writing additional code. -But this solution ... I do not know if it would work, when writing a driver for Debian running on a i586 platform or PowerMac G3 for instance. System calls on sufficiently smart processors like x86 use C-like ABI good practices: registers and buffers to pass data instead of global variables, because multithreaded programs will have race condition on accessing the global variables. See read(2) syscall as an example of such API http://man7.org/linux/man-pages/man2/read.2.html On Thursday, 7 May 2015 at 18:18:02 UTC, Johannes Pfau wrote: Not sure about shared (I don't think anybody knows what exactly shared is supposed to do) Shared is supposed to prevent the programmer from accidentally putting unshared data in a shared context. Expectedly people wanted it to be a silver bullet for concurrency, instead std.concurrency provides high-level concurrency safety.
Re: Spawning a console in Windows (similar to forkpty on linux)
On 10/05/2015 12:13 a.m., wobbles wrote: This isn't specifically a D question, but seeing as it's for a D library I figure it can go here :) On Windows, I want to be able to spawn a console and then interact with its stdin/out asynchronously, similar to how forkpty [1] works on linux. I'm improving my dexpect library [2] to work with windows machines and this bit has me stumped. There doesnt seem to be much info about it that I can find (though my google-fu mightn't be good enough!!) I'm sure theres someone here who knows something? Thanks! [1] http://linux.die.net/man/3/forkpty [2] https://github.com/grogancolin/dexpect Did you try creating a new process which is cmd? Because std.process should be able to handle the IO part.
Re: Breaking changes in Visual C++ 2015
On Saturday, 9 May 2015 at 09:31:10 UTC, bachmeier wrote: On Saturday, 9 May 2015 at 02:08:54 UTC, weaselcat wrote: On Friday, 8 May 2015 at 08:51:24 UTC, Walter Bright wrote: On 5/8/2015 12:45 AM, weaselcat wrote: some of these really are klunky though. Nobody's ever satisfied. Doesn't mean the tools aren't effective, and doesn't mean a complete lack of tooling. I think it's important to air grievances with the language because it won't get better by sticking our heads in the sand. Stating things like unit tests could have better reporting capabilities etc, sparks a good discussion on how to improve them, and I think this thread is proof of that. I think it's good to have an honest discussion about these issues, but there is also a tendency of some to go overboard. At times it crosses into trolling territory where they'll post something negative just to be posting something negative. One incident that stands out followed an announcement that got a lot of press for D, and someone thought it was a good use of his time to post a laundry list of problems with the language in that thread, much of which was pure crap. Those posts do not contribute anything. There is a tendency to bash and trash D for not having the exact same feature that some other language has, or for not having a tool that exists for some other language. This often gives the impression that D is unusable and complete crap, unless, of course, it will get feature X demanded by user Y. This type of discussion is not constructive, but guided by personal likes and dislikes and only creates a lot of noise with no real results. There is always room for improvement in software. All programs could be better, all tools could be better. But that something could be better doesn't mean that it's crap.
Re: Spawning a console in Windows (similar to forkpty on linux)
On Saturday, 9 May 2015 at 12:25:32 UTC, wobbles wrote: On Saturday, 9 May 2015 at 12:16:52 UTC, Rikki Cattermole wrote: On 10/05/2015 12:13 a.m., wobbles wrote: This isn't specifically a D question, but seeing as it's for a D library I figure it can go here :) On Windows, I want to be able to spawn a console and then interact with its stdin/out asynchronously, similar to how forkpty [1] works on linux. I'm improving my dexpect library [2] to work with windows machines and this bit has me stumped. There doesnt seem to be much info about it that I can find (though my google-fu mightn't be good enough!!) I'm sure theres someone here who knows something? Thanks! [1] http://linux.die.net/man/3/forkpty [2] https://github.com/grogancolin/dexpect Did you try creating a new process which is cmd? Because std.process should be able to handle the IO part. I have, but they all block i/o and so I cant continually read from its output :/ What I mean is, if the cmd.exe hasnt flushed it's output, my cmdPid.stdout.readln (or whatever) will block until it does. I dont really want this. I guess I need to make another thread to do this so I wont block the main thread?
Re: Spawning a console in Windows (similar to forkpty on linux)
On Saturday, 9 May 2015 at 12:16:52 UTC, Rikki Cattermole wrote: On 10/05/2015 12:13 a.m., wobbles wrote: This isn't specifically a D question, but seeing as it's for a D library I figure it can go here :) On Windows, I want to be able to spawn a console and then interact with its stdin/out asynchronously, similar to how forkpty [1] works on linux. I'm improving my dexpect library [2] to work with windows machines and this bit has me stumped. There doesnt seem to be much info about it that I can find (though my google-fu mightn't be good enough!!) I'm sure theres someone here who knows something? Thanks! [1] http://linux.die.net/man/3/forkpty [2] https://github.com/grogancolin/dexpect Did you try creating a new process which is cmd? Because std.process should be able to handle the IO part. I have, but they all block i/o and so I cant continually read from its output :/
Re: Lambda functions in D
On Saturday, 9 May 2015 at 14:15:21 UTC, Ali Çehreli wrote: On 05/09/2015 04:59 AM, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 11:49:48 UTC, Timon Gehr wrote: assert((function int(int x)=x?x*__traits(parent,{})(x-1):1)(10)==3628800); Thanks. Yes, it is similar to what I wanted :) Also interesting: http://rosettacode.org/wiki/Y_combinator#D I think that code was improved by Timon Gehr as well. Ali Yes, it's much better. Even something like Common Lisp.