Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 02:28:21 UTC, Manu wrote: On 19 March 2018 at 17:17, Mike Franklin via Digitalmars-dwrote: On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: Digging out and old yet important issue. https://issues.dlang.org/show_bug.cgi?id=5710 +1 Oh oh, https://issues.dlang.org/show_bug.cgi?id=5227 !! Have you seen https://github.com/dlang/phobos/pull/6272 ?
Re: #dbugfix Issue 5710
On 19 March 2018 at 20:53, Mike Franklin via Digitalmars-dwrote: > On Tuesday, 20 March 2018 at 02:28:21 UTC, Manu wrote: >> >> On 19 March 2018 at 17:17, Mike Franklin via Digitalmars-d >> wrote: >>> >>> On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: Digging out and old yet important issue. >>> >>> >>> >>> https://issues.dlang.org/show_bug.cgi?id=5710 >>> >>> +1 >> >> >> Oh oh, https://issues.dlang.org/show_bug.cgi?id=5227 !! > > > Submit a #dbugfix 5227 to the General Forum to make sure this gets counted. I posted it on twitter... I was the first one ;)
Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 03:55:24 UTC, Mike Franklin wrote: On Tuesday, 20 March 2018 at 02:45:34 UTC, Jonathan M Davis wrote: IMHO, it would be _huge_ if this issue could be fixed. Mike Parker, I think that means +1. Yeah, got it :-) Also counted the other one. Thanks!
Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 02:45:34 UTC, Jonathan M Davis wrote: IMHO, it would be _huge_ if this issue could be fixed. Mike Parker, I think that means +1.
Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 02:28:21 UTC, Manu wrote: On 19 March 2018 at 17:17, Mike Franklin via Digitalmars-dwrote: On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: Digging out and old yet important issue. https://issues.dlang.org/show_bug.cgi?id=5710 +1 Oh oh, https://issues.dlang.org/show_bug.cgi?id=5227 !! Submit a #dbugfix 5227 to the General Forum to make sure this gets counted. For more information see https://dlang.org/blog/2018/02/03/the-dbugfix-campaign/ Mike
Re: #dbugfix Issue 5710
On Tuesday, March 20, 2018 00:00:22 ciechowoj via Digitalmars-d wrote: > Digging out and old yet important issue. IMHO, it would be _huge_ if this issue could be fixed. The whole issue with "multiple context pointers" can get really annoying, and it can't always be reasonably worked around. However, I don't recall anyone ever coming up with even a theoretical solution for the problem. So, I have no idea what it's going to take to fix it, and I don't have high hopes that it will be. But maybe we'll get lucky, and someone will get an epiphany or divine inspiration or whatnot, and we'll finally get a fix. Hope springs eternal... - Jonathan M Davis
Re: DConf 2018 Munich Registration is Open!
On Monday, 19 March 2018 at 13:34:36 UTC, Mike Parker wrote: The D Language Foundation is thrilled to announce that registration for DConf 2018, May 2-5 in Munich, is now open. [...] Proggit link, in case you simply forgot to post it here: https://www.reddit.com/r/programming/comments/85jijd/dconf_d_language_conference_2018_munich/
Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: Digging out and old yet important issue. Noted!
Re: #dbugfix Issue 5710
On 19 March 2018 at 17:17, Mike Franklin via Digitalmars-dwrote: > On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: >> >> Digging out and old yet important issue. > > > https://issues.dlang.org/show_bug.cgi?id=5710 > > +1 Oh oh, https://issues.dlang.org/show_bug.cgi?id=5227 !!
[Issue 18504] Assert in synchronized crashes with SIGILL on exit
https://issues.dlang.org/show_bug.cgi?id=18504 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #2 from Walter Bright --- https://github.com/dlang/dmd/pull/8027 --
Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: Digging out and old yet important issue. https://issues.dlang.org/show_bug.cgi?id=5710 +1
Re: #dbugfix Issue 5710
On Tuesday, 20 March 2018 at 00:00:22 UTC, ciechowoj wrote: Digging out and old yet important issue. That's one of those bugs that even if a solution gets implemented, it won't get accepted and pulled in. Soweone up top needs to figure out how they want it to be implemented in an acceptable manor first. From the looks of the issue comments, and how long the issue has been open. Seems like there's no solution that's deemed acceptable enough by said individuals to be implemented.
#dbugfix Issue 5710
Digging out and old yet important issue.
Re: DConf 2018 Munich Registration is Open!
On Monday, 19 March 2018 at 14:28:59 UTC, Andrei Alexandrescu wrote: The D Language Foundation is thrilled to announce that registration for DConf 2018, May 2-5 in Munich, is now open. [...] The page on the talk by Igor Česi has a stray $(P
[Issue 18636] New: Make the ddox instant search available for ddoc
https://issues.dlang.org/show_bug.cgi?id=18636 Issue ID: 18636 Summary: Make the ddox instant search available for ddoc Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: greensunn...@gmail.com this is an common request from the "State of D" survey. Sometimes the Rust instant search was a good example. The main difference here is that the entire page is used for listing the results. --
[Issue 18635] New: Show list of transition features on dlang.org and the man page
https://issues.dlang.org/show_bug.cgi?id=18635 Issue ID: 18635 Summary: Show list of transition features on dlang.org and the man page Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: greensunn...@gmail.com This file generates the compiler switches: https://github.com/dlang/dlang.org/blob/master/ddoc/source/preprocessor.d --
Re: Testing D database calls code for regression
On Friday, 16 March 2018 at 20:17:49 UTC, aberba wrote: How will you test D code which makes calls to database to detect bugs and regression. Unlike where you can inject data like assert (2+1 == 3), database interfacing code will be crazy... Or there's some mocking available for such cases. Especially when more features are developed on top. Well, I am not really sure what you are looking for but to test database code, there are frameworks for this Check for example tsqlt ( http://tsqlt.org/ ) this framework is ms sql specific and is the one I have experience with There is also dbfit ( http://dbfit.github.io/dbfit/ ) which seem to support more database management frameworks tsqlt is very good for unit testing, sql procedures or statements at a high this is how it was setup to be used 1. you prepare sql procedure to create your tables that will be used in testing 2. you prepare sql procedure with insert statements to create the data sample you want to be used for testing 3. you write a script execute the two procedures from the first two step then executed the procedure or statement you want to test and then at the end of this script executed some assert statements that is basically your unit test how to setup used those scripts 1. the setup started a transaction 2. the setup dropped everything in the database 3. the setup executed the scripts from point 3 above to create your database, followed by the insert statements scripts or data creation script, followed by executing the statement to be tested and finally executing the assert statements 4. finally the setup rolled back everything this setup was support by the tsqlt framework, but honestly i dont know how much of this was specific to the environment where i worked but you can use tsqlt to have this D is not a database language, D is not sql You should clearly separate testing the D code that call the sql statements and testing the sql statements themselves The above frameworks, will help you test the sql code in isolation
[Issue 18634] std.container.rbtree does not work with delegate comparators
https://issues.dlang.org/show_bug.cgi?id=18634 Sebchanged: What|Removed |Added CC||greensunn...@gmail.com --- Comment #1 from Seb --- PR https://github.com/dlang/phobos/pull/6304 (it's a good practice to mention/link the PR to avoid duplicate work) --
[Issue 18634] std.container.rbtree does not work with delegate comparators
https://issues.dlang.org/show_bug.cgi?id=18634 viktor.iva...@gmail.com changed: What|Removed |Added Priority|P1 |P5 Summary|RBTree does not work with |std.container.rbtree does |delegate comparators|not work with delegate ||comparators --
[Issue 18634] New: RBTree does not work with delegate comparators
https://issues.dlang.org/show_bug.cgi?id=18634 Issue ID: 18634 Summary: RBTree does not work with delegate comparators Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: trivial Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: viktor.iva...@gmail.com The RedBlackTree does not work with delegate comparators due to RedBlackTree.opEquals() forcing a function when doing the equality comparison. The following test shows the issue: import std.algorithm.comparison : equal; auto t = new RedBlackTree!(int, delegate (a, b) => a > b); t.insert([1, 3, 5, 4, 2]); assert(t[].equal([5, 4, 3, 2, 1])); --
[Issue 18633] Specify clearly if `typectors ref` is the same as `typector auto ref `
https://issues.dlang.org/show_bug.cgi?id=18633 Jonathan M Davischanged: What|Removed |Added CC||issues.dl...@jmdavisprog.co ||m --- Comment #1 from Jonathan M Davis --- Given that auto ref is supposed to be distinct from auto, I would expect it to be a compiler bug if ref with anything other than auto were treated the same as auto ref. auto by itself is supposed to be a placeholder to indicate that a variable is being declared, and is unnecessary when another attribute or identifier clearly indicates that a variable is being declared, and that has nothing to with auto ref. But I have no idea how clear the spec is on that. --
[Issue 18632] enable use of fromStringz with char[n]
https://issues.dlang.org/show_bug.cgi?id=18632 Jonathan M Davischanged: What|Removed |Added CC||issues.dl...@jmdavisprog.co ||m --- Comment #1 from Jonathan M Davis --- (In reply to elpenguino+D from comment #0) > This would possibly also have the benefit of being @safe and pure. Without -dip1000, treating the result as @safe would be a huge mistake, because slicing a static array like this is inherently unsafe. The fact that the compiler does not treat slicing static arrays as @system without -dip1000 and scope is a bug (and it's in bugzilla somewhere, but I don't feel like searching for it at the moment). And on that note, the function would have to accept the static array by ref, or it would have a huge @safety bug. --
[Issue 18633] New: Specify clearly if `typectors ref` is the same as `typector auto ref `
https://issues.dlang.org/show_bug.cgi?id=18633 Issue ID: 18633 Summary: Specify clearly if `typectors ref` is the same as `typector auto ref ` Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: b2.t...@gmx.com the compiler accepts `auto ref inout(ElementType!Range) choice(Range, RandomGen = Random)(inout ref Range range, ref RandomGen urng){...}` While a more correct form is `auto ref inout(ElementType!Range) choice(Range, RandomGen = Random)(inout auto ref Range range, ref RandomGen urng){...}` The specs don't say why and when `auto` can be omitted, they could be more accurate. Problem encountered here: https://github.com/dlang/phobos/pull/6302#discussion_r175561789 --
[Issue 18632] New: enable use of fromStringz with char[n]
https://issues.dlang.org/show_bug.cgi?id=18632 Issue ID: 18632 Summary: enable use of fromStringz with char[n] Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: elpenguin...@gmail.com i.e. ``` char[40] cString; auto someString = cString.fromStringz(); assert((someString.length >= 0) && (someString.length <= 40)); ``` This would behave more like strnlen than strlen, and would be particularly useful when the maximum size of the string is known ahead of time. This would possibly also have the benefit of being @safe and pure. --
Re: Lazy caching map()?
On Monday, 19 March 2018 at 16:47:16 UTC, Graham Fawcett wrote: On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty expensive to compute, return an object `result` such that: [...] Map the sources to std.parallelism.Task instances, and yieldForce() the instances when you need the results? On second thought, that won't work. AFIAK there's no way to take an unscheduled task and force it to execute on the current thread immediately and yield the result. But with such an operation, you could have a thread-local future/promise type that would meet your needs. Graham
Re: CTFE ^^ (pow)
On 19 March 2018 at 13:00, Jacob Carlborg via Digitalmars-dwrote: > On 2018-03-19 01:00, Manu wrote: > >> It's not aggression, it's a decade of compounded frustration. > > > Perhaps you can give this a try: > https://forum.dlang.org/thread/ojxxjixcxnztmssky...@forum.dlang.org Haha. Yeah, mine was the very first response, linking to this exact issue! Just one of the many ways I've tried to resurrect interest in this issue :P
Re: DConf 2018 Munich Registration is Open!
On 2018-03-19 16:42, Graham Fawcett wrote: On Monday, 19 March 2018 at 14:28:59 UTC, Andrei Alexandrescu wrote: The D Language Foundation is thrilled to announce that registration for DConf 2018, May 2-5 in Munich, is now open. Hi Andrei, I think something broke on the dlang.org Web site when the announcement was added. I was on the download page: https://dlang.org/download.html ...and it's currently full of "DConf 2018 Programme & Open Registration" links, and no links to the actual downloads. It's fixed now. -- /Jacob Carlborg
Re: Downloads page
On 2018-03-19 20:52, Tony wrote: The downloads page is a little corrupted: https://dlang.org/download.html It's fixed now. -- /Jacob Carlborg
Re: Testing D database calls code for regression
On Mon, Mar 19, 2018 at 06:45:49PM +, aberba via Digitalmars-d-learn wrote: [...] > The thing about functional programming where functions are > decoupled/testable doesn't seem to apply to database call code. I > guess its because databases introduces a different state...another > point of failure. Not necessarily; in some cases it may be possible to design code such that its logic can be tested independently of an actual database. But that may not be practical in your case since it will likely involve a major rewrite. Basically, it's pretty rare for an application to actually need the full range of the SQL language + *all* of the features your database backend provides. Usually, the "business logic", so to speak, boils down to just some simple primitives: uploadFile(), createAccount(), loginUser(), logoutUser(), deleteAccount(), retrieveFile(), etc.. Ideally, the business logic part of the code should not even care about whether there's a database in the back supporting these operations; it should be higher-level code built on top of these high-level primitives. There should definitely not be any literal SQL statements anywhere at this level. The "business logic" side of the code should be completely testable with a mock API (with stubs for uploadFile, createAccount, etc.), and should not need to touch a real database at all. In the middle level where these primitives are implemented, that's where you actually translate these high-level operations into SQL. If the high-level API is well-designed, each operation should be pretty well encapsulated and should not cause unexpected conflicts with other operations. [...] > My code logic is a mix of file uploads which leads to saving file info > into db. And some general queries... my worry has been adding a > feature which might cause a regression in another rearly executed > code...its feels like I have to test all features/rest calls after > every major change. Don't know how others do this...when there's some > tight coupling involved. [...] Sounds like you're not really doing *unit* testing anymore, but it's a large-scale application-wide regression test. For that, probably your best bet is to create test databases and use external testing with a mock network / test DB server. E.g., basically what the dmd testsuite does today: a directory of input files and expected output files, and some simple tools to automatically run through all of them. You could create a library of test cases that you run your program through before release, to make sure nothing that has worked in the past will stop working now. T -- If it breaks, you get to keep both pieces. -- Software disclaimer notice
Re: CTFE ^^ (pow)
On 2018-03-19 01:00, Manu wrote: It's not aggression, it's a decade of compounded frustration. Perhaps you can give this a try: https://forum.dlang.org/thread/ojxxjixcxnztmssky...@forum.dlang.org -- /Jacob Carlborg
Downloads page
The downloads page is a little corrupted: https://dlang.org/download.html
Re: Does the compiler inline the predicate functions to std.algorithm.sort?
On Monday, 19 March 2018 at 12:45:58 UTC, tipdbmp wrote: the LLVM IR obtained with -output-ll might be easier to read than assembly.) I only seem to get assembly on d.godbolt.org, even with the -output-ll option. On d.godbolt.org, you can get LLVM IR with a trick: use `-output-s=false -output-ll`. -Johan
[Issue 18631] std.random.choice does not work with const arrays
https://issues.dlang.org/show_bug.cgi?id=18631 Basile B.changed: What|Removed |Added Hardware|x86 |All OS|Windows |All Severity|enhancement |normal --
[Issue 18631] New: std.random.choice does not work with const arrays
https://issues.dlang.org/show_bug.cgi?id=18631 Issue ID: 18631 Summary: std.random.choice does not work with const arrays Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: elpenguin...@gmail.com ``` const x = [1,2]; auto y = choice(x); ``` results in ``` /dlang/dmd/linux/bin64/../../src/phobos/std/random.d(2033): Error: template std.random.choice cannot deduce function from argument types !()(const(int[]), MersenneTwisterEngine!(uint, 32LU, 624LU, 397LU, 31LU, 2567483615u, 11LU, 4294967295u, 7LU, 2636928640u, 15LU, 4022730752u, 18LU, 1812433253u)), candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/random.d(2020): std.random.choice(Range, RandomGen = Random)(auto ref Range range, ref RandomGen urng) if (isRandomAccessRange!Range && hasLength!Range && isUniformRNG!RandomGen) /dlang/dmd/linux/bin64/../../src/phobos/std/random.d(2031): std.random.choice(Range)(auto ref Range range) onlineapp.d(5): Error: template instance `std.random.choice!(const(int[]))` error instantiating ``` It appears that the only thing keeping this from working is x not being a range, but the body of the function does not seem to actually require that be true. --
Re: Vision document for H1 2018
On Friday, 9 March 2018 at 21:43:53 UTC, Andrei Alexandrescu wrote: Hello, the vision document of the Founation for the first six months of 2018 is here: https://wiki.dlang.org/Vision/2018H1 In addition to the expected items, we have a new top-level priority - locking down the language definition. This is in recognition of the fact that we need a precise definition of the language going forward. Thanks, Andrei If I compare 2018H1 vision, to 2017H2 vision I see that 3 out of 6 objectives are carry over from 2017 I think this needs more explanation, and maybe the vision document, should becomes more of a road map document A vision by some definitions in management, is the organization dream, it doesn't have to be completely realistic A road map, is more like a plan, that is realistically achievable Again, I think, if 3 out 6 items are from last year, it seems unlikely all 6 will complete this year, and it seems more likely most of those will carry over to next year, and it becomes unclear which of those 6 will actually be implemented this year
Re: This week in D
On Monday, 19 March 2018 at 14:11:24 UTC, Adam D. Ruppe wrote: On Monday, 19 March 2018 at 10:04:15 UTC, bauss wrote: Has it stopped completely or is it just temporary? I want to restart it with a 2.0 thing probably monthly instead of weekly (well I might generate the link list automatically each week, but commit to doing a feature once a month) as part of the dpldocs.info project: have stuff from community projects as well as bugzilla stats and try to get tutorials for it. It will definitely NOT be sunday anymore - that day just doesn't work for me. I'm considering making it a part of the patreon goal so I can even commission stuff but idk yet. But yes, I do intend to get back into it, just not sure on timetable. Sounds great!
Re: Testing D database calls code for regression
On Monday, 19 March 2018 at 00:56:26 UTC, H. S. Teoh wrote: On Sun, Mar 18, 2018 at 07:51:18PM +, aberba via Digitalmars-d-learn wrote: On Friday, 16 March 2018 at 21:15:33 UTC, H. S. Teoh wrote: > On Fri, Mar 16, 2018 at 08:17:49PM +, aberba via > Digitalmars-d-learn wrote: > > [...] > > The usual way I do this is to decouple the code from the > real database backend by templatizing the database driver. > Then in my unittest I can instantiate the template with a > mock database driver that only implements the bare minimum > to run the test. > > [...] Mocking a fake database can also be huge pain. Especially when something like transactions and prepared statements are involved. It depends on what your test is looking for. The idea is that the mock database only implements a (small!) subset of a real database, basically just enough for the test to run, and nothing more. Of course, sometimes it may not be easy to do this, if the code being tested is very complex. Imagine testing your mock for introduced by future extension. If you find yourself needing to test your mock database, then you're doing it wrong. :-D It's supposed to be helping you test your code, not to create more code that itself needs to be tested! Basically, this kind of testing imposes certain requirements on the way you write your code. Certain kinds of code are easier to test than others. For example, imagine trying to test a complex I/O pipeline implemented as nested loops. It's basically impossible to test it except as a blackbox testing (certain input sets must produce certain output sets). It's usually impractical for the test to target specific code paths nested deep inside a nested loop. The only thing you can do is to hope and pray that your blackbox tests cover enough of the code paths to ensure things are correct. But you're likely to miss certain exceptional cases. But if said I/O pipeline is implemented as series of range compositions, for example, then it becomes very easy to test each component of the range composition. Each component is decoupled from the others, so it's easy for the unittest to check all code paths. Then it's much easier to have the confidence that the composed pipeline itself is correct. I/O pipelines are an easy example, but understandably, in real-world code things are rarely that clean. So you'll have to find a way of designing your database code such that it's more easily testable. Otherwise, it's going to be a challenge The thing about functional programming where functions are decoupled/testable doesn't seem to apply to database call code. I guess its because databases introduces a different state...another point of failure. no matter what. No matter what you do, testing a function made of loops nested 5 levels deep is going to be very hard. Similarly, if your database code has very complex interdependencies, then it's going to be hard to test no matter how you try. My code logic is a mix of file uploads which leads to saving file info into db. And some general queries... my worry has been adding a feature which might cause a regression in another rearly executed code...its feels like I have to test all features/rest calls after every major change. Don't know how others do this...when there's some tight coupling involved. Anyway, on the more practical side of things, depending on what your test is trying to do, a mock database could be as simple as: struct MockDb { string prebakedResponse; auto query(string sql) { if (sql == "SELECT * FROM data") return prebakedResponse; else if (sql == "UPDATE * SET ... ") prebakedResponse = ... else assert(0, "Time to rewrite your unittest :-P"); } } I.e., you literally only need to implement what the test case will actually invoke. Anything that isn't strictly required is fair game to just outright ignore. Also, keep in mind that MockDb can be a completely different thing per unittest. Trying to use the same mock DB for all unittests will just end up with writing your own database engine, which kinda defeats the purpose. :-P But the ability to do this depends on how decoupled the code is. Code with complex interdependencies will generally give you a much harder time than more modular, decoupled code. T
Re: Incomprehensible error message
On Mon, 2018-03-19 at 10:54 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > > One wild guess is if some of the symbols come from different modules, > such that you might have modA.dvb_entry vs. modB.dvb_entry, for > example, > which would be a type mismatch. Or if one symbol was declared in D > linkage but the other in C linkage, which is perhaps a more likely > cause. But since the compiler doesn't tell us the FQN of the > identifiers, it's anybody's guess whether this is actually the > problem, > or which are the offending identifiers. > Prompted by this and Adam's emails, which gave me the moral support to getting stuck in to doing something rather than just moaning :-) I think the problem is with the instance of dvb_entry *. The call is actually in a loop: for (auto entry = ptr.c_ptr().first_entry; entry != null; entry = entry.next) { if (entry.channel is null) { continue; } // TODO Shouldn't need this, but it seems needed, why? frontendParameters.logfunc(LOG_INFO, "\nChannel: %s", entry.channel); try { auto scanHandler = ScanHandler_Ptr(frontendParameters.c_ptr(), entry, dmx_fd.value(), , other_nit, timeout_multiplier); I tried replacing the auto with dvb_entry* and we have the answer: ../../Repositories/Git/Masters/DVBTune/source/channels.d(157): Error: cannot implicitly convert expression `(*this.ptr.c_ptr()).first_entry` of type `libdvbv5_d.dvb_file.dvb_entry*` to `libdvbv5_d.dvb_scan.dvb_entry*` This is most likely an unintended consequence of using DStep: the dvb_entry type is being defined in two distinct modules. Now everything is clear and I just need to find a solution to why two definitions. The error message is still incomprehensible as is though. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: Packages and module import
On Mon, 2018-03-19 at 11:56 -0600, Jonathan M Davis via Digitalmars-d- learn wrote: > > […] > Well, what's the module statement in linux_dmx.d look like? > There wasn't one, even though I knew there was one. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: Packages and module import
On Mon, 2018-03-19 at 17:49 +, Adam D. Ruppe via Digitalmars-d- learn wrote: > […] > > Odds are, linux_dmx.d is missing the `module > libdvbv5_d.linux_dmx;` line. > […] You are right. I was certain I had correct module statements in all the modules, but I hadn't. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
[Issue 18624] getSymbolsByUDA produces wrong result if one of the symbols having the UDA is a function
https://issues.dlang.org/show_bug.cgi?id=18624 spoov0@gmail.com changed: What|Removed |Added CC||elpenguin...@gmail.com --- Comment #3 from spoov0@gmail.com --- *** Issue 18555 has been marked as a duplicate of this issue. *** --
[Issue 18555] getSymbolsByUDA has strange behaviour on modules
https://issues.dlang.org/show_bug.cgi?id=18555 spoov0@gmail.com changed: What|Removed |Added Resolution|FIXED |DUPLICATE --- Comment #2 from spoov0@gmail.com --- *** This issue has been marked as a duplicate of issue 18624 *** --
Re: Incomprehensible error message
On Mon, Mar 19, 2018 at 05:01:32PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Monday, 19 March 2018 at 16:33:28 UTC, Russel Winder wrote: > > I have been staring at this message so long, I have clearly stopped > > actually reading it, hence outside assistance needed. > > So I would guess either there's two definitions of one of the types > like maybe `dvb_v5_fe_parms` and the constructor uses one and your > code uses another (may be the same struct defined in two different > modules, where the definition imported one and you imported another - > stupid compiler was (is?) liable to say "type A is not type A" when it > should say "type foo.A is not bar.A"), or something like a stray const > on the `this` pointer. > > > I almost remember that A != A bug was fixed but maybe not in function > call things, or maybe not pushed to your ldc version yet. Yeah, the compiler really ought to be outputting FQNs in error messages, since otherwise you get baffling A != A messages. Though outputting FQNs everywhere has the tendency of bloating error messages to unreadable lengths, esp. when templates are involved. :-( (Though fortunately, no templates are involved in this case.) On a higher level, though, these type mismatch errors really ought to be refactored to pinpoint the cause of the compiler's unhappiness more narrowly, i.e., instead of saying: function F(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) is not callable with parameter types (a,b,c,d,e,f,g,h,j,i,k,l,m,n,o,p,q,r,s,t,u,v) which requires the poor user to parse *two* entire incomprehensibly long parameter/argument lists and diff them in his head, the compiler really should say something more along the lines of: cannot pass argument j of type J to parameter 9 of type I and argument i of type I to parameter 10 of type J in function call to F(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) The incomprehensibly long parameter list is unfortunately probably still necessary to identify any overloads of F, but at least point out to the user *which* parameters aren't matching instead of leaving him to figure it out! T -- IBM = I'll Buy Microsoft!
Re: Packages and module import
On Monday, March 19, 2018 17:29:10 Russel Winder via Digitalmars-d-learn wrote: > I had assumed that a directory of modules was a package. So for > example: > > A/a.d > A/b.d > > were two modules in package A. Especially given there is a module > statement at the beginning of each module: > > A/a.d has module A.a; > A/b.d has module A.b; > > Now A.b needs to access something from A.a. I had assumed that the > import should be fully qualified. So in A.b.d: > > import A.a: thing; > > This all works when building the library. Yes packages are directories and modules are files, but that can be mucked with on some level by explicitly marking the module with a module path that doesn't match its directory structure. If you do that, that tends to cause problems with the compiler finding your module to import, and build tools like rdmd and dub assume that the module's import path matches the file structure, but it's unfortunately not actually required, much as conceptually, that's the idea. > ldc2 -of=Build/Release/libdvbv5_d.so -shared -defaultlib=phobos2-ldc > Build/Release/source/libdvbv5_d/linux_dmx.o > Build/Release/source/libdvbv5_d/dvb_v5_std.o > Build/Release/source/libdvbv5_d/dvb_frontend.o > Build/Release/source/libdvbv5_d/dvb_log.o > Build/Release/source/libdvbv5_d/dvb_demux.o > Build/Release/source/libdvbv5_d/dvb_fe.o > Build/Release/source/libdvbv5_d/dvb_file.o > Build/Release/source/libdvbv5_d/dvb_scan.o > Build/Release/source/libdvbv5_d/dvb_sat.o -L-ldruntime-ldc > > > However when trying to build the unit-tests: > > > ldc2 -I=source -unittest --main -of=Build/Test/libdvbv5_d > source/libdvbv5_d/linux_dmx.d source/libdvbv5_d/dvb_v5_std.d > source/libdvbv5_d/dvb_frontend.d source/libdvbv5_d/dvb_log.d > source/libdvbv5_d/dvb_demux.d source/libdvbv5_d/dvb_fe.d > source/libdvbv5_d/dvb_file.d source/libdvbv5_d/dvb_scan.d > source/libdvbv5_d/dvb_sat.d source/libdvbv5_d/dvb_demux.d(35): Error: > module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported > with 'import linux_dmx;' > > > Am I just missing something simple? Well, what's the module statement in linux_dmx.d look like? For better or worse, while the compiler will infer a module's name from the file name if you don't give it one, it won't infer the pcakage name. So, if you have no module declaration in linux_dmx.d, then it's going to be inferred as being the module linux_dmx with no package. So, that may or may not be part of your problem. Based on what you posted, it's not at all clear to me how you're building this stuff. The first example without -unittest is just dealing with .o files and not having to deal with imports at all. To know how that's being dealt with would require the command-line associated with generating the .o files. Also, if the import that's being complained about is in a unit test and isn't imported outside of one, then the problem relating to the import wouldn't be found when building without -unittest. The same would frequently be true if it's a template, since often, templates aren't instantiated outside of unit tests when compiling a library. - Jonathan M Davis
Re: Incomprehensible error message
On Mon, Mar 19, 2018 at 04:33:28PM +, Russel Winder via Digitalmars-d-learn wrote: [...] > I have been staring at this message so long, I have clearly stopped > actually reading it, hence outside assistance needed. > > Can someone please explain to me (probably in words of one syllable > since I am clearly being very unintelligent) how any code can deliver > an error message such as: [...] Here's my reformatting of the error, that hopefully might be of assistance: > source/channels.d(161): Error: constructor > libdvbv5.ScanHandler_Ptr.this ( > dvb_v5_fe_parms* frontendParameters, > dvb_entry* entry, > const(int) dmx_fd, > extern (C) int function(void* args, dvb_v5_fe_parms* parms) > check_frontend, > const(uint) other_nit, > const(uint) timeout_multiplier) > is not callable using argument types ( > dvb_v5_fe_parms*, > dvb_entry*, > const(int), > extern (C) int function(void* _arguments, dvb_v5_fe_parms* > frontendParameters), > const(uint), > const(uint)) [...] Or, boiled down to the bare basics with extraneous identifiers removed: > source/channels.d(161): Error: constructor > libdvbv5.ScanHandler_Ptr.this ( > dvb_v5_fe_parms*, > dvb_entry*, > const(int), > extern (C) int function(void*, dvb_v5_fe_parms*), > const(uint), > const(uint)) > is not callable using argument types ( > dvb_v5_fe_parms*, > dvb_entry*, > const(int), > extern (C) int function(void*, dvb_v5_fe_parms*), > const(uint), > const(uint)) [...] Which is rather odd, since the parameter types correspond to each other exactly. So why the compiler would reject the code, I honestly have no idea. One wild guess is if some of the symbols come from different modules, such that you might have modA.dvb_entry vs. modB.dvb_entry, for example, which would be a type mismatch. Or if one symbol was declared in D linkage but the other in C linkage, which is perhaps a more likely cause. But since the compiler doesn't tell us the FQN of the identifiers, it's anybody's guess whether this is actually the problem, or which are the offending identifiers. T -- Prosperity breeds contempt, and poverty breeds consent. -- Suck.com
Re: Packages and module import
On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: I had assumed that a directory of modules was a package. So for example: [...] On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: To my amateur eyes, first command-line build looks like a linking of object files into a .so. The second command-line build looks like compilation is taking place. Seems like the command-line used to compile the library is missing.
Re: Packages and module import
On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: Especially given there is a module statement at the beginning of each module: It is not especially, it is ONLY because of the module statement. The directory layout is a convention so tools can find the module file, but only the module declaration line in the code itself defines the authoritative name. source/libdvbv5_d/dvb_demux.d(35): Error: module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported with 'import linux_dmx;' Odds are, linux_dmx.d is missing the `module libdvbv5_d.linux_dmx;` line. Any import statements and module statements need to use the same name. The layout in the file system is secondary to this.
Re: Is there a way to pipeline program with random-access ranges in C#?
On Monday, 19 March 2018 at 14:41:27 UTC, rumbu wrote: Sorry, but I fail to understand your requirements. Do you have a practical example? Doing this without writing a loop or using arrays for memoizing half-finished calculations: public static int Foo(int[] input) { int result = 10; for (int i = input.Length / 4; i >= 0; i -= 4) { int sum = 0; for (int j = i; j < i +4 && j < input.Length; j++) sum += input[j]; sum *= i; result = (result + sum) / 2; } return result; } To be honest, this is as artificial as it looks. When I look again at my code, it seems that my main problem was that I have not made a habit to input.Zip(Enumerable.Range(0, inputLength), Tuple.Create) or similar when I need indexing in C# :). I'm still interested in the answer, though.
Packages and module import
I had assumed that a directory of modules was a package. So for example: A/a.d A/b.d were two modules in package A. Especially given there is a module statement at the beginning of each module: A/a.d has module A.a; A/b.d has module A.b; Now A.b needs to access something from A.a. I had assumed that the import should be fully qualified. So in A.b.d: import A.a: thing; This all works when building the library. ldc2 -of=Build/Release/libdvbv5_d.so -shared -defaultlib=phobos2-ldc Build/Release/source/libdvbv5_d/linux_dmx.o Build/Release/source/libdvbv5_d/dvb_v5_std.o Build/Release/source/libdvbv5_d/dvb_frontend.o Build/Release/source/libdvbv5_d/dvb_log.o Build/Release/source/libdvbv5_d/dvb_demux.o Build/Release/source/libdvbv5_d/dvb_fe.o Build/Release/source/libdvbv5_d/dvb_file.o Build/Release/source/libdvbv5_d/dvb_scan.o Build/Release/source/libdvbv5_d/dvb_sat.o -L-ldruntime-ldc However when trying to build the unit-tests: ldc2 -I=source -unittest --main -of=Build/Test/libdvbv5_d source/libdvbv5_d/linux_dmx.d source/libdvbv5_d/dvb_v5_std.d source/libdvbv5_d/dvb_frontend.d source/libdvbv5_d/dvb_log.d source/libdvbv5_d/dvb_demux.d source/libdvbv5_d/dvb_fe.d source/libdvbv5_d/dvb_file.d source/libdvbv5_d/dvb_scan.d source/libdvbv5_d/dvb_sat.d source/libdvbv5_d/dvb_demux.d(35): Error: module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported with 'import linux_dmx;' Am I just missing something simple? -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: Incomprehensible error message
On Monday, 19 March 2018 at 16:33:28 UTC, Russel Winder wrote: I have been staring at this message so long, I have clearly stopped actually reading it, hence outside assistance needed. So I would guess either there's two definitions of one of the types like maybe `dvb_v5_fe_parms` and the constructor uses one and your code uses another (may be the same struct defined in two different modules, where the definition imported one and you imported another - stupid compiler was (is?) liable to say "type A is not type A" when it should say "type foo.A is not bar.A"), or something like a stray const on the `this` pointer. I almost remember that A != A bug was fixed but maybe not in function call things, or maybe not pushed to your ldc version yet.
Re: Vision document for H1 2018
On Friday, 16 March 2018 at 21:38:30 UTC, rumbu wrote: Do you know anything else in the .net library than LINQ where extension methods (somehow equivalent to UFCS) are abused? I thought that something happened in the .net world while I was asleep, that's why I just searched my local copy of .net core and there are exactly 198 extension methods. I would not call these "big". It's big because linq is perceptionally big in itself similar to how std.algorithm is big. It's also design pattern in C#: if you want a complex interface method with simplified overloads, you don't declare interface with many overloads, you declare one interface method that takes all parameters and a number of simplified extension methods that forward to interface, Unity container and Rhino mocks are designed this way. Last time I checked, .net Console was an enormous static class with three Stream objects behind the scenes. That's also how D console IO works. When I said that phobos looks like a mess compared to .net lib I referred especially to the poor choice of names (eg. RedBlackTree vs SortedDictionary) and lack of essential stuff (eg. happy to have levenshteinDistance built in, but I cannot sort correctly two strings in any other language than English). That's true, naming is a little complex.
Re: Lazy caching map()?
On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty expensive to compute, return an object `result` such that: [...] Map the sources to std.parallelism.Task instances, and yieldForce() the instances when you need the results? Graham
[Issue 18628] @disable this(this) erroneously adds `__postblit` member
https://issues.dlang.org/show_bug.cgi?id=18628 --- Comment #4 from Andrei Alexandrescu--- The problem with hasElaborateCopyConstructor is the binary expectation: * is that true? Then there's work involved to copy the object * is that false? Then the object can be copied with memcpy This does not account for the disabled case. So I'm not sure what to do here aside from defining a different trait e.g. hasDisabledCopyConstructor. --
[Issue 18628] @disable this(this) erroneously adds `__postblit` member
https://issues.dlang.org/show_bug.cgi?id=18628 Andrei Alexandrescuchanged: What|Removed |Added CC||and...@erdani.com --- Comment #3 from Andrei Alexandrescu --- Question applies to all functions. Consider: import std.stdio; import std.traits; struct A { @disable void fun(); } void main() { writeln(hasMember!(A, "fun")); // expected: false } This prints true. --
Re: Vision document for H1 2018
On Friday, 16 March 2018 at 18:35:14 UTC, Tony wrote: I thought C# was like Java and does not allow free procedures. Can you give an example of C# procedural-style IO? All methods of Console class.
Incomprehensible error message
Hi, I have been staring at this message so long, I have clearly stopped actually reading it, hence outside assistance needed. Can someone please explain to me (probably in words of one syllable since I am clearly being very unintelligent) how any code can deliver an error message such as: ldc2 -I=. -g -gc -d-debug -I/home/users/russel/Built/include/d -of=Build/Release/dvb-tune source/main.d source/libdvbv5.d source/channels.d -L-ldvbv5 source/channels.d(161): Error: constructor libdvbv5.ScanHandler_Ptr.this (dvb_v5_fe_parms* frontendParameters, dvb_entry* entry, const(int) dmx_fd, extern (C) int function(void* args, dvb_v5_fe_parms* parms) check_frontend, const(uint) other_nit, const(uint) timeout_multiplier) is not callable using argument types (dvb_v5_fe_parms*, dvb_entry*, const(int), extern (C) int function(void* _arguments, dvb_v5_fe_parms* frontendParameters), const(uint), const(uint)) -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
[Issue 18357] can break immutable with postblit
https://issues.dlang.org/show_bug.cgi?id=18357 Andrei Alexandrescuchanged: What|Removed |Added CC||and...@erdani.com --- Comment #2 from Andrei Alexandrescu --- A similar example shows fetching a mutable pointer to immutable data: int* g; struct S { int* x; this(this) { g = x; } } void main() { immutable int* x = new int(42); assert(*x == 42); /* passes */ auto s = immutable S(x); auto s2 = s; /* should be rejected */ } --
Re: DConf 2018 Munich Registration is Open!
On Monday, 19 March 2018 at 14:28:59 UTC, Andrei Alexandrescu wrote: The D Language Foundation is thrilled to announce that registration for DConf 2018, May 2-5 in Munich, is now open. Hi Andrei, I think something broke on the dlang.org Web site when the announcement was added. I was on the download page: https://dlang.org/download.html ...and it's currently full of "DConf 2018 Programme & Open Registration" links, and no links to the actual downloads. Best, Graham
[Issue 18417] Make const and immutable postblit constructors illegal
https://issues.dlang.org/show_bug.cgi?id=18417 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 18417] Make const and immutable postblit constructors illegal
https://issues.dlang.org/show_bug.cgi?id=18417 --- Comment #9 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/86f2428bf3676a849f3b9cbaab2f1441e9776c71 Fix Issue 18417 - Make const and immutable postblit constructors illegal https://github.com/dlang/dmd/commit/6ef4e36f176b905bfd11e3d34ff826d9ebafec86 Merge pull request #8032 from RazvanN7/Issue_18417 Fix Issue 18417 - Make const and immutable postblit constructors illegal --
Re: Is there a way to pipeline program with random-access ranges in C#?
On Monday, 19 March 2018 at 11:35:46 UTC, Dukc wrote: This topic is technically in wrong place, since the problem is with C#, not D. But because what I'm asking is more idiomatic in D than elsewhere, I think I have the best changes to get understood here. So, I'm looking for some library, or technique, that allows me to chain range-evaluating commands like Phobos, but on C# or JavaScript. Either does, because I'm using Bridge.Net to compile C# to JavaScript, but I would prefer C# because of the type system. LinQ is otherwise just what I described, except that it can work only with input ranges that can be reseted to their initial state. That leads me to do a lot of for loops. In D I virtually never need them. I am wondering, does anybody know an alternative which can forward forwarding/bidirectional/random-access capability of source ranges too? Sorry, but I fail to understand your requirements. Do you have a practical example?
Re: Static library building
On Monday, 19 March 2018 at 14:31:05 UTC, Adam D. Ruppe wrote: On Monday, 19 March 2018 at 14:07:52 UTC, Vindex wrote: dmd main.d -L-L. -L-l:mod.a It still needs to know where to find the import file to get D information like names and types out of it that aren't in the lib (well they sorta are but not exactly, in any case it isn't implemented to try it now). So either still pass it mod.d there, which makes the library useless, or pass `-Isomething` where there's a `pack/mod.d` or `pack/mod.di` file with the function prototypes. dmd -H can make mod.di out of mod.d for you in some cases automatically. Thank you. Sorry, the library does not save the requested information.
Re: Static library building
On Monday, 19 March 2018 at 14:07:52 UTC, Vindex wrote: dmd main.d -L-L. -L-l:mod.a It still needs to know where to find the import file to get D information like names and types out of it that aren't in the lib (well they sorta are but not exactly, in any case it isn't implemented to try it now). So either still pass it mod.d there, which makes the library useless, or pass `-Isomething` where there's a `pack/mod.d` or `pack/mod.di` file with the function prototypes. dmd -H can make mod.di out of mod.d for you in some cases automatically.
DConf 2018 Munich Registration is Open!
The D Language Foundation is thrilled to announce that registration for DConf 2018, May 2-5 in Munich, is now open. The programme is set, the speakers are crafting their slides, and we're counting down the days. In addition to the traditional keynotes from D language stewards Walter Bright and Andrei Alexandrescu, our invited keynote comes from Martin Odersky, professor at EPFL and creator of the Scala language. Liran Zvibel of WekaIO will close out the talks on Day 3. That's 21 hours of talks followed on May 5th by the 2nd Annual DConf Hackathon, an all-day event where D coders get together to brainstorm, squash bugs, and improve the D programming experience. All of that combines with friendly people and intelligent conversation to create the meetup of meetups for the D language community. But DConf isn't just for D coders. No matter which language your text editor speaks, we warmly invite you to join us. We love to introduce DLang to the uninitiated, exchange ideas, and make new friends. Like German beer? So do we! Join us for a few in Munich! Visit dconf.org to see the programme[1] and register[2], then head over to the D Blog[3] for the latest post on DConf. See you in Munich May 2-5! [1] http://dconf.org/2018/schedule/index.html [2] http://dconf.org/2018/registration.html [3] http://dlang.org/blog/2018/03/19/dconf-2018-programme-open-registration/
Re: This week in D
On Monday, 19 March 2018 at 10:04:15 UTC, bauss wrote: Has it stopped completely or is it just temporary? I want to restart it with a 2.0 thing probably monthly instead of weekly (well I might generate the link list automatically each week, but commit to doing a feature once a month) as part of the dpldocs.info project: have stuff from community projects as well as bugzilla stats and try to get tutorials for it. It will definitely NOT be sunday anymore - that day just doesn't work for me. I'm considering making it a part of the patreon goal so I can even commission stuff but idk yet. But yes, I do intend to get back into it, just not sure on timetable.
Static library building
'main.d': import pack.mod; void main() { fn("Hello"); } 'mod.d': module pack.mod; void fn(string s) { import std.stdio; writeln("Hello"); } Both files are in the same directory. So all is well: dmd main.d mod.d So all is bad: dmd mod.d -lib dmd main.d -L-L. -L-l:mod.a main.d(1): Error: module mod is in file 'pack/mod.d' which cannot be read Please answer why it happens.
DConf 2018 Munich Registration is Open!
The D Language Foundation is thrilled to announce that registration for DConf 2018, May 2-5 in Munich, is now open. The programme is set, the speakers are crafting their slides, and we're counting down the days. In addition to the traditional keynotes from D language stewards Walter Bright and Andrei Alexandrescu, our invited keynote comes from Martin Odersky, professor at EPFL and creator of the Scala language. Liran Zvibel of WekaIO will close out the talks on Day 3. That's 21 hours of talks followed on May 5th by the 2nd Annual DConf Hackathon, an all-day event where D coders get together to brainstorm, squash bugs, and improve the D programming experience. All of that combines with friendly people and intelligent conversation to create the meetup of meetups for the D language community. But DConf isn't just for D coders. No matter which language your text editor speaks, we warmly invite you to join us. We love to introduce DLang to the uninitiated, exchange ideas, and make new friends. Like German beer? So do we! Join us for a few in Munich! Visit dconf.org to see the programme[1] and register[2], then head over to the D Blog[3] for the latest post on DConf. See you in Munich May 2-5! [1] http://dconf.org/2018/schedule/index.html [2] http://dconf.org/2018/registration.html [3] http://dlang.org/blog/2018/03/19/dconf-2018-programme-open-registration/
Re: RBTree delegates and types
On Monday, 19 March 2018 at 11:30:13 UTC, Steven Schveighoffer wrote: Yes, you need a `this` pointer for it to work. However, we can do this by encapsulating the return type with an auto function: https://run.dlang.io/is/inSzaU Sorry I didn't get this right away. Interesting chicken-and-egg problem, but as usual, D delivers :) -Steve That's beautiful! Thanks!
Re: Build an AliasSeq from memberFunction return types
I couldn't have wished for a better answer! Thank you so much, Simen.
[Issue 18604] in parameter storage class should be deprecated
https://issues.dlang.org/show_bug.cgi?id=18604 Adam D. Ruppechanged: What|Removed |Added CC||destructiona...@gmail.com --- Comment #2 from Adam D. Ruppe --- It never should have been changed from `scope const` in the first place. Anyone who was misusing it is responsible for their own mistake - all written material on the language, from spec to tutorials to books, have been clear from the beginning about what it does and when you are supposed to use it. Their code was already broken. --
Re: Does the compiler inline the predicate functions to std.algorithm.sort?
On Monday, 19 March 2018 at 12:45:58 UTC, tipdbmp wrote: (@tipdbmp: The string gets turned into the function _D3std10functional__T9binaryFunVAyaa5_61203c2062VQra1_61VQza1_62Z__TQBvTiTiZQCdFNaNbNiNfKiKiZb. No references to it remain with -O3; the LLVM IR obtained with -output-ll might be easier to read than assembly.) I see. It seems that ldc 1.8.0 with "-release -O2|3" inlines it, but dmd 2.079.0 with "-release" (no -O option?) does not. DMD has a -inline flag to enable inlining - though LDC is a lot better in optimization than DMD and thus typically used for anything performance related. the LLVM IR obtained with -output-ll might be easier to read than assembly.) I only seem to get assembly on d.godbolt.org, even with the -output-ll option. You can get IR on run.dlang.io by simply selecting LDC and hitting the IR button.
Re: Does the compiler inline the predicate functions to std.algorithm.sort?
(@tipdbmp: The string gets turned into the function _D3std10functional__T9binaryFunVAyaa5_61203c2062VQra1_61VQza1_62Z__TQBvTiTiZQCdFNaNbNiNfKiKiZb. No references to it remain with -O3; the LLVM IR obtained with -output-ll might be easier to read than assembly.) I see. It seems that ldc 1.8.0 with "-release -O2|3" inlines it, but dmd 2.079.0 with "-release" (no -O option?) does not. the LLVM IR obtained with -output-ll might be easier to read than assembly.) I only seem to get assembly on d.godbolt.org, even with the -output-ll option.
Re: help cast
On Monday, 19 March 2018 at 11:20:05 UTC, Steven Schveighoffer wrote: Let me adjust your example a bit, and see if you still agree: auto bytes = cast(ubyte[])[55_444, 289, 1_000_000, 846, 123_456_789]; writeln(bytes); // [148, 33, 64, 78, 21] I have used cast(ubyte[]) to get ubytes as well, but I normally would do this for values that actually *could be* ubytes. for values higher than ubytes, I would not have expected implicit truncation. It's especially confusing to someone who has seen when you cast an int[] to a ubyte[], and gets the bytes for that same data. When I use cast(ubyte[]), I took it to mean "pretend this is a ubyte[] literal", not "cast each element to ubyte". I can also see this biting someone who has a long set of ubytes, and accidentally does one that is larger than 255. -Steve Raw `cast` is just nasty. It's overloaded and confusing. Wrapper template functions like `reinterpretBitsAs` can help alleviate the pain, e.g. `assert([1, 2, 3].reinterpretBitsAs!(ubyte[]).length == 12);`. I feel like C++ got it right (or just less wrong) with casts.
Re: The D Language Foundation at Open Collective
On Monday, 19 March 2018 at 09:42:11 UTC, rumbu wrote: On Monday, 19 March 2018 at 07:22:42 UTC, Paolo Invernizzi wrote: On Thursday, 15 March 2018 at 12:36:24 UTC, Meta wrote: On Wednesday, 14 March 2018 at 12:00:42 UTC, Seb wrote: Yeah, the idea is that 5$ a month isn't much (~ one coffee in most countries), but if 500 people donate one coffee a month, you get the entire coffee machine with a warp engine :) Sorry to derail, but I had to ask: where does 1 coffee (even extra large) cost $5 USD? Let me know so I know to never move there. Yeah... I still prefer an 'espresso', that in Italy is simply called 'caffè': 1.00 euro in Milano. An original Cappuccino, italiano, is 1.20 euro... /Paolo I wonder how did you survive in Italy without Starbucks? :) Well, things are moving... [1] I'm wondering if they will do the 'espresso solo' the Italian Way guess not! Anyhow, I've drank a very very good "caffè espresso" in Silicon Valley, in a Google Plex building... There was a guy with a real passion about it, and he was able to use an Italian Coffè Machine in the right way. :-) [1] https://starbucksreservecareers.it/index.html
Re: help cast
On Monday, 19 March 2018 at 11:20:05 UTC, Steven Schveighoffer wrote: On 3/18/18 4:07 PM, Jonathan M Davis wrote: That's exactly what it's doing, and when you have multiple elements in the literal, it quickly gets a lot more pleasant than casting each element individually. e.g. cast(ubyte[])[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] vs [cast(ubyte)0, cast(ubyte)1, cast(ubyte)2, cast(ubyte)3, cast(ubyte)4, cast(ubyte)5, cast(ubyte)6, cast(ubyte)7, cast(ubyte)8, cast(ubyte)9, cast(ubyte)10] I use this trick all the time when creating arrays of integral types smaller than int, precisely because casting each element is a royal pain and way harder to read. Let me adjust your example a bit, and see if you still agree: auto bytes = cast(ubyte[])[55_444, 289, 1_000_000, 846, 123_456_789]; writeln(bytes); // [148, 33, 64, 78, 21] I have used cast(ubyte[]) to get ubytes as well, but I normally would do this for values that actually *could be* ubytes. for values higher than ubytes, I would not have expected implicit truncation. It's especially confusing to someone who has seen when you cast an int[] to a ubyte[], and gets the bytes for that same data. When I use cast(ubyte[]), I took it to mean "pretend this is a ubyte[] literal", not "cast each element to ubyte". I can also see this biting someone who has a long set of ubytes, and accidentally does one that is larger than 255. -Steve An even funnier example. auto bytes = cast(ubyte[])cast(int[])[55_444, 289, 1_000_000, 846, 123_456_789]; auto bytes2 = cast(int[])[55_444, 289, 1_000_000, 846, 123_456_789]; auto bytes3 = cast(ubyte[])bytes2; writeln(bytes); // Guess what the output is here. writeln(bytes2); // Prints:[55444, 289, 100, 846, 123456789] writeln(bytes3); // Prints: [148, 216, 0, 0, 33, 1, 0, 0, 64, 66, 15, 0, 78, 3, 0, 0, 21, 205, 91, 7]
[Issue 18628] @disable this(this) erroneously adds `__postblit` member
https://issues.dlang.org/show_bug.cgi?id=18628 --- Comment #2 from RazvanN--- What I'm saying is that the output of hasMember is correct, but the output of hasElaborateCopyConstructor most certainly isn't, but, in my opinion, the fix should be in phobos, not in dmd. --
[Issue 18628] @disable this(this) erroneously adds `__postblit` member
https://issues.dlang.org/show_bug.cgi?id=18628 RazvanNchanged: What|Removed |Added CC||razvan.nitu1...@gmail.com --- Comment #1 from RazvanN --- Well, the struct defines the member, it's just that it is disabled. One might argue that the output is correct and the programmer needs to check if the member is disabled or not --
Is there a way to pipeline program with random-access ranges in C#?
This topic is technically in wrong place, since the problem is with C#, not D. But because what I'm asking is more idiomatic in D than elsewhere, I think I have the best changes to get understood here. So, I'm looking for some library, or technique, that allows me to chain range-evaluating commands like Phobos, but on C# or JavaScript. Either does, because I'm using Bridge.Net to compile C# to JavaScript, but I would prefer C# because of the type system. LinQ is otherwise just what I described, except that it can work only with input ranges that can be reseted to their initial state. That leads me to do a lot of for loops. In D I virtually never need them. I am wondering, does anybody know an alternative which can forward forwarding/bidirectional/random-access capability of source ranges too?
Re: RBTree delegates and types
On 3/19/18 5:16 AM, Viktor wrote: Hi Steve, thanks for replying! I've also noticed that RedBlackTree.opEquals() is like this from the initial pull request and was wondering if noone has been using a delegate and why... typically, you don't need a delegate, but generally, you CAN use a delegate as an alias "less" function. I don't see why it should be restricted here. But this is probably why nobody ever found it -- most people just use the default lambda. On the second topic, I've tried that and it doesn't work. I have a minimal test program that shows the issue. https://run.dlang.io/is/WNF78H Oh! I totally missed that comp is a member function (in your first example). I thought it was passed in. Sorry for not taking a closer look. Yes, you need a `this` pointer for it to work. However, we can do this by encapsulating the return type with an auto function: https://run.dlang.io/is/inSzaU Sorry I didn't get this right away. Interesting chicken-and-egg problem, but as usual, D delivers :) -Steve
Re: help cast
On 3/18/18 4:07 PM, Jonathan M Davis wrote: That's exactly what it's doing, and when you have multiple elements in the literal, it quickly gets a lot more pleasant than casting each element individually. e.g. cast(ubyte[])[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] vs [cast(ubyte)0, cast(ubyte)1, cast(ubyte)2, cast(ubyte)3, cast(ubyte)4, cast(ubyte)5, cast(ubyte)6, cast(ubyte)7, cast(ubyte)8, cast(ubyte)9, cast(ubyte)10] I use this trick all the time when creating arrays of integral types smaller than int, precisely because casting each element is a royal pain and way harder to read. Let me adjust your example a bit, and see if you still agree: auto bytes = cast(ubyte[])[55_444, 289, 1_000_000, 846, 123_456_789]; writeln(bytes); // [148, 33, 64, 78, 21] I have used cast(ubyte[]) to get ubytes as well, but I normally would do this for values that actually *could be* ubytes. for values higher than ubytes, I would not have expected implicit truncation. It's especially confusing to someone who has seen when you cast an int[] to a ubyte[], and gets the bytes for that same data. When I use cast(ubyte[]), I took it to mean "pretend this is a ubyte[] literal", not "cast each element to ubyte". I can also see this biting someone who has a long set of ubytes, and accidentally does one that is larger than 255. -Steve
dub default settings
I find myself typing over and over again the same things like '-a x86_64'. Is it somehow possible to set those defaults?
[Issue 18445] [DIP25][DIP1000] Wrong "return as a parameter attribute" inference
https://issues.dlang.org/show_bug.cgi?id=18445 Carsten Blüggelchanged: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |INVALID --
[Issue 18445] [DIP25][DIP1000] Wrong "return as a parameter attribute" inference
https://issues.dlang.org/show_bug.cgi?id=18445 Carsten Blüggelchanged: What|Removed |Added Blocks|18444 | --- Comment #1 from Carsten Blüggel --- (In reply to Carsten Blüggel from comment #0) > Example from phobos (-dip1000, DMD64 D Compiler v2.078.2+/master): > https://github.com/dlang/phobos/blob/master/std/container/slist.d > > make -f posix.mak std/container/slist.test (-dip1000 switch for that module) > > std/container/slist.d(378) [referring to struct SList(T). size_t > insertFront(Stuff)(Stuff stuff)]: Error: parameter stuff is return but > function does not return any indirections > > No error, when -dip25 switch is thrown instead. Fixing slist.d to be -dip1000 compilable doesn't depend on this issue any more Referenced Issues: https://issues.dlang.org/show_bug.cgi?id=18444 [Issue 18444] [DIP25][DIP1000] Tracking issue for: "The implementation doesn't match DIPs 25/1000" --
[Issue 18444] [DIP25][DIP1000] Tracking issue for: "The implementation doesn't match DIPs 25/1000"
https://issues.dlang.org/show_bug.cgi?id=18444 Carsten Blüggelchanged: What|Removed |Added Depends on|18445 | Referenced Issues: https://issues.dlang.org/show_bug.cgi?id=18445 [Issue 18445] [DIP25][DIP1000] Wrong "return as a parameter attribute" inference --
Re: Seeking lecturer - D language (Moscow)
Я работаю в Москве и вполне мог бы заняться этим направлением. On Friday, 16 March 2018 at 04:57:57 UTC, Dmitry Olshansky wrote: On Friday, 16 March 2018 at 00:18:20 UTC, Ivan Kazmenko wrote:
This week in D
Has it stopped completely or is it just temporary? There hasn't been anything since November: http://arsdnet.net/this-week-in-d/2017-nov-26.html
Re: The D Language Foundation at Open Collective
On Monday, 19 March 2018 at 07:22:42 UTC, Paolo Invernizzi wrote: On Thursday, 15 March 2018 at 12:36:24 UTC, Meta wrote: On Wednesday, 14 March 2018 at 12:00:42 UTC, Seb wrote: Yeah, the idea is that 5$ a month isn't much (~ one coffee in most countries), but if 500 people donate one coffee a month, you get the entire coffee machine with a warp engine :) Sorry to derail, but I had to ask: where does 1 coffee (even extra large) cost $5 USD? Let me know so I know to never move there. Yeah... I still prefer an 'espresso', that in Italy is simply called 'caffè': 1.00 euro in Milano. An original Cappuccino, italiano, is 1.20 euro... /Paolo I wonder how did you survive in Italy without Starbucks? :)
Re: The D Language Foundation at Open Collective
On Monday, 19 March 2018 at 07:22:42 UTC, Paolo Invernizzi wrote: On Thursday, 15 March 2018 at 12:36:24 UTC, Meta wrote: On Wednesday, 14 March 2018 at 12:00:42 UTC, Seb wrote: Yeah, the idea is that 5$ a month isn't much (~ one coffee in most countries), but if 500 people donate one coffee a month, you get the entire coffee machine with a warp engine :) Sorry to derail, but I had to ask: where does 1 coffee (even extra large) cost $5 USD? Let me know so I know to never move there. Yeah... I still prefer an 'espresso', that in Italy is simply called 'caffè': 1.00 euro in Milano. An original Cappuccino, italiano, is 1.20 euro... /Paolo O.K. Paolo, you are in a very bad position you would have to give up your morning espresso a whole five day working week to make the 5$ for "dlang.org" donation :-) It was a view years ago, when I was in the US, thinking: "espresso, should be the same in Colorado as in Germany." But I got shocked by the bar keeper putting spray cream on top of the small cup... So you never know what you get, if your order something called "coffee" if you are outside of Bella Italia!
Re: RBTree delegates and types
On Sunday, 18 March 2018 at 17:21:58 UTC, Steven Schveighoffer wrote: On 3/18/18 8:34 AM, Viktor wrote: Hey, I'm trying to convert an old legacy app to D and have a couple of questions. It has been a very fun weekend! First, I could not make std.container.rbtree use a delegate for a comparator. The docs say it should be possible, but I got a weird error. I tracked it down to RedBlackTreee.opEquals() using explicit function when calling equals(): return equal!(function(Elem a, Elem b) => !_less(a,b) && !_less(b,a))(thisRange, thatRange); When I removed the "function" things started compiling (I have yet to test the code due to question #2 below). I've done a dub -b unittest without issues so it might be OK. So, the first...several questions are: do you think this change is safe and should I raise an issue in the bugzilla or do a PR for it on github? Yes, seems like an oversight. RedBlackTree.opEquals was added almost 6 years ago, and it's possible this wouldn't have worked back then (https://github.com/dlang/phobos/pull/900) Should it include a new unittest that makes sure rbtree can be instantiated with a delegate? Definitely. Thanks for thinking of this! The other part I'm still struggling with is about auto types. Can I store the rbtree type in the following class so it can be used from another method? class Indexer(T, alias pred) { alias RBType = RedBlackTree!(uint, (a, b) => comp(a, b)); this(T storage) { this.storage = storage; this.index = new RBType(); } void dumpIndex() { // how to get my dirty hands on the index here? // answer: just use it? } bool comp(uint i1, uint i2) { auto rec1 = storage[i1]; auto rec2 = storage[i2]; return pred(rec1, rec2); } private T storage; RBType index; } -Steve Hi Steve, thanks for replying! I've also noticed that RedBlackTree.opEquals() is like this from the initial pull request and was wondering if noone has been using a delegate and why... On the second topic, I've tried that and it doesn't work. I have a minimal test program that shows the issue. https://run.dlang.io/is/WNF78H onlineapp.d(15): Error: need this for less of type bool(int a, int b) onlineapp.d(15):instantiated from here: Generic!((a, b) => less(a, b)) If I try using an explicit delegate in the alias: onlineapp.d(15): Error: delegate `onlineapp.Custom.__dgliteral6` cannot be class members onlineapp.d(15):instantiated from here: Generic!(delegate (a, b) => less(a, b)) That seems reasonable to me, since the delegate needs a frame (for the this pointer) and there is no frame at that point. I think in the end I'll need to plant an interface that RBTree will implement and use the interface instead. The code in question: class Generic(alias pred) { void add(int a, int b) { import std.stdio : writeln; if (pred(a,b)) writeln(a); else writeln(b); } } class Custom { alias MyGeneric = Generic!( (a,b) => less(a,b) ); private MyGeneric g; this () { g = new MyGeneric; } void test() { g.add(5, 6); } bool less(int a, int b) { import std.stdio : writeln; writeln("Yup"); return a < b; } } void main() { auto t = new Custom; t.test; }
Re: Should the "front" range primitive be "const" ?
On Friday, 2 February 2018 at 14:29:34 UTC, H. S. Teoh wrote: On Fri, Feb 02, 2018 at 07:06:56AM +, Simen Kjærås via Digitalmars-d-learn wrote: [...] Its semantics are not broken; it's just harder to use. Due to const transitivity, it's an all-or-nothing deal. .tailConst gives us the middle ground. [...] FWIW there's also head const in phobos since more than one year - known as Final: https://dlang.org/phobos/std_experimental_typecons.html
[Issue 18629] std.algorithm.iteration.subsitute is slow
https://issues.dlang.org/show_bug.cgi?id=18629 greenifychanged: What|Removed |Added CC||greeen...@gmail.com Assignee|nob...@puremagic.com|greeen...@gmail.com --
Re: CTFE ^^ (pow)
On Monday, 19 March 2018 at 05:27:20 UTC, Norm wrote: On Monday, 19 March 2018 at 04:15:26 UTC, rikki cattermole wrote: On 19/03/2018 5:05 PM, Norm wrote: On Monday, 19 March 2018 at 03:53:07 UTC, rikki cattermole wrote: On 19/03/2018 4:43 PM, Norm wrote: [...] You just said the magic word, medical. D was never an appropriate fit here. dmd's backend has been for thirty years (or so) been up to recently licensed so that you may not use it for this purpose. Nothing has changed here. I have no idea what you're talking about now. What has the backend license got to do with medical? The code generation capabilities of dmd has not been certified for medical usage. In essence, if it generated bad code, kills somebody, your the one at fault, even if the source is fine. You would end up begging to settle out of court. It is my understanding that medical software manufacturers pay for their compilers already certified. So that suggests to me that you're not exactly life threatening but I would still caution you away from D even if that bit is just my own opinion. No, compilers do not need to be certified for class B or class C software. These are the two highest safety classes for medical SW. Beyond class C SW is not allowed, e.g. safety critical interlocks such as the big red button to shut off a radiation dose or stop a robotic system. Compilers are are treated as SOUP (Software of Unknown Provenance), i.e. a black box. Risk analysis leads to risk control measures that in turn ensure people don't die and this is done at the system and component level, not the codegen level. Verification is performed to ensure the system implements the requirements correctly, and subsequently the risk control measures. Not all requirements are risk control measures, but all requirements must be verified as correct. Cheers, Norm I was the CTO and partner of a company using D in medical devices since more than ten years ago... as Norm wrote, medical software is a strange beast... Anyway, as someone else wrote, when I leaved the company, two years ago, the new CTO and my former colleague, decided not to invest anymore in D. After ten years of use. Said that, I'm pretty happy about what's happening in D Land in the last 3/4 months, but clearly there's a lot to be done. /Paolo
Re: The D Language Foundation at Open Collective
On 03/19/2018 12:31 AM, Tony wrote: I believe they only mentioned the time factor, but it is also labor intensive to manually pour the water. Yup [nod, nod]. That's why decades ago they invented machines to pour the hot water over the coffee for us ;) It even heats up the water, too!
Re: Logging Function Parameters
On Sunday, 18 March 2018 at 23:17:58 UTC, Dennis wrote: On Sunday, 18 March 2018 at 22:57:15 UTC, aliak wrote: // But you get a: // Error: Using the result of a comma expression is not allowed // writeln(mixin(arguments!f)); You can't mix part of a function call in: "Mixed in text must form complete declarations, statements, or expressions." (https://dlang.org/articles/mixin.html) In this case, it evaluates to a comma expression, which is deprecated. If you put the "writeln();" inside the mixin string it should form a complete statement and compile. Ah! Thanks for the clarification.
Re: how to make private class member private
On Monday, 19 March 2018 at 01:11:43 UTC, psychoticRabbit wrote: The fact that the creator of a class, is also the creator of the module that contains that class, is not a valid reason for not seeking to improve encapsulation of that class. I agree with this. This especially matters with projects where multiple people might work on the same module. You might not want to expose every member to all the people who work on the module. Whereas you might want other members to be exposed to the module and not outside, so the argument for putting the class into a new module doesn't work either, since the members you do want to expose cannot be exposed, unless they're public, in which case it defeats the whole purpose of encapsulation. Yes, it's great that private is module-level by default, but it just doesn't work in practice with modules worked on by multiple people. Tons of bugs can be avoided too, like a few times unittests have passed in phobos with traits because private members were visible in the module. (I can't remember a specific example on top of my head, but it has happened a few times.)
[Issue 18199] Error with lambda in struct initializer
https://issues.dlang.org/show_bug.cgi?id=18199 --- Comment #9 from John Belmonte--- The attempted change to parser.d broke some code in a test application. It's possible to have a function body with no colon or return tokens at the top level (e.g. a body with just a switch statement). I also realized that the current dmd code can misinterpret a function literal as a struct initializer as well. Contrived, but consider the following function body which has no colon or return at any scope: static MyFun foo = { final switch(5) { } }; So the "color or return" test is clearly not robust for discerning function literal from struct initializer. New plan is to try to implement a simple lookahead to test for struct initializer. --
[Issue 17784] [scope][DIP1000] Confusing error message for escaping local via new-expression
https://issues.dlang.org/show_bug.cgi?id=17784 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #1 from Walter Bright --- https://github.com/dlang/dmd/pull/8054 --
[Issue 18622] Outdated information regarding link definition when generated by Visual D DLL project.
https://issues.dlang.org/show_bug.cgi?id=18622 Rainer Schuetzechanged: What|Removed |Added CC||r.sagita...@gmx.de --- Comment #1 from Rainer Schuetze --- Thanks for the report. For the next release I have changed that comment to ; exporting can by done explicitly here, or with the "export" specifier --
Re: The D Language Foundation at Open Collective
On Thursday, 15 March 2018 at 12:36:24 UTC, Meta wrote: On Wednesday, 14 March 2018 at 12:00:42 UTC, Seb wrote: Yeah, the idea is that 5$ a month isn't much (~ one coffee in most countries), but if 500 people donate one coffee a month, you get the entire coffee machine with a warp engine :) Sorry to derail, but I had to ask: where does 1 coffee (even extra large) cost $5 USD? Let me know so I know to never move there. Yeah... I still prefer an 'espresso', that in Italy is simply called 'caffè': 1.00 euro in Milano. An original Cappuccino, italiano, is 1.20 euro... /Paolo
[Issue 18242] DMD Segmentation fault.
https://issues.dlang.org/show_bug.cgi?id=18242 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #2 from Walter Bright --- https://github.com/dlang/dmd/pull/8050 --