[Issue 15957] Disabled postblit + template mixin break opAssign with confusing error message
https://issues.dlang.org/show_bug.cgi?id=15957 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #2 from Walter Bright --- https://github.com/dlang/dmd/pull/5713 --
[Issue 15957] Disabled postblit + template mixin break opAssign with confusing error message
https://issues.dlang.org/show_bug.cgi?id=15957 Walter Brightchanged: What|Removed |Added Hardware|x86_64 |All OS|Linux |All --
[Issue 15939] GC.collect causes deadlock in multi-threaded environment
https://issues.dlang.org/show_bug.cgi?id=15939 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #8 from Walter Bright --- (In reply to Aleksei Preobrazhenskii from comment #7) > I was running tests for past five days, I didn't see any deadlocks since I > switched GC to using real-time POSIX signals (thread_setGCSignals(SIGRTMIN, > SIGRTMIN + 1)). I would recommend to change default signals accordingly. Since you've written the code to fix it, please write a Pull Request for it. That way you get the credit! --
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 20:01:34 UTC, Andrei Alexandrescu wrote: Andrei Alexandrescuwrote: https://github.com/dlang/phobos/pull/3971 I closed the PR as too controversial. -- Andrei I guess it's too late, but from what I gathered from the comments, main controversy is about the name but not the utility (e.g. Adam's `substr` vs `substring` argument). `printDelimited` and/or `printDelimitedLn`. Done. Maybe I'm too spoiled by IDEs, but I really think we should not optimize for short names in std library. My (PHP and Java) IDE would suggest `printDelimited` after typing "prd" or even "pd". I write such helper in every project and having it in phobos would be nice. (P.S. these naming and other bikeshedding debates are pretty depressing in this otherwise great community) -Alexander
Re: Russian group
On Wednesday, 27 April 2016 at 02:59:50 UTC, antonio ferreira wrote: On Wednesday, 2 December 2015 at 06:53:18 UTC, Suliman wrote: On Monday, 30 November 2015 at 10:58:34 UTC, Quentin Ladeveze wrote: Hi everybody, I just created a Telegram group for dlang users : https://telegram.me/joinchat/BeLaugMz35ZxQUq2fks4YQ Feel free to join ! Russian group https://telegram.me/joinchat/AtK90wNnU7mm0gx7yKo82w Does russian group still exist? :/ https://telegram.me/dlangru
[Issue 15960] SetUnion should filter duplicates
https://issues.dlang.org/show_bug.cgi?id=15960 greensunn...@gmail.com changed: What|Removed |Added CC||greensunn...@gmail.com Severity|enhancement |normal --
[Issue 15960] New: SetUnion should filter duplicates
https://issues.dlang.org/show_bug.cgi?id=15960 Issue ID: 15960 Summary: SetUnion should filter duplicates Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: greensunn...@gmail.com Have a look at http://en.cppreference.com/w/cpp/algorithm/merge http://en.cppreference.com/w/cpp/algorithm/set_union tl;dr: SetUnion should filter for duplicates "The difference between these two algorithms is with handling values from both input ranges which compare equivalent (see notes on LessThanComparable). If any equivalent values appeared n times in the first range and m times in the second, std::merge would output all n+m occurrences whereas std::set_union would output std::max(n, m) ones only" ``` [1,2].merge([1,3]) == [1,1,2,3] [1,2].setUnion([1,3]) == [1,2,3] ``` --
[Issue 15959] New: core.sys.windows modules should be modified for x64
https://issues.dlang.org/show_bug.cgi?id=15959 Issue ID: 15959 Summary: core.sys.windows modules should be modified for x64 Product: D Version: D2 Hardware: x86_64 URL: https://msdn.microsoft.com/en-us/library/aa383663(v=vs .85).aspx OS: Windows Status: NEW Severity: major Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: j...@red.email.ne.jp core.sys.windows.* modules came with 2.070. However, their support for x64 are not enough, then some of those API's need modified. The above MSDN link is the list of the APIs affected by x64. (I've been searching for it!) I'll send a PR later. --
Re: Walter's Famous German Language Essentials Guide
On Wednesday, 27 April 2016 at 02:57:47 UTC, Walter Bright wrote: To prepare for a week in Berlin, a few German phrases is all you'll need to fit in, get around, and have a great time: 1. Ein Bier bitte! 2. Noch ein Bier bitte! 3. Wo ist der WC! Some footage of Walter's last trip in Germany: https://www.youtube.com/watch?v=5bYMAgM42pM
Re: Russian group
On Wednesday, 2 December 2015 at 06:53:18 UTC, Suliman wrote: On Monday, 30 November 2015 at 10:58:34 UTC, Quentin Ladeveze wrote: Hi everybody, I just created a Telegram group for dlang users : https://telegram.me/joinchat/BeLaugMz35ZxQUq2fks4YQ Feel free to join ! Russian group https://telegram.me/joinchat/AtK90wNnU7mm0gx7yKo82w Does russian group still exist? :/
Re: Directions to Ibis Hotel in Berlin from Tegel Airport
On 4/26/2016 12:21 PM, Andrej Mitrovic via Digitalmars-d wrote: This is assuming you want to eat at those places while you're in Berlin, I'm looking forward to a bratwurst with some good senf!
Search dub via duckduckgo
For those that use duckduckgo as their search engine, you can now search the dub package registry with the '!dub' bang. I submitted this a while ago on a whim and it just got approved.
Re: Automatically enforce Phobos's styleguide
On Tuesday, 26 April 2016 at 19:04:44 UTC, Seb wrote: Hey all, tl;dr: I want to pull improve Phobos code style for the greater good of having a bot that automatically checks the coding style. This should be quite useful for submitters. I hope we all agree that the time spent "nitpicking" is wasted, we overlook much (see below) and we can do better! Agenda -- The idea is quite simple: 1) Fix one violation for the entire codebase 2) Enable it in the bot. 3) Pick next violation and goto 1) Great news: 1) I submitted a couple of trivial fixes (#4245, #4246, #4247) 2) The Travis bot passes :) As mentioned I decreased the linting to a minimum, but now we do have it :) Future work can fix more violations in the Phobos codebase - small low hanging fruits include e.g. > 120 lines or undocumented public methods. For more details: https://github.com/dlang/phobos/pull/4243
Re: DlangUI MouseEvent mouse delta
I am currently handling it like this: current = e.pos(); xdelta = current.x - previous.x; ydelta = current.y - previous.y; previous = current; I'm just wondering if there is a built in solution that I missed.
Re: Line spacing for '///ditto' on the website
On Sunday, 24 April 2016 at 11:25:46 UTC, Nick Treleaven wrote: There should be expand/collapse buttons for overload details so you can compare them simultaneously. That's not a bad idea, but I'm probably not going to do it just because it doesn't fit well with my plan of separate pages for each function - including overloads. On the separate pages, there may be completely different documentation, and even if the source says "///ditto", the generator does things like filter out params that don't exist on this overload. So I'd suggest just opening in two browser windows instead and positioning them side-by-side It could also be done in Javascript. Maybe I will consider that later. I think template args should not be elided completely in the summary, at least (...) should be shown in the signature. Yeah, I actually agree with that now, as long as they are constrained (hah) by the nowrap css rule, I think they are fine. I am going to see about adding them on the next version. I think there are too many line breaks, maybe this instead: Function endsWith -> bool @anyAttributes (alias pred, R) (R doesThisEnd) if (isInputRange!R && ifTestable!(typeof(doesThisEnd.front), unaryFun!pred)) The counterpoint to this is any page with complex individual arguments. http://dpldocs.info/experimental-docs/simpledisplay.SimpleWindow.this.1.html SimpleWindow's constructor has several parameters, most with default values. Take away the linebreaks there and it becomes an unreadable mess. I don't have an example of long template arguments off the top of my head, but even cgi.d's main mixin starts to show it: http://dpldocs.info/experimental-docs/arsd.cgi.CustomCgiMain.html Since template arguments can have types and default values too (and specializers!), they can get really messy on one line as well. So, putting them on one line really hurts those cases, and I don't think putting them on separate lines really hurts the easy cases (like endsWith, or std.math http://dpldocs.info/experimental-docs/std.math.cos.3.html it is a bit silly to break it down there, but it doesn't really /hurt/), I am erring on the side of using more space. oh dear the table of contents there indeed is silly, I need to take that back out unless there's several headers.
Re: C header file: tagged enumerations
On Tuesday, 26 April 2016 at 23:33:08 UTC, Stefan Koch wrote: static if (win32msi >= 500) . Won't work here because static if must have a complete declaration inside it, and the C pattern only has a few elements of the whole inside each #if. D doesn't handle this C pattern well... you basically have to rewrite the whole thing for each version. Personally, I just decide to support all of them and say the older versions with less declarations are less supported...
Re: C header file: tagged enumerations
On Tuesday, 26 April 2016 at 23:33:08 UTC, Stefan Koch wrote: On Tuesday, 26 April 2016 at 22:57:36 UTC, Jesse Phillips wrote: Windows tends to have these in their header files, what is the best way to translate them to D? [...] eunm win32msi = mixin(_WIN32_MSI); static if (win32msi >= 500) . Sorry forgot to mention that static if doesn't allow adding partial declarations, always need to be complete. Or to quote the compiler: "Error: basic type expected, not static"
Re: Line spacing for '///ditto' on the website
On Sunday, 24 April 2016 at 07:56:07 UTC, default0 wrote: Only thing I dislike about it is that the "Overload: signature>" thing of the currently selected overload vanishes completely, instead of just changing color to suggest it is the active one you selected. Try it now: http://dpldocs.info/experimental-docs/std.algorithm.searching.endsWith.2.html Also, your search currently does not list modules as search results (try searching base64, it will only show things like the Base64/Base64Impl things etc). Huh, good catch! I split identifiers on snake_name and camelCase for partial matches, but never split module names on dots. It is rebuilding its index now, you should see new results pretty soon. (The slow thing about it right now is I have to rebuild docs package-at-a-time for interlinking and nav, and I have to rebuild EVERYTHING for the search index. Before going beta and taking public packages to add to the docs, I need to make the regeneration incremental as it takes a while now.) Anyhow I really should be using your docs by now, seems the timeframe where you hit a "this has not been implemented yet, sorry"-warning on half the links you click on is finally over Aliases and single variable enums still have bugs in the generator (`alias a = b;` works, but `alias b a;` doesn't, and it thinks `enum a = 0;` is the same as `auto a = 0;`), but yeah, most everything else works now. I am also in the process of switching syntax away from Phobos' ad-hoc macros over to my new convenient things, so pages are still changing but most of them should be legible now. I'm still short of my major goals of rewritten content and heavy interlinking - it can only automatically link names from the same module right now (it parses imports but doesn't analyze them at this point), but indeed, I think it is a huge step up from the main site. This doc btw is describing my syntax changes: http://dpldocs.info/experimental-docs/test.html
Re: C header file: tagged enumerations
On Tuesday, 26 April 2016 at 22:57:36 UTC, Jesse Phillips wrote: Windows tends to have these in their header files, what is the best way to translate them to D? [...] eunm win32msi = mixin(_WIN32_MSI); static if (win32msi >= 500) .
C header file: tagged enumerations
Windows tends to have these in their header files, what is the best way to translate them to D? https://msdn.microsoft.com/en-us/library/whbyts4t.aspx Example below. In general a named enum is close enough to the same thing, but this example has additional enumerations added based on the preprocessor. Assuming _WIN32_MSI is defined for compile time, what is recommended for creating this enum? typedef enum tagINSTALLMESSAGE { // 12 others ... INSTALLMESSAGE_INITIALIZE , INSTALLMESSAGE_TERMINATE , INSTALLMESSAGE_SHOWDIALOG , #if (_WIN32_MSI >= 500) INSTALLMESSAGE_PERFORMANCE, #endif // (_WIN32_MSI >= 500) #if (_WIN32_MSI >= 400) INSTALLMESSAGE_RMFILESINUSE , #endif // (_WIN32_MSI >= 400) #if (_WIN32_MSI >= 450) INSTALLMESSAGE_INSTALLSTART , INSTALLMESSAGE_INSTALLEND , #endif // (_WIN32_MSI >= 450) } INSTALLMESSAGE;
Re: Automatically enforce Phobos's styleguide
I maintain some of the linters at work. One suggestion I'd have (perhaps you're already on it) is that a linter that can both detect and prompt to auto-fix the issues is at least an order of magnitude more useful. People fix things more, people like the linters more, it avoids the fallacy of trying to get people to read big paragraphs of how to fix things themselves... it's just generally a much more awesome experience. Would recommend.
[Issue 15939] GC.collect causes deadlock in multi-threaded environment
https://issues.dlang.org/show_bug.cgi?id=15939 Vladimir Panteleevchanged: What|Removed |Added CC||c...@dawg.eu, ||thecybersha...@gmail.com --
Re: Some questions on latest work
On Tuesday, 26 April 2016 at 01:48:21 UTC, bigsandwich wrote: 1) This rant has nothing to do with OP's questions. It does not help him. I disagree. It does help him. It has the potential to save him time and frustration. One thing that is common among most PL communities is that they do not explicitly and openly communicate design flaws, and every other shortcoming in the language that has the potential to impact the user and their projects, with the outside world. I can understand such a thing from a corporation and their marketing department, whose goal is to make money by manipulating people to buy their stuff, but not from a community of volunteers whose so-called goal is to make life easier for the rest of us. 2) Its a community driven project, and its free. That's a lame excuse that's been used over and over again in FOSS communities, usually by those who have failed or are in the process of failing. It's getting worse as more and more sophisticated idiots put their junk on Github and then make a big announcement on reddit/HN for others to start using their greatest inventions. If you would rather use C++ or Rust, you know where to find them. That's a kind of response one gets from Amerikans everytime someone criticizes the government, the educations system, the financial and the banking system, etc. "If you don't like it, get the f**k out; this is 'Merica, the greatest country in the world on God's greenest earth." The only people who think Amerika is great are the brain-dead and brainwashed Amerikans themselves. So if you want people to use other languages, then stop elevating D to such high places where it doesn't belong. On DConf, the title of Andrei's next talk should be "D's flaws and why you shouldn't use it." And maybe Walter could talk about how "In 15 years Perl6 introduced more innovations than D in 20". Think about it, D is refurbished C++, done by those with zero experience designing a successful programming language. And what is C++? Possibly one of the worst programming languages in the world. That says something.
Re: LDC 1.0.0-beta1 has been released! Please help testing!
On Monday, 25 April 2016 at 06:42:02 UTC, Kai Nacke wrote: LDC 1.0.0-beta1, the LLVM-based D compiler, is available for download! Using a recent build of LDC I was able to build EMSI's core data processing library and get it to pass all of its tests. It also seems to handle DCD and D-Scanner correctly now.
Re: LZ4 decompression at CTFE
On Tuesday, 26 April 2016 at 22:07:47 UTC, MrSmith wrote: I would like to use this instead of c++ static lib. Thanks! (I hope it works at runtime too). Oh and If you could please send me a sample of a file you are trying to uncompress. That would be most helpful.
Re: LZ4 decompression at CTFE
On Tuesday, 26 April 2016 at 22:07:47 UTC, MrSmith wrote: I would like to use this instead of c++ static lib. Thanks! (I hope it works at runtime too). Sure it does, but keep in mind the c++ version is heavily optimized. I would have to make a special runtime version to archive comparable performance I think. That said, I already plan to write another optimized version. Concerning compression. I am fairly certain I can beat the compression ratio of lz4hc in a few cases. But it is going to be slower.
LZ4 decompression at CTFE
Hello, originally I want to wait with this announcement until DConf. But since I working on another toy. I can release this info early. So as per title. you can decompress .lz4 flies created by the standard lz4hc commnadline tool at compile time. No github link yet as there is a little bit of cleanup todo :) Please comment.
Re: LZ4 decompression at CTFE
On Tuesday, 26 April 2016 at 22:05:39 UTC, Stefan Koch wrote: Hello, originally I want to wait with this announcement until DConf. But since I working on another toy. I can release this info early. So as per title. you can decompress .lz4 flies created by the standard lz4hc commnadline tool at compile time. No github link yet as there is a little bit of cleanup todo :) Please comment. I would like to use this instead of c++ static lib. Thanks! (I hope it works at runtime too).
Re: Some questions on latest work
On Tuesday, 26 April 2016 at 02:33:41 UTC, Andrei Alexandrescu wrote: That's a pretty awesome rant! Bill, could you please email me your mailing address? I'd be glad to send you a DConf T-shirt. Thanks! -- Andrei Quitting a well paying job at Facebook to peruse a hobby sounds like something a person going through midlife crisis would do. You may keep the T-shirt. I suggest you smoke some DMT (and have a breakthrough), or have a few Ayahuasca sessions. If that doesn't set you off on a path to the greatest positive impact, then nothing ever will. Everything you've desired to achieve with D is a construct of your ego, and nothing more.
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 21:11:22 UTC, Solomon E wrote: ... writesln(a, b); // I would expect does the same as writefln("%s %s", a, b); alias print = writesln!(separator="\t"); print(a, b); // now with tab separation ... Sorry about using a named template argument when that isn't a thing apparently. writesln!"\t"("A", "B"); // tab separation void print(string separator = "\t", string eol = "\n", S...)(auto ref S args) { writesln!(separator, eol, S)(args); } print("A", "B"); // now with tab separation Those lines successfully run, and I don't know how to define a custom "print" shorter yet.
[Issue 7417] One-definition rule for version specification - allow version expressions
https://issues.dlang.org/show_bug.cgi?id=7417 Witold Barylukchanged: What|Removed |Added CC||bary...@smp.if.uj.edu.pl --- Comment #6 from Witold Baryluk --- Hi. Any update on this. I was just trying to compiled phobos using gdc on arm64, and of course first thing that failed was a static assert in libdruntime/core/sys/posix/sys/socket.d that do have about 10 different semi duplicated version branches. I would really want to say: version (ARM || AArch64 || PPC || PPC64 || MIPS32 || MIPS64 || X86 || X86_64) { ... } else version (SomethingSpecial) { ... } else { static assert(0); } That would be good enough in most cases. Support for more elaborate conditions would be nice too. instead of version (A) { } else { somethign special. } version (!A) { something special. } or version (A) { version (B) { something. } } version (A && B) { something. } It is probably possible to implement what I want using mixing and putting common code in the template, and then expand version (ARM || AArch64 || PPC || PPC64 || MIPS32 || MIPS64 || X86 || X86_64) { into separate branches with mixed-in template. Still I fell, explicit booleans support on versions would be nicer. BTW. The mentioned file also shows almost the same enums in the OSX and FreeBSD branches, so maybe in this case it is worth doing this via mixin, as the OSX and FreeBSD branches cannot be really folded easily into one version (OSX || FreeBSD) branch. Same with Android (with do have same enum values as Linux). --
Re: Directions to Ibis Hotel in Berlin from Tegel Airport
On Tuesday, 26 April 2016 at 19:21:13 UTC, Andrej Mitrovic wrote: It's really not so bad anymore as it used to be. Credit cards are accepted in most stores or supermarkets, even "Netto" which is a discount-store and which started accepting Visa just last year. Other stores like "Real" and "Kaisers" will accept Visa, even many small shops will accept it. Then again the Burger King at Alexanderplatz will for some reason *not* accept any credit card, while the McDonalds which is ~50 meters away will. This is assuming you want to eat at those places while you're in Berlin, obviously there's great food here that you could try rather than go to the familiar fast-food chains.. If you're going to go for a döner kebab prepare some cash! In some cases they might ask you for your ID (e.g. passport). On 4/26/16, Johannes Pfau via Digitalmars-dwrote: Am Tue, 26 Apr 2016 12:25:41 + schrieb Kagamin : On Monday, 25 April 2016 at 09:16:11 UTC, Iain Buclaw wrote: > Germany is a cash-in-hand country. Credit cards are > rejected in most places that I've tried. You mean debit cards are accepted? Anyway why credit cards? Aren't credit money more expensive than debit? The overdraft limit is just a fixed offset from zero and you pay extra interest, one could just imagine zero balance at his preferred offset and keep it there. The girocard (sometimes called EC card) debit card system is accepted at most places: https://en.wikipedia.org/wiki/Girocard IIRC you need a german bank account though to own such a card ;-) I was today to TXL, so I took some pictures while riding home (I was sitting on a passenger side). First, here are the routes for 109 and U7: https://www.bvg.de/images/content/linienverlaeufe/LinienverlaufBus109.pdf https://www.bvg.de/images/content/linienverlaeufe/LinienverlaufU7.pdf This is the U-Bahnhof Jakob-Keiser-Platz: http://imgur.com/nCBxOho This is the pink-orange building just before it (I took a picture when I passed it): http://imgur.com/zrQw6Fn In the bus, there's a display showing next station and a voice (in German, but even I can recognize the name of the station) telling the name of the next station. It's needed to indicate that you're going off the bus (this caught me when I was a new one) which needs to be pressed *before* the bus arrive to the station (if somebody has pressed it, you'll see red STOP on the right corner of the display) by pressing one of the green tasters on the yellow bars. Sorry for the potato quality: http://imgur.com/gTzEtxh And *bonus level*. If you didn't get off at U-Bahnhof Jakob-Keiser-Platz, 15 minutes after, 109 will get to U Bahnhof Adenauerplatz where you can catch U7 again (just after it turns right after S-Bahnhof Charlottenburg): http://imgur.com/0TZWI7P
Re: Checking if an Integer is an Exact Binary Power
On 26.04.2016 17:27, Xinok wrote: On Monday, 25 April 2016 at 15:35:14 UTC, Dominikus Dittes Scherkl wrote: On Monday, 25 April 2016 at 15:27:02 UTC, Xinok wrote: Brute force. http://dpaste.dzfl.pl/882d7cdc5f74 Yeah. And your test spares the failed case int.min (0x8000), because in this case x & -x is negative, but of cause x>>>1 is positive, so it returns false despite -(2^^31) is in fact a power of two. So this requires an extra cast to work correct (in fact no big difference in the assembly): return (Unsigned!T)(x & -x) > (Unsigned!T)(x >>> 1); How is it wrong? Negative numbers are NOT powers of two (unless you have an imaginary/complex exponent), so it's still correct to return false for -int.min. Should it not? http://www.wolframalpha.com/input/?i=solve+2^n+%3D+-%282^31%29+for+n static assert(2^^31==int.min); // :o)
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 16:30:22 UTC, Jonathan M Davis wrote: On Tuesday, April 26, 2016 12:18:11 cym13 via Digitalmars-d wrote: Finally it doesn't bring much. One learns writeln, laments a bit that it doesn't put spaces itself then just accepts it. I confess that I was very surprised to find out that writeln worked with multiple arguments. In my initial look at D I would have appreciated print. However, at least part of the reason is that it was a while before I knew writefln existed. After finding it (and discovering that writeln takes multiple arguments), having the functionality of print was less an issue. It's not easy to reconstruct why it took me a while to discover writefln, but perhaps finding places to show it off in introductory material would help others find it more quickly. --Jon
Re: Simple and effective approaches to constraint error messages
On 26.04.2016 13:26, Marc Schütz wrote: Currently, there is no boolean short-cut evaluation in template constraints, see: bool foo()() { pragma(msg, "foo"); return true; } bool bar()() { pragma(msg, "bar"); return true; } void main() { static assert(__traits(compiles, foo() || bar())); } Prints "foo" and "bar", even though bar() wouldn't need to be evaluated anymore after foo() returned true. There sometimes is short-cut evaluation. This only prints "Foo": template Foo(){ pragma(msg, "Foo"); enum Foo=true; } auto bar()(){ pragma(msg, "bar"); return true; } void main(){ static assert(Foo!()||bar()); } I don't see the point of the different behaviour for those cases.
[Issue 8384] std.conv.to should allow conversion between any pair of string/wstring/dstring/char*/wchar*/dchar*
https://issues.dlang.org/show_bug.cgi?id=8384 --- Comment #25 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/60a233372a96abab810f030b4e3ff494987aa25e Partial fix of Issue 8384 - std.conv.to should allow conversion between any pair of string/wstring/dstring/char*/wchar*/dchar* https://github.com/dlang/phobos/commit/22c7f11265d62ad1ac387bc9aaa90b742f9563b2 Merge pull request #4199 from Biotronic/fix-8384 Partial fix of Issue 8384 - std.conv.to should allow conversion betwe… --
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 12:38:06 UTC, Jonathan M Davis wrote: On Tuesday, April 26, 2016 08:50:23 ixid via Digitalmars-d wrote: and seem to think 'print(a, b, c);' is going to confuse people more than 'writefln("%s %s %s", a, b, c);' which is ridiculous. Honestly, I think that writefln is way clearer than print. Certainly, if you're familiar with printf, it's pretty obvious what writefln does with the possible confusion over whether it prints a newline or not (and the ln in the name is there to tell you that), whereas it's not at all obvious what print is going to do without looking at the docs. We could always use C++ streams! They are perfectly clear what they're doing, right? stdout << a << " " << b << " " << c << endl; Seriously, a formatting line may only be confusing at first, but it's something you need to learn at some point. I don't ever want to rely on something as ugly as streams. C had printf; which was print, with an f! and that was good enough for everything! (I feel like I'm quoting Garfield now) Not that long ago when I was getting into D, I used printf more, then when I memorized writeln I used it a lot more. It's really not that bad. More people should sit down and read the damn documentation (mind you I've read about half of it, and I need to start over now since it's been so long).
Re: So, to print or not to print?
Andrei Alexandrescuwrote: > https://github.com/dlang/phobos/pull/3971 > > Walter and I were talking this morning that there should be a high > barrier of entry for one-liners in Phobos. The "print" function is > technically a one-liner (i.e. writefln with the appropriate format > string). On the other hand, it may be convivial enough to warrant > inclusion, and saves us from embarrassing things such as producing > meaningless output when numbers are printed together. > > There's been a bit of churn in the PR comments regarding the utility of > "print", and discussion diverged into other functions such as "dump" > etc. Keeping it on topic: any strong cons and pros regarding the > function? I want to either merge or close the PR and move on. > > > Thanks, > > Andrei > I closed the PR as too controversial. -- Andrei
Re: Some questions on latest work
On Tuesday, 26 April 2016 at 18:16:42 UTC, Joakim wrote: On Tuesday, 26 April 2016 at 13:55:23 UTC, ag0aep6g wrote: Please don't bash on other languages, especially when they're perceived as competition. It reflects badly on the D community. He gave very specific criticism, along with a code sample, then made a prediction, followed by suggesting another competing language that might do better. To be honest when I looked at the code I thought it was really hard to read and it was C++, it wasn't until I noted we were talking about rust that I looked at it again, but it hurts my eyes and my head...
Re: Some questions on latest work
On Tuesday, 26 April 2016 at 19:39:01 UTC, ag0aep6g wrote: None of that is the usual content-free fanboy "bashing." I don't agree. I don't see any content to speak of. You are talking a lot for someone who sees nothing to speak of.
Re: Checking if an Integer is an Exact Binary Power
On Tuesday, 26 April 2016 at 18:04:53 UTC, deadalnix wrote: You got to explain me how you end up with a negative number by multiplying 2 by 2 a bunch of time. You gotta scrawl your numbers down badly so one of the 2's looks like a minus sign. Or go so large that the universe caves in on itself.
Re: String lambdas
On Tuesday, 26 April 2016 at 17:58:22 UTC, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/3882 I just closed with some regret a nice piece of engineering. Please comment if you think string lambdas have a lot of unexploited potential. I'm of the opinion that string lambdas must go. I started, and I really should finish it at some point, removing string lambdas from the documentation: https://github.com/dlang/phobos/pull/3800 I think that the drawback you mentioned does not outweigh the benefits gained from using actual lambdas.
Re: Some questions on latest work
On 26.04.2016 20:16, Joakim wrote: He gave very specific criticism, This is not "very specific criticism": "Are you joking? When I am reading it's code my eyes begin to bleed. It's syntax is terrible. [...] Do you really think that modern language should like this?" along with a code sample, He gave a code sample, yes. He didn't point out what he dislikes about it. He didn't contrast it with another language. then made a prediction, You skipped the part where he puts puts down Rust "fan boys", saying they don't even understand Rust code. His "prediction" is the death of Rust. In my opinion, calling death upon competing projects is bad form. [...] None of that is the usual content-free fanboy "bashing." I don't agree. I don't see any content to speak of.
Re: Directions to Ibis Hotel in Berlin from Tegel Airport
It's really not so bad anymore as it used to be. Credit cards are accepted in most stores or supermarkets, even "Netto" which is a discount-store and which started accepting Visa just last year. Other stores like "Real" and "Kaisers" will accept Visa, even many small shops will accept it. Then again the Burger King at Alexanderplatz will for some reason *not* accept any credit card, while the McDonalds which is ~50 meters away will. This is assuming you want to eat at those places while you're in Berlin, obviously there's great food here that you could try rather than go to the familiar fast-food chains.. If you're going to go for a döner kebab prepare some cash! In some cases they might ask you for your ID (e.g. passport). On 4/26/16, Johannes Pfau via Digitalmars-dwrote: > Am Tue, 26 Apr 2016 12:25:41 + > schrieb Kagamin : > >> On Monday, 25 April 2016 at 09:16:11 UTC, Iain Buclaw wrote: >> > Germany is a cash-in-hand country. Credit cards are rejected >> > in most places that I've tried. >> >> You mean debit cards are accepted? Anyway why credit cards? >> Aren't credit money more expensive than debit? The overdraft >> limit is just a fixed offset from zero and you pay extra >> interest, one could just imagine zero balance at his preferred >> offset and keep it there. > > The girocard (sometimes called EC card) debit card system is accepted at > most places: https://en.wikipedia.org/wiki/Girocard IIRC you need a > german bank account though to own such a card ;-) >
Re: String lambdas
On Tuesday, April 26, 2016 13:58:22 Andrei Alexandrescu via Digitalmars-d wrote: > https://github.com/dlang/phobos/pull/3882 > > I just closed with some regret a nice piece of engineering. Please > comment if you think string lambdas have a lot of unexploited potential. Well, they're nicer than the "new" lambda syntax for really short stuff like "a == b" or "a != b", but beyond that, the newer syntax mostly does what the string lambdas were trying to do. And if your lambda gets very long, it really should be replaced with something like a nested function anyway. Pretty much anything complicated shouldn't be a lambda, or it risks being unmaintainable. So, while that PR was indeed a nice piece of engineering, it seems to be solving a problem that really shouldn't be solved with lambdas anyway. > One thing we really need in order to 100% replace string lambdas with > lambdas is function equivalence. Right now we're in the odd situation > that SomeTemplate!((a, b) => a < b) has distinct types, one per > instantiation. Once that's solved, we can consider deprecating string lambdas, but equivalence is indeed the one killer feature that non-string lambdas lack. However, from what I recall of discussions on that, it sounded like it was going to be pretty nasty to implement. :( - Jonathan M Davis
[Issue 15111] hashOf fails for structs that have an alias this to a dynamic array
https://issues.dlang.org/show_bug.cgi?id=15111 --- Comment #1 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/3af285fea29e7bbe2bea9b4fcb4b93f1ecb72755 fix issue 15111 - hashOf fails for structs that have an alias this to a dynamic array https://github.com/dlang/druntime/commit/2d8b0a5901bde46d3f773ad1a22cd3780306067c Merge pull request #1536 from BBasile/issue-15111 fix issue 15111 - hashOf fails for structs that have an alias this to a dynamic array --
[Issue 15111] hashOf fails for structs that have an alias this to a dynamic array
https://issues.dlang.org/show_bug.cgi?id=15111 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
Re: Automatically enforce Phobos's styleguide
On Tuesday, 26 April 2016 at 19:04:44 UTC, Seb wrote: As expected a styleguide without a automatically enforcing it, leaks ... It's not so much a matter of "leaks" - rather, much of DMD, D-runtime, and Phobos pre-date the style rules, and so never attempted to follow them in the first place. Indeed, some of the rules we have now were chosen simply by surveying the existing eclectic code base to determine which conventions were *most common* - in some cases by slim margins...
DlangUI MouseEvent mouse delta
I am trying to know how much the mouse moves when clicking down on a certain widget, but I can't figure out how. I noticed only a mouse wheel delta property and nothing for the mouse pointer x,y deltas since the click. I am looking to do something such as if(e.lbutton().isDown() && !e.rbutton().isDown()) { pitch -= e.dy(); }
Automatically enforce Phobos's styleguide
Hey all, tl;dr: I want to pull improve Phobos code style for the greater good of having a bot that automatically checks the coding style. This should be quite useful for submitters. I hope we all agree that the time spent "nitpicking" is wasted, we overlook much (see below) and we can do better! Agenda -- The idea is quite simple: 1) Fix one violation for the entire codebase 2) Enable it in the bot. 3) Pick next violation and goto 1) First violation: space between operators Can be easily fixed by running this: ``` sed -i "s/switch(/switch (/" **/*.d sed -i "s/foreach(/foreach (/" **/*.d sed -i "s/foreach_reverse(/foreach_reverse (/" **/*.d sed -i "s/while(/while (/" **/*.d sed -i "s/if(/if (/" **/*.d ``` I started with some PRs (one is way to large to review): https://github.com/dlang/phobos/pull/4239 https://github.com/dlang/phobos/pull/4240 https://github.com/dlang/phobos/pull/4241 https://github.com/dlang/phobos/pull/4242 How big is this change? --- grep -E "(for|foreach|foreach_reverse|if|while)\(" $(find . -name '*.d') | wc -l 3505 As expected a styleguide without a automatically enforcing it, leaks ... Disadvantages - This potentially might create some troubles with forks or pending PRs. -> If anyone objects the introduction of automatic linting to Phobos, please raise your voice!
Re: So, to print or not to print?
On 04/26/2016 02:29 PM, TheGag96 wrote: On Tuesday, 26 April 2016 at 14:33:42 UTC, tn wrote: Maybe the name of the function should then be "writes" and/or "writesln" (instead of "print"), so that it can at least be found from the same place in the documentation as other related functions. The naming scheme would then also be consistent with the rest of the write/writef-family. (Here -s stands for "separated/spaced" just as -f stands for "formatted" etc.) I really like this idea. Much better than just "print", and maybe even better than "dump". Can't it be confused with a verb? -- Andrei
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 14:33:42 UTC, tn wrote: Maybe the name of the function should then be "writes" and/or "writesln" (instead of "print"), so that it can at least be found from the same place in the documentation as other related functions. The naming scheme would then also be consistent with the rest of the write/writef-family. (Here -s stands for "separated/spaced" just as -f stands for "formatted" etc.) I really like this idea. Much better than just "print", and maybe even better than "dump".
Re: Some questions on latest work
On Tuesday, 26 April 2016 at 13:55:23 UTC, ag0aep6g wrote: On 26.04.2016 10:20, Suliman wrote: Do you really think that modern language should like this? I talked with a lot of rust fun-boys. Most of them do not understand do not understand the code of their favourite language. Rust will die when Mozilla will move to WebKit. I much more believe in Swift success, that that Rust have any future. Please don't bash on other languages, especially when they're perceived as competition. It reflects badly on the D community. He gave very specific criticism, along with a code sample, then made a prediction, followed by suggesting another competing language that might do better. None of that is the usual content-free fanboy "bashing." There is nothing wrong with occasional criticism of the competition, as long as we don't overdo it, either in frequency or by exaggerating.
[Issue 15958] Missing extern(Windows) of core.sys.windows functions
https://issues.dlang.org/show_bug.cgi?id=15958 --- Comment #2 from github-bugzi...@puremagic.com --- Commit pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7d84c696f208ae562e769e0321ace8688a0131bd Merge pull request #1550 from qchikara/pr-winapi-linkage Fix Issue 15958 - Missing extern(Windows) of core.sys.windows functions --
Re: Checking if an Integer is an Exact Binary Power
On Tuesday, 26 April 2016 at 08:12:02 UTC, Dominikus Dittes Scherkl wrote: On Monday, 25 April 2016 at 22:42:38 UTC, deadalnix wrote: x & -x is the smallest power of 2 that divides x. Basically, if x = 1000 , x & -x = 1000 . This is easy to proves considering -x = ~x + 1 . Now, x >> 1 will be of the form 0100 . If one of these digit is one, then (x >> 1) >= (x & -x) . If they are all zeros, (x >> 1) < (x & -x) which is the case where you have a power of 2. 0 is a special case, can it can be checked that the function return false for this specific input. This looks like it is correct. Yes. Except for the case 0x8000 (= int.min), because this is negative so NOT smaller than 0x4000 (= int.min>>>1), which is considered positive. So the algorithm doesn't work for signed integers (without extra cast). You got to explain me how you end up with a negative number by multiplying 2 by 2 a bunch of time.
String lambdas
https://github.com/dlang/phobos/pull/3882 I just closed with some regret a nice piece of engineering. Please comment if you think string lambdas have a lot of unexploited potential. One thing we really need in order to 100% replace string lambdas with lambdas is function equivalence. Right now we're in the odd situation that SomeTemplate!((a, b) => a < b) has distinct types, one per instantiation. Andrei
Re: Directions to Ibis Hotel in Berlin from Tegel Airport
Am Tue, 26 Apr 2016 12:25:41 + schrieb Kagamin: > On Monday, 25 April 2016 at 09:16:11 UTC, Iain Buclaw wrote: > > Germany is a cash-in-hand country. Credit cards are rejected > > in most places that I've tried. > > You mean debit cards are accepted? Anyway why credit cards? > Aren't credit money more expensive than debit? The overdraft > limit is just a fixed offset from zero and you pay extra > interest, one could just imagine zero balance at his preferred > offset and keep it there. The girocard (sometimes called EC card) debit card system is accepted at most places: https://en.wikipedia.org/wiki/Girocard IIRC you need a german bank account though to own such a card ;-)
Re: Lazy Generation of Random Sequence
On Tuesday, 26 April 2016 at 17:38:33 UTC, Nordlöw wrote: On Tuesday, 26 April 2016 at 11:09:42 UTC, Seb wrote: Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGen So should I pass it by ref or const ref then? I guess both work fine, but this was just a warning for other case. The example that @WebDrake mentioned on his slides can happen too easily - a reason why we should fix it (which is on my agenda).
Re: Lazy Generation of Random Sequence
On Tuesday, 26 April 2016 at 11:09:42 UTC, Seb wrote: Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGen So should I pass it by ref or const ref then?
Re: Lazy Generation of Random Sequence
On Tuesday, 26 April 2016 at 17:38:33 UTC, Nordlöw wrote: On Tuesday, 26 April 2016 at 11:09:42 UTC, Seb wrote: Btw if you do random generation at the moment, you should always be aware that it's super-easy to do an implicit copy if you pass around the rndGen So should I pass it by ref or const ref then? Doh. Const ref is of no use... just by ref then, right?
Re: Checking if an Integer is an Exact Binary Power
On Tuesday, 26 April 2016 at 16:53:00 UTC, tsbockman wrote: On Tuesday, 26 April 2016 at 14:37:46 UTC, Marco Leise wrote: Can we just use __traits(hasTargetFeature, "popcnt") already and get rid of _popcnt? No, because DMD does not currently support setting SSE4 as the minimum target. Thus, `__traits(hasTargetFeature, "popcnt")` must always return `false` at compile time. As for LDC and GDC - both already treat `popcnt()` as an intrinsic, and don't need your proposed change. It's strange why it emits an branch. http://goo.gl/jJbSYd Det version doesn't use cmp and should be fast.
Re: Checking if an Integer is an Exact Binary Power
On Tuesday, 26 April 2016 at 14:37:46 UTC, Marco Leise wrote: Can we just use __traits(hasTargetFeature, "popcnt") already and get rid of _popcnt? No, because DMD does not currently support setting SSE4 as the minimum target. Thus, `__traits(hasTargetFeature, "popcnt")` must always return `false` at compile time. As for LDC and GDC - both already treat `popcnt()` as an intrinsic, and don't need your proposed change.
Re: Minecraft written in D - on Android
On Tuesday, 26 April 2016 at 14:25:05 UTC, Benjamin Thaut wrote: On Tuesday, 26 April 2016 at 08:42:21 UTC, Vadim Lopatin wrote: Demo of DlangUI Scene3D engine - Minecraft-like voxel rendering - is available for Android/ARM. Post screenshots please. Screenshot from my android device: http://imgur.com/gallery/7wVBk8E
Re: Minecraft written in D - on Android
On Tuesday, 26 April 2016 at 14:05:19 UTC, WebFreak001 wrote: On my android device it says "Failed to parse package" Also where is the source at so I can run dub manually? Dub build is available only for desktop. For Android, clone repository git clone --recursive https://github.com/buggins/dlangui.git Go to dlangui/examples/dminer/android_project Edit paths in file android_build_config.mk export DLANGUI_DIR=$HOME/src/d/dlangui export NDK=$HOME/android-ndk-r11c export SDK=$HOME/android-sdk-linux export LDC=$HOME/ldc2-android-arm-0.17.0-alpha2-linux-x86_64 export NDK_ARCH=x86_64 export JAVA_HOME=/usr/lib/jvm/java-8-oracle/ To build package, you will need Android NDK, SDK, LDC2 for android. In Android SDK manager, download platform android-19 (Android 4.4.X) Build is tested only on Linux X64. More build instructions: https://github.com/buggins/dlangui/blob/master/examples/dminer/android_project/README.md
Re: So, to print or not to print?
On Tuesday, April 26, 2016 12:18:11 cym13 via Digitalmars-d wrote: > Finally it doesn't bring much. One learns writeln, laments a bit > that it doesn't put spaces itself then just accepts it. I confess that I was very surprised to find out that writeln worked with multiple arguments. I fully expected writeln to just print what you give it followed by a newline, whereas writefln would take a format string and act like printf except for how %s works with everything, and it adds a newline. I never would have expected any kind of print function that would print multiple arguments without a format string. - Jonathan M Davis
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 15:55:54 UTC, Andrei Alexandrescu wrote: Deja vu all over again. Where's the exchange where that argument got destroyed? -- Andrei Your attempt at destruction bounced off the thick armor of my superior argument! Here's your comment from the other thread: https://github.com/dlang/phobos/pull/3971#issuecomment-183368836 "The way I see it is their charters are different, one is not better or worse than the other." You can say exactly the same thing about substr and substring - their charters are different, one works by index and one by length! The question is: which one is which? Why is it print that adds spaces instead of write? Why is print not to printf what write is to writef? It is just too similar. BTW ruby and php have print functions. Neither output spaces...
Re: Simple and effective approaches to constraint error messages
On Tuesday, 26 April 2016 at 15:56:55 UTC, Andrei Alexandrescu wrote: On 04/26/2016 11:35 AM, Meta wrote: The nice part about 1 is that every constraint gets it for free. Only if in CNF, otherwise needs changed. -- Andrei True, but I bet the majority of template constraints are in this form. The wiki page you linked also says that clauses that are not in CNF can be rewritten in CNF, but doing that automatically in the compiler would probably be difficult, bug-ridden, and annoying for end users. Are you familiar with Nim's implementation of concepts? I think somebody actually implemented something close to this in D using inheritance and introspection. http://nim-lang.org/docs/manual.html#generics-concepts
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 14:33:42 UTC, tn wrote: On Tuesday, 26 April 2016 at 12:52:13 UTC, Andrei Alexandrescu wrote: On 04/26/2016 08:18 AM, cym13 wrote: [...] "When you want spaces between arguments and when you don't". We've been over this. Nobody asks when they should use writef over writeln or readf over readln (which also share a common role with common features). Maybe the name of the function should then be "writes" and/or "writesln" (instead of "print"), so that it can at least be found from the same place in the documentation as other related functions. The naming scheme would then also be consistent with the rest of the write/writef-family. (Here -s stands for "separated/spaced" just as -f stands for "formatted" etc.) I like the `writes` idea! Could be a good compromise ;-)
Re: So, to print or not to print?
On 04/26/2016 09:50 AM, cym13 wrote: On Tuesday, 26 April 2016 at 12:46:09 UTC, Andrei Alexandrescu wrote: On 04/26/2016 04:50 AM, ixid wrote: Please find an example of a newcomer who would be confused by print. This is an objectionable argument because none of the people making it are newcomers, you're using an entirely theoretical newcomer as your argument, and seem to think 'print(a, b, c);' is going to confuse people more than 'writefln("%s %s %s", a, b, c);' which is ridiculous. Let me also add that the very request came from a former newcomer. -- Andrei Well except maybe for you and Walter I think we're all former newcomers. Good point but you know I mean "recently former" :o). -- Andrei
Re: So, to print or not to print?
On 04/26/2016 09:56 AM, Adam D. Ruppe wrote: On Tuesday, 26 April 2016 at 12:52:13 UTC, Andrei Alexandrescu wrote: "When you want spaces between arguments and when you don't". As I have said before, other languages have tried this kind of thing... and they aren't remembered well for it. substr vs substring in javascript is the first big example. Similar name, subtle difference. Deja vu all over again. Where's the exchange where that argument got destroyed? -- Andrei
Re: Simple and effective approaches to constraint error messages
On 04/26/2016 11:35 AM, Meta wrote: The nice part about 1 is that every constraint gets it for free. Only if in CNF, otherwise needs changed. -- Andrei
Re: Compare lambda expressions
There's no way to do this in D. There have been several proposals but nothing implemented as of yet.
Re: So, to print or not to print?
On Monday, 25 April 2016 at 19:35:04 UTC, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/3971 Walter and I were talking this morning that there should be a high barrier of entry for one-liners in Phobos. The "print" function is technically a one-liner (i.e. writefln with the appropriate format string). On the other hand, it may be convivial enough to warrant inclusion, and saves us from embarrassing things such as producing meaningless output when numbers are printed together. There's been a bit of churn in the PR comments regarding the utility of "print", and discussion diverged into other functions such as "dump" etc. Keeping it on topic: any strong cons and pros regarding the function? I want to either merge or close the PR and move on. Thanks, Andrei Python users are only a subset of new users coming to D, and as far as I know it is the only big language where such a `print` primitive exists with the semantics of putting spaces between each item printed. Ruby also has `print` but it does not put spaces between arguments; it adds a newline after each argument. So which behaviour should we copy? None of the other big languages, C, C++, Javascript, Java, C#, Scala, Groovy, et al., have a `print` function that matches the semantics of Python's print (nor Ruby's). Why add yet another IO function that will only help very inexperienced beginners coming from a single (popular, granted) language? I'm all for making the D experience easy for beginners, but this is not a low-hanging fruit. It's just rotten.
Re: Simple and effective approaches to constraint error messages
On Monday, 25 April 2016 at 17:52:58 UTC, Andrei Alexandrescu wrote: Idea #2: Allow custom error messages The basic idea here is to define pragma(err, "message") as an expression that formats "message" as an error and returns false. Then we can write: R find(R, E)(R range, E elem) if ((isInputRange!R || pragma(err, R.stringof~" must be an input range") && (is(typeof(range == elem) == bool) || pragma(err, "...")) Now, when printing the failed candidate, the compiler adds the error message(s) produced by the failing constraint. The problem with this is verbosity - e.g. we almost always want to write the same message when isInputRange fails, so naturally we'd like to encapsulate the message within isInputRange. This could go as follows. Currently: template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if (r.empty) {} // can test for empty r.popFront(); // can invoke popFront() auto h = r.front; // can get the front of the range })); } Envisioned (simplified): template lval(T) { static @property ref T lval() { static T r = T.init; return r; } } template isInputRange(R) { enum bool isInputRange = (is(typeof({if(lval!R.empty) {}}) || pragma(err, "cannot test for empty")) && (is(typeof(lval!R.popFront()) || pragma(err, "cannot invoke popFront") (is(typeof({ return lval!R.front; })) || pragma(err, can get the front of the range)); } Then the way it goes, the compiler collects the concatenation of pragma(msg, "xxx") during the invocation of isInputRange!R and prints it if it fails as part of a constraint. Further simplifications should be possible, e.g. make is() support an error string etc. The problem here is that *every* constraint must be modified, which will a long and tedious process. The nice part about 1 is that every constraint gets it for free. Applying it recursively would provide a nice "stack trace" of constraint failure so the user can see exactly what went wrong and where. The problem then becomes the verbosity of errors, but we already have ways of dealing with that such as the -v switch.
Re: Garbage Collector : Ignoring a reference
Am Tue, 26 Apr 2016 13:35:37 + schrieb Begah: > When the screen switches to another screen ie from menu to the > game, > I want that the "button.png" texture is automaticly destroyed by > the gc. My ideological point of view is that you must not use non-deterministic garbage collection for resources. Neither for files, GUI widgets or textures. The garbage collector cannot look past its own confined environment (heap memory allocated by the D program and loaded D libraries) and will not have enough information to tell if the process is running out of file handles, backing buffer for widgets or texture memory on the graphics card. It only takes action, when its own heap is filling up or when you manually call GC.collect(). All the convenient 100% GC languages from Java to Python require the user to call ".close()" for files, ".dispose()/.Destroy()" for widgets, etc. Reference counting is the correct approach. It makes using external resources safe and convenient by removing the need for manual lifetime management. Cyclic references cannot exist in the D code in this scenario. The texture constructor: - sets ref count to 1 - adds texture to hash map The copy constructor: - increments the ref count The destructor: - decrements the ref count - if ref count reaches 0: - removes the texture from the hash table - destroys the texture data -- Marco
Re: Checking if an Integer is an Exact Binary Power
On Monday, 25 April 2016 at 15:35:14 UTC, Dominikus Dittes Scherkl wrote: On Monday, 25 April 2016 at 15:27:02 UTC, Xinok wrote: Brute force. http://dpaste.dzfl.pl/882d7cdc5f74 Yeah. And your test spares the failed case int.min (0x8000), because in this case x & -x is negative, but of cause x>>>1 is positive, so it returns false despite -(2^^31) is in fact a power of two. So this requires an extra cast to work correct (in fact no big difference in the assembly): return (Unsigned!T)(x & -x) > (Unsigned!T)(x >>> 1); How is it wrong? Negative numbers are NOT powers of two (unless you have an imaginary/complex exponent), so it's still correct to return false for -int.min. Should it not? http://www.wolframalpha.com/input/?i=solve+2^n+%3D+-%282^31%29+for+n
Re: Live streaming of DConf 2016: confirmed
On Tuesday, 26 April 2016 at 14:44:42 UTC, Dicebot wrote: For high quality recordings publishes later shouldn't be a problem. Very good!
[Issue 15860] lockstep should support foreach_reverse
https://issues.dlang.org/show_bug.cgi?id=15860 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/154b0e9cb8f9b0d93a59faf913006a4b66862bc9 Fix Issue 15860 - lockstep should support foreach_reverse https://github.com/dlang/phobos/commit/23fcb244efbb545485fb5fd8635144340e4193d3 Merge pull request #4138 from Biotronic/fix-15860 Fix Issue 15860 - lockstep should support foreach_reverse --
[Issue 15860] lockstep should support foreach_reverse
https://issues.dlang.org/show_bug.cgi?id=15860 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
Re: Live streaming of DConf 2016: confirmed
On Tuesday, 26 April 2016 at 14:01:56 UTC, Dmitry wrote: On Thursday, 21 April 2016 at 17:24:43 UTC, Dicebot wrote: Have just got a confirmation that there will both live stream and high quality recording for later publishing during DConf 2016 @ Berlin - not being able to attend is not a reason to not participate! ;) Any chance for subtitles? For live stream - don't think so. For high quality recordings publishes later shouldn't be a problem.
Re: Minecraft written in D - on Android
On Tuesday, 26 April 2016 at 08:42:21 UTC, Vadim Lopatin wrote: Demo of DlangUI Scene3D engine - Minecraft-like voxel rendering - is available for Android/ARM. Post screenshots please.
Re: Checking if an Integer is an Exact Binary Power
Am Mon, 25 Apr 2016 17:04:43 + schrieb tsbockman: > On Monday, 25 April 2016 at 16:48:14 UTC, Lass Safin wrote: > > Example; > > > > import core.bitop; > > import core.cpuid; > > > > int count; > > if(hasPopcnt) > > count = _popcnt; // Uses x86-instruction "popcnt". > > else > > count = popcnt; // Phobos's software implementation. > > > > // Do stuff with count > > That is not right (since 2.069, I think?). Adding that check just > makes things slower and more complicated: > > core.bitop.popcnt() itself already checks hasPopcnt, and forwards > to the intrinsic if it is available. Can we just use __traits(hasTargetFeature, "popcnt") already and get rid of _popcnt? -- Marco
Compare lambda expressions
Hi all! Not sure, if this belongs directly to the D language, or it is rather maths, but: given to delegate generating functions and a main auto func1(int arg) { bool delegate(int x) dg; dg = (x) => arg * x; return dg; } auto func2(int arg) { bool delegate(int x) dg; dg = (x) => arg * x * x / x; return dg; } void main() { auto dgf1 = func1(4); writeln(dgf1(2)); auto dgf2 = func2(4); writeln(dgf2(2)); writeln(dgf1 == dgf2); } the last line gives false, either in this form, as well with .ptr, as well with .funcptr. The question is, how to say, whether two lambda expressions are the same? What if the lambda expressions are predicates? This case would be more important for me... I understand, that there is only a little hope to get answer other then "impossible", even for the constrained case. In such a case, I have another opportunity: Say, I define two lambda functions as strings in, say a json file. I'm going to parse them and build functions out of them. How to force the input in a unified manner? In such a case, I could compare the given strings with some weird regular expression... So, the question for this case is: Is there some normalized form of writing a lambda expression? Any literature would be more then sufficient as an answer... Many thanks in advance :)
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 12:52:13 UTC, Andrei Alexandrescu wrote: On 04/26/2016 08:18 AM, cym13 wrote: The first questions I expect are "when should I use print and when use writeln?" for they share a common role with common features. "When you want spaces between arguments and when you don't". We've been over this. Nobody asks when they should use writef over writeln or readf over readln (which also share a common role with common features). Maybe the name of the function should then be "writes" and/or "writesln" (instead of "print"), so that it can at least be found from the same place in the documentation as other related functions. The naming scheme would then also be consistent with the rest of the write/writef-family. (Here -s stands for "separated/spaced" just as -f stands for "formatted" etc.)
Re: Minecraft written in D - on Android
On Tuesday, 26 April 2016 at 08:42:21 UTC, Vadim Lopatin wrote: Hello, Demo of DlangUI Scene3D engine - Minecraft-like voxel rendering - is available for Android/ARM. Download DlangUIMinecraftDemo.apk from https://sourceforge.net/projects/crengine/files/DlangUI/ Image is a bit corrupted with some artifacts. On desktop it works better: `dub run dlangui:dminer` Another demo of DlangUI 3d engine: `dub run dlangui:d3d` DlangUI/Scene3d is simple 3D engine. Supports, cameras, lights, meshes, hierarchy of nodes, transforms, models, meshes, materials, shaders. For now, only OBJ 3d model import is implemented. No physics engine integrated so far. Best regards, Vadim On my android device it says "Failed to parse package" Also where is the source at so I can run dub manually?
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 12:52:13 UTC, Andrei Alexandrescu wrote: On 04/26/2016 08:18 AM, cym13 wrote: The first questions I expect are "when should I use print and when use writeln?" for they share a common role with common features. "When you want spaces between arguments and when you don't". We've been over this. Nobody asks when they should use writef over writeln or readf over readln (which also share a common role with common features). What precedent do you have of people getting confused like that? Andrei Well, just the post above your own there's a case of someone who didn't expect the separation. I think it makes my point.
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 12:52:13 UTC, Andrei Alexandrescu wrote: "When you want spaces between arguments and when you don't". As I have said before, other languages have tried this kind of thing... and they aren't remembered well for it. substr vs substring in javascript is the first big example. Similar name, subtle difference.
Re: Some questions on latest work
On 26.04.2016 10:20, Suliman wrote: Do you really think that modern language should like this? I talked with a lot of rust fun-boys. Most of them do not understand do not understand the code of their favourite language. Rust will die when Mozilla will move to WebKit. I much more believe in Swift success, that that Rust have any future. Please don't bash on other languages, especially when they're perceived as competition. It reflects badly on the D community.
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 12:46:09 UTC, Andrei Alexandrescu wrote: On 04/26/2016 04:50 AM, ixid wrote: Please find an example of a newcomer who would be confused by print. This is an objectionable argument because none of the people making it are newcomers, you're using an entirely theoretical newcomer as your argument, and seem to think 'print(a, b, c);' is going to confuse people more than 'writefln("%s %s %s", a, b, c);' which is ridiculous. Let me also add that the very request came from a former newcomer. -- Andrei Well except maybe for you and Walter I think we're all former newcomers.
Re: Garbage Collector : Ignoring a reference
Thus, i need a way to tell the gc to ignore the reference ( or something similar ) in that hashmap. So, having pointer that doesn't hold a reference isn't that hard (store it in memory region that is unreachable to gc), but don't you need a way to tell if that pointer ins't dangling, beyond initial problem?
Re: So, to print or not to print?
On Tuesday, 26 April 2016 at 12:46:48 UTC, Seb wrote: the separation between std.stdio and std.file. At least I expected that I can use `writeln` on files :/ You can... auto file = File("name.txt", "wt"); file.writeln("hey"); As mentioned on github I would love to see a proper dump function and this would be quite useful for newcomers. Yeah, dump has serious value, I'd support it.
Re: Some questions on latest work
On Tuesday, 26 April 2016 at 04:37:03 UTC, deadalnix wrote: On 32 bits, nothing fundamental changed, but the compiler got a bit smarter about alocating with the no scan flag, so that's better. Indeed, though any large array is liable to be pinned by a false pointer on 32 bit, even with no_scan. I actually recommend malloc/free large arrays with easy lifetimes on 32 bit just to avoid those accidental leaks. 64 bit is fine though. I don't know for that one, but if that doesn't work with classes, this is indeed a problem worth solving. I think it kinda works now but not very well because the ref countedness gets lost in inheritance. If it implements two interfaces for example, it cannot properly express that implicit conversion. Usable though AFAIK, just clunky.
[Issue 15958] Missing extern(Windows) of core.sys.windows functions
https://issues.dlang.org/show_bug.cgi?id=15958 j...@red.email.ne.jp changed: What|Removed |Added Keywords||pull --- Comment #1 from j...@red.email.ne.jp --- https://github.com/dlang/druntime/pull/1550 --
Re: Garbage Collector : Ignoring a reference
On 26.04.2016 15:35, Begah wrote: Nothing will reload. An example : I load a texture "button.png" in a class and draw it to the screen, When the screen switches to another screen ie from menu to the game, I want that the "button.png" texture is automaticly destroyed by the gc. But this will never happen because i still have a reference to it in my hashmap. Thus, i need a way to tell the gc to ignore the reference ( or something similar ) in that hashmap. How would you prevent reads of that now-invalid element of the hashmap?
Re: Garbage Collector : Ignoring a reference
On Tuesday, 26 April 2016 at 13:01:26 UTC, ciechowoj wrote: On Tuesday, 26 April 2016 at 09:07:59 UTC, Begah wrote: How could i tell the garbage collector to ignore the reference in the hashmap and to free it if there isn't any other reference that in my hashmap? You could always zero the reference in the hashmap, as it won't be valid after reload anyway... Nothing will reload. An example : I load a texture "button.png" in a class and draw it to the screen, When the screen switches to another screen ie from menu to the game, I want that the "button.png" texture is automaticly destroyed by the gc. But this will never happen because i still have a reference to it in my hashmap. Thus, i need a way to tell the gc to ignore the reference ( or something similar ) in that hashmap.
Re: Changelog entries as folder or in wiki
On 21.04.2016 01:51, Seb wrote: It would be great if we had a better, painless way to handle the changelog - two simple ideas: 1) Use a changelog folder instead of file After having rebased a pull request for the third time just because of changelog.dd: Sounds good to me.
Re: Checking if an Integer is an Exact Binary Power
On Tuesday, 26 April 2016 at 08:12:02 UTC, Dominikus Dittes Scherkl wrote: On Monday, 25 April 2016 at 22:42:38 UTC, deadalnix wrote: x & -x is the smallest power of 2 that divides x. Basically, if x = 1000 , x & -x = 1000 . This is easy to proves considering -x = ~x + 1 . Now, x >> 1 will be of the form 0100 . If one of these digit is one, then (x >> 1) >= (x & -x) . If they are all zeros, (x >> 1) < (x & -x) which is the case where you have a power of 2. 0 is a special case, can it can be checked that the function return false for this specific input. This looks like it is correct. Yes. Except for the case 0x8000 (= int.min), because this is negative so NOT smaller than 0x4000 (= int.min>>>1), which is considered positive. So the algorithm doesn't work for signed integers (without extra cast). Well, it depends a bit on how you define "is a power of two": If you define "x is a power of 2" as "there is a natural number n, so that x == 2*2*...*2 (n-times)" with * defined as multiplication in the ring of integers modulo 2^32 (i.e. int or uint), then int.min and 0 are powers of two because the multiplication overflows. If you define "x is a power of 2" as above but based on the multiplication in the ring of integers, then int.min (== -2^31) and 0 are not powers of two.
Re: So, to print or not to print?
On 04/26/2016 08:46 AM, Seb wrote: I can out myself as a newcomer (since February) and a lot of stuff in D is pretty confusing. For example - a bit related - the separation between std.stdio and std.file. At least I expected that I can use `writeln` on files :/ Thanks for your insight! Could someone insert an explanation at the top of both std.file and std.stdio, built from the following point: Artifacts in std.stdio treat files as complex data repositories that are opened, read from and/or written to, and closed. Artifacts in std.file treat a file as a unit, much like shell programs do. With std.file read/write operations are done at the level of the entire file at once, and details of opening and closing are implicit. Honestly, I see no value whatsoever in print. writefln already does the same job and in a clearer manner. Or `writeln(chain(a, b, c).join(','))`. That's just a terrible argument, sorry. The whole point here is to not necessitate introducing too many language and library artifacts in order to print something. Andrei
Re: Simple and effective approaches to constraint error messages
On Monday, 25 April 2016 at 17:52:58 UTC, Andrei Alexandrescu wrote: It's been long asked in our community that failing template constraints issue better error messages. Consider: [...] I still prefer static inheritance. Having said that, I like the pragma(err) thing in the template constraint. Atila
Re: Garbage Collector : Ignoring a reference
On Tuesday, 26 April 2016 at 09:07:59 UTC, Begah wrote: How could i tell the garbage collector to ignore the reference in the hashmap and to free it if there isn't any other reference that in my hashmap? You could always zero the reference in the hashmap, as it won't be valid after reload anyway...