Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On Friday, 18 January 2019 at 20:29:08 UTC, H. S. Teoh wrote: That would work, but it would also suffer from all the same problems as macro-based programming in C. The compiler would be unable to detect when you accidentally pasted type names together where you intended to be separate, the strings may not actually represent real types, and generating code from pasting / manipulating strings is very error-prone. And you could write very unmaintainable code like pasting partial tokens together as strings, etc., which makes it hard for anyone else (including yourself after 3 months) to understand just what the code is trying to do. Generally, you want some level of syntactic / semantic enforcement by the compiler when you manipulate lists (or whatever other structures) of types. T Well, it's the approach Andrei laid out in his DConf 2018 talk: https://youtu.be/-0jcE9B5kjs?t=2641 The advantage is how simple it is, and that it only uses existing language constructs. But, indeed, the problems you mention are not insignificant.
Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On Thursday, 17 January 2019 at 20:47:38 UTC, Steven Schveighoffer wrote: well, there was no static foreach for that article (which I admit I didn't read, but I know what you mean). But it's DEFINITELY not as easy as it could be: import std.conv; alias AliasSeq(P...) = P; template staticMap(alias Transform, Params...) { alias seq0 = Transform!(Params[0]); static foreach(i; 1 .. Params.length) { mixin("alias seq" ~ i.to!string ~ " = AliasSeq!(seq" ~ (i-1).to!string ~ ", Transform!(Params[" ~ i.to!string ~ "]));"); } mixin("alias staticMap = seq" ~ (Params.length-1).to!string ~ ";"); } alias Constify(T) = const(T); void main() { alias someTypes = AliasSeq!(int, char, bool); pragma(msg, staticMap!(Constify, someTypes)); // (const(int), const(char), const(bool)) } Note, that this would be a LOT easier with string interpolation... mixin("alias seq${i} = AliasSeq!(seq${i-1}, Transform!(Params[${i}]));".text); -Steve Why not do away with AliasSeq and use strings all the way? string Constify(string type) { // can add input checks here return "const(" ~ type ~ ")"; } void main() { import std.algorithm : map; enum someTypes = ["int", "char", "bool"]; enum constTypes = map!Constify(someTypes); mixin(constTypes[0] ~ "myConstInt = 42;"); // int myConstInt = 42; } Represent types as strings, CTFE them as you see fit, and output a string that can then be mixin'ed to use the actual type. :)
Re: I have a plan.. I really DO
On Thursday, 12 July 2018 at 14:49:14 UTC, bachmeier wrote: AFAICT, the money goes to internal compiler work to add new features to the language in order to appeal to C++ users. Well, there's also the redesign of the Phobos collections. I don't know if attracting C++ users is currently a specific goal of the D Foundation, but if it is, I suggest listening to the complaints that C++ users make (about C++, not D), e.g. [1]. Ironically, some of the common complaints, like incomprehensible error messages (for templates, anyway), are also common complaints about D. [1] https://www.reddit.com/r/cpp/comments/7lvteh/what_are_the_weakest_points_of_c_in_your_opinion/
Re: Silicon Valley D Meetup - October 26, 2017 - "D Fibers" by Ali Çehreli
On Saturday, 21 October 2017 at 18:20:13 UTC, Ali Çehreli wrote: D Fibers Ali will present a shorter version of his DConf 2016 talk: http://dconf.org/2016/talks/cehreli.html D's fibers (coroutines in other languages) are not a part of the language but a feature implemented by the D runtime. This talk should be fairly accessible to new programmers even without a CS background as it will explain the function call stack as well as context registers, concepts necessary to understand how fibers are useful at all. Ali Nice. I won't be there, but I really liked the talk about multitasking you gave at DConf 2016. I never heard of coroutines before it, so it pretty much blew my mind how easily you can iterate on several trees (simultaneously) with them.
Re: D on Tiobe Index
On Thursday, 31 August 2017 at 17:40:16 UTC, bitwise wrote: On Thursday, 31 August 2017 at 16:37:35 UTC, SrMordred wrote: On Thursday, 31 August 2017 at 14:57:28 UTC, bitwise wrote: https://www.tiobe.com/tiobe-index/d/ What happened in 2009? My first thought was that it was related to the D1 -> D2 transition, but that wasn't it. Considering that I had to ask for the graph to be generated though, I figured that it may have been omitted on purpose due to low sample size, i.e. noisy results. I wouldn't worry too much about it. Clearly the popularity of D is well correlated with U.S. real estate prices. :D
Re: Open Methods: From C++ to D
On Monday, 28 August 2017 at 12:19:26 UTC, Mike Parker wrote: Jean-Louis Leroy posted about his open methods library here in the forums some time ago. Now, he's written a blog post that explains what open methods are, and describes the D implementation and how it compares to his C++ library. The blog: https://dlang.org/blog/2017/08/28/open-methods-from-c-to-d/ Reddit: https://www.reddit.com/r/programming/comments/6wj0ev/open_methods_from_c_to_d/ Nice. This does seem superior to the visitor pattern.
Re: D books - 3 eBooks, videos, and courses for $25 right now
On Thursday, 3 August 2017 at 15:49:06 UTC, Martin Tschierschke wrote: On Thursday, 27 July 2017 at 08:29:14 UTC, Martin Tschierschke wrote: On Friday, 16 December 2016 at 05:43:02 UTC, Kai Nacke wrote: Hi all, Packt Publishing offers eBooks for $5 for a limited time. If your collection of D eBooks is still incomplete then this is a great chance for you. :-) D Cookbook by Adam D. Ruppe (https://www.packtpub.com/application-development/d-cookbook) Learning D by Michael Parker (https://www.packtpub.com/application-development/learning-d) D Web Development by myself (https://www.packtpub.com/web-development/d-web-development) Regards, Kai 3 eBooks, videos, and courses for $25 right now Not as cheap as in December but a good opportunity to take them all... And now as well, for $10 each. Do you know if the books are up to date with the language's MO? I don't think the language has changed much since the books were published, but maybe the idioms did...
Re: Eric Niebler talks about C++ Ranges at Microsoft Campus Wed evening
On Tuesday, 16 May 2017 at 17:44:28 UTC, Walter Bright wrote: http://nwcpp.org May 17th, 2017 at 7:00 PM Steptoe Room, Cafeteria 40, Microsoft Campus, 156th Ave NE, Redmond, WA 98052. Eric's talks are generally not to be missed. We often go out for beer afterwards :-) I remember this talk of him, which was great: CppCon 2015: Eric Niebler "Ranges for the Standard Library" https://www.youtube.com/watch?v=mFUXNMfaciE
Re: "Programming in D" is up-to-date
On Sunday, 14 May 2017 at 04:44:26 UTC, bluecat wrote: On Saturday, 13 May 2017 at 23:22:41 UTC, Ali Çehreli wrote: I've updated the book to 2.074.0. I've updated all paper and electronic versions at all publishers. However, I recommend that you wait a week or so before ordering (e.g. from Amazon) so that you get the latest version. (The copyright and Preface pages should say May 2017.) You can download the up-to-date versions here: http://ddili.org/ders/d.en/index.html The fonts are indeed embedded in the PDF, EPUB, and AZW3 formats. You may have to experiment with configuration settings of your e-reader to enable the embedded fonts. YMMV. :/ Ali I just wanted to say thank you very much for your book. It has been invaluable to me while learning D. Keep up the great work! Seconded.
Re: Testing in the D Standard Library
On Friday, 20 January 2017 at 13:35:40 UTC, Mike Parker wrote: Jack Stouffer details how unit testing, code review, and code coverage are handled in the development and maintenance of Phobos. Thanks, Jack! Blog: https://dlang.org/blog/2017/01/20/testing-in-the-d-standard-library/ Reddit: https://www.reddit.com/r/programming/comments/5p3vlq/testing_in_the_d_standard_library/ Very informative! Have you considered adding randomized tests to Phobos? For instance, for the sum() example, you could generate a random array x, say, 100 times and assert: sum(x) == x[0] + sum(x[1..$]); which is pretty much the defining property of the summation function (along with sum(a)==a[0] for an array of length 1).
Re: Getters/setters generator
On Wednesday, 18 January 2017 at 21:57:42 UTC, Andrei Alexandrescu wrote: On 1/18/17 5:29 PM, Mark wrote: I see. Is there a way to call invariant() of a class/struct directly? That would obviate the need for a particular predicate (copy the class state, run the setter, check if invariants are satisfied and restore previous state if they aren't). It seems painfully obvious the right way is a guarded assignment and anything else would be a more or less painful workaround. -- Andrei I agree. I'm just a bit unsettled by the slight code duplication that would ensue.
Re: Getters/setters generator
On Tuesday, 17 January 2017 at 15:59:26 UTC, Andrei Alexandrescu wrote: On 1/17/17 12:08 PM, Mark wrote: On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu wrote: On 1/17/17 9:32 AM, Eugene Wissner wrote: Ah, well thanks. I don't think it makes much sense since it would be easier to write a complete setter if the user needs extra checks. Accessors are there only for the generation of the standard methods, that just get or set some object property. Hmmm... that's a bit of a bummer because it helps only the degenerate case (accessors are there as placeholders for future extensions, and otherwise offer no protection whatsoever compared to a public value). The question would be then what would be use cases for the accessors. Predicated setters are not just a random thing one might want out of many possibilities, it's a frequent pattern. -- Andrei Given that D supports class invariants, is there a real need for predicated setters? The invariant is evaluated after the setter has taken place, i.e. after the object has been corrupted. The setter guard prevents corruption from happening. -- Andrei I see. Is there a way to call invariant() of a class/struct directly? That would obviate the need for a particular predicate (copy the class state, run the setter, check if invariants are satisfied and restore previous state if they aren't).
Re: Getters/setters generator
On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu wrote: On 1/17/17 9:32 AM, Eugene Wissner wrote: Ah, well thanks. I don't think it makes much sense since it would be easier to write a complete setter if the user needs extra checks. Accessors are there only for the generation of the standard methods, that just get or set some object property. Hmmm... that's a bit of a bummer because it helps only the degenerate case (accessors are there as placeholders for future extensions, and otherwise offer no protection whatsoever compared to a public value). The question would be then what would be use cases for the accessors. Predicated setters are not just a random thing one might want out of many possibilities, it's a frequent pattern. -- Andrei Given that D supports class invariants, is there a real need for predicated setters?
Re: Vision document for H1 2017
On Sunday, 8 January 2017 at 00:15:23 UTC, Seb wrote: On Saturday, 7 January 2017 at 23:33:45 UTC, Benjiro wrote: Maybe something to add ( for new users ) is something similar to: http://rustbyexample.com/ Easy to use, lots of information, simple tasks that involve interaction for the user, feedback on success. Do you know about the existing Dlang Tour? https://tour.dlang.org PRs/Issues to improve it are welcome Its translation into a couple of languages is WIP: https://github.com/dlang-tour I think the "D for C++ programmers" page could use a revamp: https://dlang.org/cpptod.html At the moment it mainly explains where and how D differs from C++. Whoever reads it may be ready to write C++ code in D, but this seems pointless and may give the impression that D is just C++ with a different syntax plus a few minor features (strong typedef and the scope statement). The page doesn't mention D's dynamic arrays, associative arrays, ranges, UFCS, function attributes and so on). The tour does mention these features (under "D's gems") so maybe some of its contents can be used to extend the "D for C++" page. One idea on my mind is providing various (honest, not specifically tailored) examples of C++ code that aims to solve a certain problem, and how the same problem can be solved in D in a better way (in some sense). I've seen this done effectively with Java vs. Scala.
Re: Silicon Valley D Meetup - December 22, 2016 - "The Curse of Knowledge: Et tu, D?" by Adam Wilson
On Saturday, 24 December 2016 at 07:30:56 UTC, Ali Çehreli wrote: On 12/15/2016 12:20 AM, Ali Çehreli wrote: https://www.meetup.com/D-Lang-Silicon-Valley/events/236253882/ The slides: http://files.meetup.com/18234529/The%20Curse%20of%20Knowledge.pptx The video: http://youtu.be/XjnBMfVTI0k (There is no audio on the recording until 45:45.) Ali Thanks for sharing this.
Re: Many documentation examples can now be run online
On Monday, 19 December 2016 at 17:50:17 UTC, Seb wrote: On Monday, 19 December 2016 at 17:44:29 UTC, Andrei Alexandrescu wrote: Take a look e.g. at https://dlang.org/phobos-prerelease/std_algorithm_iteration.html. Examples now have "Edit" and "Run" buttons that allow you to play with them online and see what they output. Changes for the ddox version forthcoming. Related: https://github.com/dlang/dlang.org/pull/1297, https://issues.dlang.org/show_bug.cgi?id=16984, https://issues.dlang.org/show_bug.cgi?id=16985. Many thanks to Sebastian Wilzbach who took this to completion, and to Damian Ziemba for working on the online compiler code! Andrei I would like to add that this is in an experimental/testing stage and hopefully will get stable with the next release ;-) Awesome.
Re: DIP 1003: remove `body` as a keyword
On Thursday, 24 November 2016 at 14:06:40 UTC, Jonathan M Davis wrote: Personally, I don't care much about having body as a usable symbol. It occasionally would be useful, but I can live without it. However, I _do_ find it very annoying that it's required for the function body when you have contracts. After all, it's not required when you write the function normally. Why should it be required when you have contracts on the function? The braces after the contracts are clearly for the function body. They couldn't be for anything else. The compiler always requires that the body be last after the in and out contracts, making the body keyword totally redundant. So, I've never understood why the body keyword was required. As far as I can tell, it fixes no ambiguity. It's just extra typing, and it makes contracts that much more verbose, which makes me that much more inclined to just not bother with them and put the assertions in the function body - particularly when I'm already of the opinion that they add no value outside of inheritance, because assertions at the beginning of the function take care of in contracts, and unit tests are really what covers the out contract case anyway (particularly since it's very rare that you can have a general test for the out contract rather than testing that specific input results in specific output). - Jonathan M Davis General tests of output are not so rare. The premise of property-based testing is being able to write such tests. Going over the functions in std.algorithm, for almost every one of them I can find a nontrivial property that any output should satisfy (for a valid input).
Re: Mir Blog: Writing efficient numerical code in D
On Monday, 12 December 2016 at 21:58:23 UTC, Relja Ljubobratovic wrote: [1] http://blog.mir.dlang.io/ndslice/algorithm/optimization/2016/12/12/writing-efficient-numerical-code.html [2] https://github.com/libmir/dcv [3] https://github.com/libmir/dcv/pull/58 Very impressive work.
Re: Please say hello to our third team member: Razvan Nitu
Welcome, Razvan! On Tuesday, 18 October 2016 at 18:21:31 UTC, Andrei Alexandrescu wrote: Hi everyone, Please join me in welcoming Razvan Nitu to our fledgling team of Romanian graduate students. Razvan has already some solid industrial experience and has a broad area of interests such as low-level kernel-level development, networking, distributed filesystems, and more. We're sure he'll find something to pique his interest :o). We are setting up the team in an office at University "Politehnica" Bucharest, close to their academic advisors. For now they're in bootcamp getting familiar with our toolchain. Please help me in getting everyone up to speed. Welcome, Razvan! Andrei Wow, the foundation is expanding much faster than I imagined. :o Do you plan to have the team work on something specific (after they get familiar with D)?