Re: dlang.org/Learn "hello_world".sort.chain ...
On Tuesday, 26 December 2023 at 11:19:29 UTC, Sergey wrote: Use typeid, instead of typeof Thanks! Got quite a type but I will worry about that later: std.range.SortedRange!(Result, "a < b").SortedRange
Re: Gordon programming language
On Sunday, 24 October 2021 at 10:13:14 UTC, Tero Hänninen wrote: Hello, I don't know how to make websites... and I want a much lighter background actually. Take a look! :) Haven't done html in years, but I believe this line is specifying the color of your text and the color of your background: -> body { font-family: monospace; color: #e0e0da; background-color: #1b1d1e; } <- The values in main.css are for a dark text on a light background: background: #F0EDE3; color: #33290A; You could either remove the "{body.." line from index.html or modify the "color" and "background-color" attribute values.
TDPL book and __traits(compiles...) snippet
In section 6.2 of The D Programming Language it talks about how the compiler will try and tell if you are going to use a null reference. It gives this code snippet below to demonstrate that. But with DMD v2.096.1-dirty I am getting that the compiler thinks the code is OK. With a "!" the assert fails. class A { int x; } A a; assert(!__traits(compiles, a.x = 5));
Re: Error: Outside Unicode code space
On Friday, 9 July 2021 at 03:32:31 UTC, Adam D Ruppe wrote: On Friday, 9 July 2021 at 03:09:52 UTC, Tony wrote: The editor I am using (Code::Blocks) displays the characters just fine. So it seems that the error message should be "Error: Outside the ASCII code space". D supports stuff outside the ASCII code space just fine. Are you sure the file is saved as utf 8? if it is something like Windows 1252 it can still often be displayed but dmd won't know what to make of it. When I checked "Settings->Editor...->Encoding Settings" it was set to WINDOWS-1252. Changing it to UTF-8 fixed the issue. Thanks!
Error: Outside Unicode code space
I copied some text from a web page into a comment and I get the error "Error: Outside Unicode code space". This appears to be an incorrect error message. It is upset about double quotes that lean forward or backwards, and apostrophes that lean backwards. And dashes that aren't the keyboard dash character. The editor I am using (Code::Blocks) displays the characters just fine. So it seems that the error message should be "Error: Outside the ASCII code space".
Re: ChromeOS and DLang
On Thursday, 27 May 2021 at 19:39:15 UTC, Ozan Sueel wrote: Hi I think about writing apps vor ChromeOS, but before running in a death end, I ask by myself, is D a good choice for this approach? Any experience with this new upcoming operating system? New and upcoming? ChromeOS was first released 10 years ago. Are they adding something different to it?
Re: ugly and/or useless features in the language.
On Saturday, 15 May 2021 at 21:15:01 UTC, Ola Fosheim Grostad wrote: On Saturday, 15 May 2021 at 14:31:08 UTC, Alain De Vos wrote: In general it is better to have fewer features and instead improve metaprogramming so that missing features can be done in a library. Why is metaprogramming added features better than the same features added in the language? One is standard between entities, the other is not.
Re: DConf talk : Exceptions will disappear in the future?
On Tuesday, 5 January 2021 at 18:42:42 UTC, Marvin wrote: On Monday, 4 January 2021 at 15:39:50 UTC, ludo456 wrote: Listening to the first visioconf of the Dconf 2020, titled Destroy All Memory Corruption, (https://www.youtube.com/watch?v=XQHAIglE9CU) Walter talks about not using exceptions any more in the future. He says something like "this is where languages are going" [towards no using exceptions any more]. Can someone point me to an article or more explanations about that? if Exceptions disappear in the future in Dlang, I will download the last version that support exceptions and never update. I have a similar feeling. Exceptions were a great addition to programming languages in my opinion.
Re: Hunt Framework 3.0.0 Released, Web Framework for DLang!
On Wednesday, 6 May 2020 at 22:28:28 UTC, Dukc wrote: On Friday, 1 May 2020 at 10:54:55 UTC, zoujiaqing wrote: [snip] Thanks, but: Some of the files have Apache license, but some have none. I think you should add a license to the whole repository that would cover those files that don't have their own. This library has potential license issues as it has many files, at least on the core section that come from OpenJDK. Even the Java specific comments have been left I, such as this in AbstractCollection.d . The OpenJDK is GPL with static linking exception. It probably isn't kosher to take those files and make them Apache 2.0, even with modifications. This class is a member of the * href="{@docRoot}/java/util/package-summary.html#CollectionsFramework"> * Java Collections Framework
Re: Pro programmer
On Sunday, 25 August 2019 at 21:30:10 UTC, GreatSam4sure wrote: I am wondering as to what is the starting point of being a pro programmer. If I want to be a pro programmer what language must I start with? Most pro programmer I have heard of are all C and C++ Guru. Most of the best guys on this D forum falls into that category. I really want to know programming to the core not just tied to a language or just at the level of drag and drop or use a framework or library. I will appreciate your help in this matter. I am ready to put in hard work. I ready know a little of java, actionscrip 3.0, kotlin, D but at the surface level but can use them to write app. But I am concern with matter like how can I write a GUI toolkit from the ground up. When you say "pro programmer" are you referring to someone who programs for a living for a company, or a "top notch/very good programmer" ?
Re: Help me decide D or C
On Wednesday, 31 July 2019 at 22:30:52 UTC, Alexandre wrote: My goals: 1) Improve as a programmer 2) Have fun doing programs That's it basically. I am planning to study all "free" time I have. I am doing basically this since last year. Are you only considering D and C or just mentioning them in this forum? The interpreted dynamically-typed languages like Python are considered easier to use and have the largest amount of functionality in their libraries. If it is just down to D or C, then definitely D. C would be at or near the bottom in terms of a language to have fun doing general programming and learning.
Re: Singleton in Action?
On Saturday, 2 February 2019 at 16:56:45 UTC, Ron Tarrant wrote: So, my big question is, do I instantiate like this: DSingleton singleton = new DSingleton; Or like this: DSingleton singleton = singleton.get(); And subsequent calls would be...? The same? Using get() only? This seems to be a case where D's definition of "private" can cause confusion versus examples from other languages with private as "access only inside the class". In other languages DSingleton singleton = new DSingleton; would never compile (the desired behavior), since the constructor is private. But D allows it in some cases due to "private to class OR module". If DSingleton is in the same module, as for example in a small test program with DSingleton and main() in the same file, then it compiles. So I think your code is fine, it's just that it can be circumvented - the private constructor can be called - if DSingledton and the instantiating code are in the same module.
Re: My Meeting C++ Keynote video is now available
On Sunday, 13 January 2019 at 04:04:14 UTC, Walter Bright wrote: One major takeaway is that the bugs/line are the same regardless of the language used. This means that languages that enable more expression in fewer lines of code result in fewer bugs for the same functionality. Is the data to support this conclusion freely available on the web somewhere? My impression is that Python is considered the easiest language to use. If it has no more bugs per line than a statically typed program that seems to suggest that non-speed-critical work should be done in Python.
Re: Why does nobody seem to think that `null` is a serious problem in D?
On Saturday, 1 December 2018 at 19:02:54 UTC, H. S. Teoh wrote: But that's precisely the problem. It's not always possible to tell whether a variable has been initialized. E.g.: To me, the possibility of a "false positive" doesn't preclude the use of a warning unless that possibility is large. Besides using a compiler option or pragma to get rid of it, the warning also goes away if you assign NULL or (X *) 0. Surprisingly, clang (gcc 6.3 does not give the warning) is not smart enough to then issue a "possibly dereferencing null pointer" warning. Therefore, leaving it up to the compiler to detect uninitialized variables is unreliable, and therefore any code that depends on this cannot be trusted. Code like the above could be exploited by a sufficiently sophisticated hack to make the uninitialized value of p coincide with something that will open a security hole, and the compiler would not be able to reliably warn the programmer of this problem. I don't know that "leaving it up to the compiler" is a correct characterization. I don't see the programmer doing anything different with the warning capability in the compiler than if it wasn't there. In either case, the programmer will attempt to supply values to all the variables they have declared and are intending to use, and in the correct order.
Re: Why does nobody seem to think that `null` is a serious problem in D?
On Saturday, 1 December 2018 at 11:16:49 UTC, Dukc wrote: This is great when it works, but the problem is that it would be gargantuan effort -and compile time sink- to make it work perfectly. When it's just about if-else if chains, switches or boolean logic as in the example, the analysis won't be too complicated. But swap those booleans out for a string, and make the conditions to test whether it's a phone number, and whether it satisfies some predicate implemented in a foreign language, and you'll see where the problem is. I think he is just talking about the compiler or static analyzer seeing if a variable has been given a value before it is used, not if it was given a valid value.
Re: Why does nobody seem to think that `null` is a serious problem in D?
isocpp.org just had a link to a blog post where someone makes a case for uninitialized variables in C++ being an advantage in that you can potentially get a warning regarding use of an uninitialized variable that points out an error in your code. https://akrzemi1.wordpress.com/2018/11/22/treating-symptoms-instead-of-the-cause/
Re: D is supposed to compile fast.
On Sunday, 25 November 2018 at 22:00:21 UTC, Chris Katko wrote: On Saturday, 24 November 2018 at 20:44:57 UTC, welkam wrote: On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote: D is supposed to compile fast. You didnt read the fine print. It compiles simple code fast. Also compilation is separate step from linking and your program might spend half of "compilation" time in link phase. Wait wait wait wait wait. So 1) I have to compile manually, then link. Except that also runs the files every time even if they're up-to-date. Is that normal behavior for C/C++? "runs the files every time"? If that means "compiles the files every time", then no. D works exactly like C/C++ - you only need to compile-to-object-code source files in the project that have changed since the last time they were compiled.
D Language 2.1
From std.compiler.D_major and std.compiler.D_minor I see that my D language version is at 2.0 . But the version of gdc front-end I am using (via Debian default gdc package as of a few months ago) from std.compiler.version_major and std.compiler.version_minor is at 2.68 . That is a lot of bug fixes, with 0 changes to the language. Actually, I realize that changes to the language are being reflected in compiler versions, not language versions. Just wondering why it was decided not to version the language (2.1, 2.2, etc.)
version(StdDoc)
In std.compiler there is this code: /// Which vendor produced this compiler. version(StdDdoc) Vendor vendor; else version(DigitalMars) Vendor vendor = Vendor.digitalMars; else version(GNU) Vendor vendor = Vendor.gnu; else version(LDC) Vendor vendor = Vendor.llvm; else version(D_NET) Vendor vendor = Vendor.dotNET; else version(SDC) Vendor vendor = Vendor.sdc; else Vendor vendor = Vendor.unknown; What is the situation in which the identifier StdDoc is set?
Re: Who can stop it ? Help me,thank you.
On Wednesday, 17 October 2018 at 14:06:49 UTC, FrankLike wrote: Where can get the new dmd or ldc2 that's no 'Trojan horse virus' ? https://dlang.org/download.html
Re: You don't like GC? Do you?
On Monday, 15 October 2018 at 08:21:11 UTC, Eugene Wissner wrote: On Monday, 15 October 2018 at 05:26:56 UTC, Tony wrote: Ideally you wouldn’t have chosen to even try D. You (and others who spend so much time arguing against garbage collection on a forum for a language designed with garbage collection) would be better off using a non-garbage collected language. He doesn't argue against garbage collection. Well, can you state what he does argue against? And D is one of the few languages that can be used without garbage collection, so it can be a non-garbage collected language and can be used as such. Wouldn't C++ or Rust, with their smart pointers, be a better choice for someone who wants to use a compiles-to-object-code language, but can't suffer any garbage collector delays?
Re: You don't like GC? Do you?
On Sunday, 14 October 2018 at 07:51:09 UTC, Stanislav Blinov wrote: That's a lamest excuse if I ever seen one. If you can't be bothered to acquire one of the most relevant skills for writing code for modern systems, then: a) Ideally, you shouldn't be writing code b) At the very least, you're not qualified to give any advice pertaining to writing code PS. "Correctness" also includes correct use of the machine and it's resources. Ideally you wouldn’t have chosen to even try D. You (and others who spend so much time arguing against garbage collection on a forum for a language designed with garbage collection) would be better off using a non-garbage collected language.
Re: Engine of forum
On Monday, 20 August 2018 at 09:52:01 UTC, Peter Alexander wrote: On Monday, 20 August 2018 at 08:39:38 UTC, Andrey wrote: On Sunday, 19 August 2018 at 11:11:56 UTC, rikki cattermole wrote: This is a news group not a forum. The web interface is driven by DFeed and is written in D. It has been designed to be very fast (quite a notable feature). I see this address: https://forum.dlang.org. It is forum. Ok, even if it isn't a forum, will dlang community have someday the real forum? Are there any movements in this direction? What are the specific problems solved or opportunities realised by moving to a real forum? Inability to edit messages.
Re: Why is it hard to make Qt bindings?
On Thursday, 5 July 2018 at 12:52:49 UTC, Steven Schveighoffer wrote: On 7/5/18 4:42 AM, drug wrote: There were several attempts to make Qt binding for dlang, but either they has failed or has been stalled. It would be nice to collect that experience. Considering 2.081 supports C++ special member (not all but majority) isn't it time to make another attempt or the problem is more complex? Could you publish your experience in making Qt bindings here? I'm not a Qt user, but doesn't Qt require a special pre-compiler, or even use the preprocessor in a way that is difficult to duplicate in D? Qt does have it's own pre-processor, but CopperSpice, a fork of Qt does not require that. http://www.copperspice.com/
Re: DVM - D Version Manager 0.4.4
On Wednesday, 4 July 2018 at 19:14:57 UTC, Jacob Carlborg wrote: On 2018-07-03 03:34, Tony wrote: Thanks, that worked! It doesn't announce where it put the compiler, which turns out to be: C:\Users\\AppData\Roaming\dvm\ You're not supposed to know where it puts the compiler. You're activating it with "dvm use " where "" is the version you want to activate. This will persist for the end of the shell session. To set a default compiler use "dvm use -d". This allows to use separate versions simultaneously in different shell sessions. See the usage information [1]. [1] https://github.com/jacob-carlborg/dvm#use-a-compiler I should have done a little more reading. Thanks, and thanks for writing it!
Re: DVM - D Version Manager 0.4.4
On Monday, 2 July 2018 at 18:31:50 UTC, Steven Schveighoffer wrote: I still use dvm (this version 0.4.4 is the latest I believe). It still works, at least on OSX. But the errors it throws are not very user friendly, most of the time you get a stack trace. I've never used the --latest switch (which BTW fails on OSX as well). Likely it's a change in how the metadata is stored on the server. Just install by name: dvm install 2.080.1 Thanks, that worked! It doesn't announce where it put the compiler, which turns out to be: C:\Users\\AppData\Roaming\dvm\
Re: DVM - D Version Manager 0.4.4
On Monday, 2 July 2018 at 07:12:47 UTC, Basile B. wrote: On Monday, 2 July 2018 at 06:21:53 UTC, Tony wrote: On Sunday, 13 September 2015 at 16:26:04 UTC, Jacob Carlborg wrote: I just released a new version of DVM, 0.4.4. The most important I am on Windows 10. Is: dvm --latest install a valid way to get the latest dmd? When I try that I get an exception Seems unmaintained. Try Cybershadow's Digger which can handle building several versions of DMD too (https://github.com/CyberShadow/Digger), even from locally served webpage as UI. OK, thanks! I saw DVM mentioned in a thread recently and I went back and couldn't find it and found this one via a search. The one I saw may have been a very old thread that someone revived.
Re: DVM - D Version Manager 0.4.4
On Sunday, 13 September 2015 at 16:26:04 UTC, Jacob Carlborg wrote: I just released a new version of DVM, 0.4.4. The most important I am on Windows 10. Is: dvm --latest install a valid way to get the latest dmd? When I try that I get an exception -- dvm --latest install An unknown error occurred: tango.core.Exception.IOException@C:\Users\doob\AppData\Roaming\dub\packages\tango-1.0.1_2.067\tango\core\Exception.d(59): truncated response 0x004421D4 0x00441ECD 0x00441688 0x0040A637 0x0040A4F5 0x004334EA 0x0044FC5B 0x0044FB71 0x004021E8 0x769B8484 in BaseThreadInitThunk 0x77252FEA in RtlValidSecurityDescriptor 0x77252FBA in RtlValidSecurityDescriptor
Re: How an Engineering Company Chose to Migrate to D
On Friday, 22 June 2018 at 02:45:06 UTC, Tony wrote: On Wednesday, 20 June 2018 at 18:21:01 UTC, Bastiaan Veelo wrote: On Wednesday, 20 June 2018 at 16:06:15 UTC, Ali wrote: On Wednesday, 20 June 2018 at 13:21:30 UTC, Mike Parker wrote: The blog: https://dlang.org/blog/2018/06/20/how-an-engineering-company-chose-to-migrate-to-d/ Reddit: https://www.reddit.com/r/programming/comments/8si75b/how_an_engineering_company_chose_to_migrate_to_d/ number 1 on hn https://news.ycombinator.com/item?id=17355348 OMG how am I to respond to all the comments, I cannot see the end of it! Who produces the Extended Pascal compiler you have been using? Oops, never mind. Read the article and see it's Prospero Software.
Re: How an Engineering Company Chose to Migrate to D
On Wednesday, 20 June 2018 at 18:21:01 UTC, Bastiaan Veelo wrote: On Wednesday, 20 June 2018 at 16:06:15 UTC, Ali wrote: On Wednesday, 20 June 2018 at 13:21:30 UTC, Mike Parker wrote: The blog: https://dlang.org/blog/2018/06/20/how-an-engineering-company-chose-to-migrate-to-d/ Reddit: https://www.reddit.com/r/programming/comments/8si75b/how_an_engineering_company_chose_to_migrate_to_d/ number 1 on hn https://news.ycombinator.com/item?id=17355348 OMG how am I to respond to all the comments, I cannot see the end of it! Who produces the Extended Pascal compiler you have been using?
Re: D only has Advantages
On Friday, 15 June 2018 at 04:52:20 UTC, Joakim wrote: Search this forum or HN for Paulo and Oberon, you'll find plenty of posts like this, where he lists all of them: :) https://forum.dlang.org/post/mioycakymbdpzryme...@forum.dlang.org Oops, I forgot that Go was garbage collected.
Re: D only has Advantages
On Friday, 15 June 2018 at 02:17:26 UTC, Adam D. Ruppe wrote: On Friday, 15 June 2018 at 02:02:52 UTC, Tony wrote: Have their been other languages - besides D - that compiled to object code and used a garbage collector? You can use a GC with C++ and you can compile Java to native code ahead of time. The distinctions aren't really that sharp, it just depends on how you use it. After I posted I wanted to edit it to add "disregarding JIT in conjunction with a VM like JVM or .NET". Have there been any C++ compilers that used a garbage collector? What I was getting at was, if someone says "I've got a systems level project I want to play around with, however GC is not a deal breaker for me. ", it seems like they are making an implied reference to D as I assume "systems level" means "compile to object code and link with linker to executable".
Re: D only has Advantages
"I've got a systems level project I want to play around with, however GC is not a deal breaker for me. " https://news.ycombinator.com/item?id=17302719 Oberon-2 has had some versions that used a garbage collector. Have their been other languages - besides D - that compiled to object code and used a garbage collector?
Re: Remember the Vasa! by Bjarne Stroustrup
With regard to having, say, a GUI written with garbage collection, and then needing to have non-garbage collected code to process audio, could that not be done with GC D calling C? And, if there was a garbage-collected D (D for Applications) and a non-GC D (D for Systems Programming), couldn't one be linked with the other? And before you say "but it should all be together coming out of one compiler" - take a moment to Remember the Vasa! I don't seriously expect two D-ish compilers, but it does seem to make more sense with regard to adding automatic reference counting to a language that already has garbage collection, as well as working to remove garbage collection from the standard library. Presumably at the beginning and for much of D's history, garbage collection was a premier selling point, along with OOP. But with regard to various compile-time stuff and function annotations and other things that didn't exist years ago, has that resulted in noticeably faster programming and/or noticeably higher code quality by those utilizing it?
Re: Remember the Vasa! by Bjarne Stroustrup
On Tuesday, 29 May 2018 at 20:19:09 UTC, bachmeier wrote: I don't think it's difficult to do that yourself. There's no need to have a formal split. One example is that it's really nice to have the GC available for part of the program and avoid it for another part. @nogc gives you a guarantee. Different variants of the language are a special case of this that is equivalent to annotating the entire program to restrict behavior. That's rarely desirable. What would be an example of a type of application (or maybe that should be "which type of domain" or "which type of developer") where you would want part of it to do garbage collection and the rest of it do not do garbage collection?
Re: Remember the Vasa! by Bjarne Stroustrup
On Tuesday, 29 May 2018 at 11:31:53 UTC, Guillaume Piolat wrote: On Tuesday, 29 May 2018 at 05:11:27 UTC, Dmitry Olshansky wrote: D is probably at the edge of what I can tollerate complexity-wise. And we’ll get to simplify a few things soon I believe. Within D, there is a bit smaller and cleaner language struggling to get out! Seems like it could be broken into two languages, one a garbage collected object-oriented language. The other, C with metaprogramming and other "betterC" type stuff.
Re: On Forum Moderation
On Saturday, 26 May 2018 at 12:06:13 UTC, Mike Parker wrote: On Saturday, 26 May 2018 at 11:30:24 UTC, Tony wrote: On Saturday, 26 May 2018 at 11:12:29 UTC, Rubn wrote: What about self moderation? If I make an unprofessional comment and want to delete it? Will this be allowed now? I guess it's more of a feature request. The lack of an edit feature has been brought up before and it was said that it doesn't exist because the forum is combined with an email mailing list. The authoratative database is an NNTP server. The mailing list is an interface to that, and so is the forum (though it maintains its own copy of the DB). Are you saying the forum could have an edit feature?
Re: On Forum Moderation
On Saturday, 26 May 2018 at 11:12:29 UTC, Rubn wrote: What about self moderation? If I make an unprofessional comment and want to delete it? Will this be allowed now? I guess it's more of a feature request. The lack of an edit feature has been brought up before and it was said that it doesn't exist because the forum is combined with an email mailing list.
Re: Sealed classes - would you want them in D?
On Friday, 11 May 2018 at 03:32:25 UTC, Uknown wrote: Also, classes are pretty inconvenient because they are hard to use without the GC. I find it surprising that a language that had Garbage Collection as one of its' key features, now has that feature looked at as an inconvenience. Was it a design error, or did the wrong class of users latch onto the language?
Re: Passing directory as compiler argument not finding file
On Friday, 13 April 2018 at 12:46:32 UTC, Cym13 wrote: On Friday, 13 April 2018 at 01:27:06 UTC, Tony wrote: I think that the typical model (at least in other languages) is to only compile one D source file at a time. Compile the b.d file with the -c option to create an object file. Then put the object file in a library file (either static (easier) or dynamic). Then you can use the -L compiler option to specify the directory of the library and the -l compiler option to specify the library (library name is shortened - libb.a referenced as -lb). Regardless of whether that would work or not this is the opposite of what's recommended in D. D compilers expect you to compile everything at once, or at least by module. That's where it works best when it comes to optimizations etc. What does "or at least by module" mean? Is it possible to have a module that is made up of more than one source file? What information does a D compiler get when you stick a.d and b.d on the command line that it doesn't get if you compile a.d and import b.d ?
Re: Passing directory as compiler argument not finding file
On Thursday, 12 April 2018 at 07:48:28 UTC, Jamie wrote: Really, it's more like: A/ a.d module A.a; import std.stdio; import B.b; void main() { writeln(f(4)); } B/ b.d module B.b; size_t f(size_t input) { return input * 2; } And in A/ I'm compiling dmd -ofoutput a.d ../B/b.d and instead I was thinking I could compile with dmd -ofoutput a.d -I../B b.d and would get the same result. The former works, the latter does not. Is there something like this that I can use or do I have to pass all the files with the direct path to them? Thanks I think that the typical model (at least in other languages) is to only compile one D source file at a time. Compile the b.d file with the -c option to create an object file. Then put the object file in a library file (either static (easier) or dynamic). Then you can use the -L compiler option to specify the directory of the library and the -l compiler option to specify the library (library name is shortened - libb.a referenced as -lb).
Re: Passing directory as compiler argument not finding file
On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: Am I using the -I compiler option incorrectly? I believe so. I think it is for finding import files, not the files you are compiling. - -I=directory Look for imports also in directory
Re: Is it a bug that a parent class that access its own private members from derived classes gets deprecation warning?
On Saturday, 7 April 2018 at 20:14:49 UTC, bauss wrote: The above in my case will give a deprecation warning that "_baz" isn't visible from "Bar". Seems like a bug to me since I'm accessing "_baz" from "Foo" itself and not from "Bar" or is it by design that you can't do such thing. I would say that you are accessing it from Bar. Or maybe that should be "via Bar". You are in Foo, but with a reference to a Bar instance. And trying to get to the _baz that is in that Bar instance. But your design doesn't allow (or at least I would have thought it was an error, not warning) or want Bar objects to be able to access _baz.
Re: Need a fancy domain for your project? .dub.pm has you covered!
Not a big deal since the same table is on code.dlang.org, but on the https://dub.pm/index.htm table, the headings "Name", "Registered" and "Score" are all active links, but the sort is not currently working.
Re: Why think unit tests should be in their own source code hierarchy instead of side-by-side
On Saturday, 24 March 2018 at 01:15:46 UTC, Jonathan M Davis wrote A number of us have nothing good to say about TDD. That's fine. That's why they have menus in restaurants. But saying it is an inferior method is different than saying it won't work or can't be used in a maintenance situation. On Saturday, 24 March 2018 at 01:15:46 UTC, Jonathan M Davis wrote: But as far as whether or not it can be done with maintenance code, my original reply that mentioned it was to someone who appeared to be talking about a new project not getting everything tested, not a maintenance project. So saying "can't do it for maintenance" doesn't even apply to my reply. You were replying to H. S. Teoh talking about adding tests to an existing project, in which case, it's very much about maintenance. I said my "original reply", meaning the one where I first mentioned Test-Driven Development. That was to something that Steven Schveighoffer said (although I did not reply directly to his message, but replied to his comment that was still in H.S. Teoh's message): "I've worked on a project where the testing was separated from the code, and it was a liability IMO. Things would get missed and not tested properly." He doesn't explicitly specify development or maintenance, but I assume it was development.
Re: Why think unit tests should be in their own source code hierarchy instead of side-by-side
On Saturday, 24 March 2018 at 00:12:23 UTC, Jonathan M Davis wrote: On Friday, March 23, 2018 22:42:34 Tony via Digitalmars-d-announce wrote: On Friday, 23 March 2018 at 22:32:50 UTC, H. S. Teoh wrote: > On Fri, Mar 23, 2018 at 09:45:33PM +0000, Tony via > > Digitalmars-d-announce wrote: >> On Friday, 23 March 2018 at 20:43:15 UTC, H. S. Teoh wrote: >> > On Friday, 23 March 2018 at 19:56:03 UTC, Steven >> > >> > Schveighoffer wrote: >> > > I've worked on a project where the testing was separated >> > > from the code, and it was a liability IMO. Things would >> > > get missed and not tested properly. >> >> That's where Test Driven Development comes in. > > That's not an option when you have an existing codebase that > you have to work with. You basically have to start out with > tons of code and no tests, and incrementally add them. > Having to also maintain a separate test tree mirroring the > source tree is simply far too much overhead to be worth the > effort. I think that you could "Test Driven Develop" the code you are adding or changing. Insisting on writing the tests before writing the code doesn't help with the kind of situation that H. S. Teoh is describing. And arguably it exacerbates the problem. Regardless, it doesn't help when the code has already been written. I don't see how it exacerbates it and I don't see how it doesn't help. The point of Test-Driven Development it to make sure you have written a test for all your code. You can also do test-driven development in unittest blocks. But as far as whether or not it can be done with maintenance code, my original reply that mentioned it was to someone who appeared to be talking about a new project not getting everything tested, not a maintenance project. So saying "can't do it for maintenance" doesn't even apply to my reply.
Re: Why think unit tests should be in their own source code hierarchy instead of side-by-side
On Friday, 23 March 2018 at 22:32:50 UTC, H. S. Teoh wrote: On Fri, Mar 23, 2018 at 09:45:33PM +, Tony via Digitalmars-d-announce wrote: On Friday, 23 March 2018 at 20:43:15 UTC, H. S. Teoh wrote: > On Friday, 23 March 2018 at 19:56:03 UTC, Steven > Schveighoffer wrote: > > I've worked on a project where the testing was separated > > from the code, and it was a liability IMO. Things would > > get missed and not tested properly. That's where Test Driven Development comes in. That's not an option when you have an existing codebase that you have to work with. You basically have to start out with tons of code and no tests, and incrementally add them. Having to also maintain a separate test tree mirroring the source tree is simply far too much overhead to be worth the effort. I think that you could "Test Driven Develop" the code you are adding or changing.
Re: Why think unit tests should be in their own source code hierarchy instead of side-by-side
On Friday, 23 March 2018 at 20:43:15 UTC, H. S. Teoh wrote: I've worked on a project where the testing was separated from the code, and it was a liability IMO. Things would get missed and not tested properly. That's where Test Driven Development comes in. Yep. As I mentioned elsewhere, recently I've had to resort to external testing for one of my projects, and I'm still working on that right now. And already, I'm seeing a liability: rather than quickly locating a unittest immediately following a particular function, now I have to remember "oh which subdirectory was it that the tests were put in? and which file was it that a particular test of this function was done?". It's an additional mental burden to have to keep doing the mapping between current source location <-> test code location (even if it's a 1-to-1 mapping), and a physical burden to have to continually open external files (and typing a potentially long path for them) rather than just "bookmark, jump to end of function, navigate unittest blocks" in the same file. There are pluses and minuses to both approaches, but I don't think that a separate file approach is as difficult as you are suggesting. The naming is typically identical to the project entities being tested, with a prefix like "Test_" tacked onto the front of the project, modules, classes and functions, making finding things straightforward. And most modern editors/IDEs will allow multiple files and projects to be open at the same time, allowing test code to be opened only once per coding session.
Re: Why think unit tests should be in their own source code hierarchy instead of side-by-side
I think unittest blocks are good for write-once and quick-and-dirty projects, or as a first-cut of testing that ultimately gets moved to a full-grown test suite in a separate project. I'd prefer not to read source code that has unittest blocks inter-mixed with the actual code.
Re: does it scale to have 1 person approve of all phobos additions?
I have never used DUB, but as I understand it, it will automatically bring down modules that are stored in gitub or two other git hosts (but not SourceForge for some reason). With that kind of functionality, it seems that inclusion in the standard library becomes much less important for a library. Rather than being included into Phobos, modules could be sanctioned/blessed in some fashion by dlang.org beyond their inclusion at code.dlang.org . Such as having their documentation on dlang.org (or wiki.dlang.org with a link to the wiki page on a dlang.org page that is for listing "sanctioned modules" or "semi-official modules").
Downloads page
The downloads page is a little corrupted: https://dlang.org/download.html
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: The D Language Foundation at Open Collective
On Monday, 19 March 2018 at 03:12:52 UTC, Nick Sabalausky (Abscissa) wrote: (And McDonalds $1/large thing seems to have gone away, I think it was just a temporary promotion. At least around here, anyway (Cleveland area, in the US)). Still doing it in the Northern California McDonalds near me. $1 for a large soda too. I'll never understand the whole "pour over" coffee movement. There is a coffee chain that started in San Francisco, Philz Coffee, which specializes in pour over coffee, and is now up to 42 locations. It is popular, and pour over and popular means an excellent chance you end up waiting in a significant line, but a lot of people don't seem to mind. I even wonder if it adds to the experience, making the product seem more valuable. However, someone must not like the wait because I read an article recently that mentioned some upscale coffee places were going back to using machines. I believe they only mentioned the time factor, but it is also labor intensive to manually pour the water.
Re: The D Language Foundation at Open Collective
On Sunday, 18 March 2018 at 20:18:45 UTC, Tony wrote: I have seen regular coffee at $4.50 and as high as $5.50 in the USA (and not always a large), I believe they currently have a $5.50 pour over, but this undated third-party hosted menu for Voltaire Coffee House in San Jose, CA shows "pour over" cups of coffee from $4 to $5: http://places.singleplatform.com/voltaire-coffee-house/menu
Re: how to make private class member private
On Sunday, 18 March 2018 at 18:04:13 UTC, Tony wrote: On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote: D is not C++, C#, or Java. C++ uses friend to get around the issue. Java has no solution. I don't know about C#. Java has four protection levels. If you don't explicitly specify [private, protected, public] the protection level is implicitly "package-private". That means that any class in the same package can access that attribute. I believe that Java packages are identical to D packages. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/accessibility-levels C# has 6 accessibility levels: public - Access is not restricted. protected - Access is limited to the containing class or types derived from the containing class. private - Access is limited to the containing type. internal - Access is limited to the current assembly. protected internal - Access is limited to the current assembly or types derived from the containing class. private protected - Access is limited to the containing class or types derived from the containing class within the current assembly. Available since C# 7.2. What is a C# Assembly? Someone says on a forum: "An assembly is a "unit of deployment" for .NET, almost always a .exe or .dll. In C# terms, it's basically a single C# project." And also refers to https://social.msdn.microsoft.com/Forums/en-US/088ce8ed-ef9b-4dea-88b3-ca016885e26d/what-is-an-assembly-in-terms-of-c?forum=csharplanguage which says: "Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly."
Re: The D Language Foundation at Open Collective
On Thursday, 15 March 2018 at 12:36:24 UTC, Meta wrote: 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. I have seen regular coffee at $4.50 and as high as $5.50 in the USA (and not always a large), but in order to get there, it has to be "single cup pour over" made, as opposed to coming out of a machine into a pot. And the beans have to be organic or they are telling you exactly where they were grown and giving you alleged "flavor notes" and maybe they roasted them in-house or locally, and the place has to have an upscale or luxury vibe. But Starbucks in the USA gives you a 20oz out-of-a-machine for under $3. McDonald's beats everybody - $1 for a large. Although I am not a big fan of the McDonalds coffee (maybe psychological due to the low price). 7/11 convenience stores and Chevron gas stations both have several varieties of coffee on tap that they sell for under $2 for a large, that I think tastes good.
Re: how to make private class member private
On Sunday, 18 March 2018 at 18:32:42 UTC, Jonathan M Davis wrote: They're similar, but there are differences. For instance, you can do package(a) in D in order to do something like put the stuff in a.b.c in package a rather than a.b. Is there a known situation where it makes sense to put module c in directory/package b - rather than directory/package a, and then tell the D compiler to treat it like it was in directory/package a?
Re: how to make private class member private
On Tuesday, 13 March 2018 at 06:03:11 UTC, Mike Parker wrote: D is not C++, C#, or Java. C++ uses friend to get around the issue. Java has no solution. I don't know about C#. Java has four protection levels. If you don't explicitly specify [private, protected, public] the protection level is implicitly "package-private". That means that any class in the same package can access that attribute. I believe that Java packages are identical to D packages.
Re: Vision document for H1 2018
On Friday, 16 March 2018 at 15:04:21 UTC, Kagamin wrote: On Thursday, 15 March 2018 at 16:03:14 UTC, rumbu wrote: Are you sure that you are talking about phobos and not tango? :) I'm eager to find how I'm uninformed. Tango doesn't use UFCS, while phobos and .net framework are big on extension methods. Also tango uses object oriented console IO, while phobos and .net framework use procedural style for it. I thought C# was like Java and does not allow free procedures. Can you give an example of C# procedural-style IO?
Re: How to simplify nested ifs
On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote: if (source?pool?repository?directory?users) // do something That type of chain is sometimes referred to as a "train wreck" (see Law of Demeter). If this is a common lookup it could be: if (source && source.GotSomeUsers() )
Re: Do forum posts use any markup language?
On Saturday, 10 March 2018 at 18:02:48 UTC, Bogdan wrote: I'd like to distinguish between regular text and code, maybe have quotes, etc. A poster has come up with a standard way to delineate code and also show if multiple files are involved (along with an "extraction to files" program): https://forum.dlang.org/thread/ndgdqraxjkuvfsjhe...@forum.dlang.org This method now works at https://run.dlang.io
Re: UDK : Comment sont levés les "Mappable keys"
On Monday, 5 March 2018 at 02:12:07 UTC, Adam Levine wrote: Bonjour à tous Alors voilà, quelqu'un saurait-il comment sont levé les évènements des touches appuyées pour UDK? Nous voudrions pouvoir utiliser un nouveau périphérique autre que la souris, le clavier ... : En l’occurrence la Kinect. Nous avons développé notre API qui permet d'exploiter la kinect en c++. Nous l'avons intégré dans UDK en unrealscript, cependant on voudrait pouvoir lever un évènement lorsque l'on détecte un geste. On voudrait donc faire le binding de nos geste avec une commande UDK et réussir à lever nos évènements qui exécuterons les commandes prédéfinis. Par exemple : Bindings=(Name="BrasEnAvant",Command="StartFire | onrelease StopFire") Comment lever l'évènement "BrasEnAvant" ? Merci d'avance Bing translate seemed to a better than normal job on this: Hi all So, would anyone know how the events of the keys pressed for UDK are lifted? We would like to be able to use a new device other than the mouse, the keyboard...: In this case the Kinect. We have developed our API that allows the use of Kinect in C++. We have integrated it into UDK in UnrealScript, however we would like to be able to raise an event when we detect a gesture. So we would like to do the binding of our gestures with a UDK command and succeed in lifting our events that will execute the predefined commands. Like what: Bindings = (Name = "BrasEnAvant ", Command = "StartFire | onrelease StopFire ") How to raise the event "BrasEnAvant "? Thanks in advance
Re: Annotation of functions
On Tuesday, 20 February 2018 at 12:15:57 UTC, psychoticRabbit wrote: I've noticed that Go and Rust annotate functions. func (in go) fn (in rust) I was kind of wondering why they made that choice, given compilers in many languages do not. On Tuesday, 20 February 2018 at 12:15:57 UTC, psychoticRabbit wrote: I've noticed that Go and Rust annotate functions. func (in go) fn (in rust) I was kind of wondering why they made that choice, given compilers in many languages do not. I think it is common to have a keyword used in function definition - outside the C-family. The Pascal family has keywords for function and procedure declaration, as does Fortran. It looks like Cobol uses the "function" keyword for when you call a function and "function-id" for when you define it. Perl, Python and Ruby all have a keyword for function definition. Would this be a useful feature in D? Everything else seems to have an annotation (e.g structs, classes.) So why not functions? What are people's thoughts about it? I think keywords for functions may be to avoid or minimize the difficulty C and C++ have with declaring (and deciphering the declarations of) function pointers. Seems it also would have prevented years of C++ having "the most vexing parse", where a class instantiation can be confused with a function declaration.
Re: -libpath?
On Wednesday, 21 February 2018 at 10:23:08 UTC, Tony wrote: There is a tool that lets you call GDC and use DMD command-line options (gdmd). If it doesn't already exist, what about a tool that allows you to call DMD using GDC options (which I think are the same as gcc/g++/clang/clang++)? I am mainly thinking about being about to do -L/the/path/to/abc and -labc as is done for the Linux C/C++ compilers.
Re: -libpath?
On Wednesday, 21 February 2018 at 02:21:14 UTC, Jonathan Marler wrote: If we added a new "linker-independent" flag to dmd, then you could add paths using the same interface regardless of which linker you are using. I'd expect the argument to be something like: -libpath= The disadvantage is it would be another command line option added to DMD. If there is general agreement that this is a desirable feature, I'll go ahead and implement it. no one responded to this, but I thought I would bump this to the front page to double check if there is any interest in this feature. There is a tool that lets you call GDC and use DMD command-line options (gdmd). If it doesn't already exist, what about a tool that allows you to call DMD using GDC options (which I think are the same as gcc/g++/clang/clang++)?
Re: std.traits.isBoolean
On Monday, 19 February 2018 at 17:22:04 UTC, Nathan S. wrote: On Monday, 19 February 2018 at 15:12:15 UTC, Tony wrote: But, assuming there is a use case for it, what if you want to restrict to a type that is either boolean, or a struct/class that can substitute for boolean - how do you do that without using the "private" BooleanTypeOf thing? In that case you can just write `is(T : bool)`. Thanks. Assuming it would substitute, that should probably be used on this page in place of BooleanTypeOf since BooleanTypeOf is not supposed to be public: https://dlang.org/library/std/traits/is_boolean.html "enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T;"
Re: std.traits.isBoolean
On Monday, 19 February 2018 at 13:47:15 UTC, Basile B. wrote: Indeed but Phobos maintainers don't want the ...TypeOf family to be documented. (https://github.com/dlang/phobos/pull/5747) Ok, thanks. But, assuming there is a use case for it, what if you want to restrict to a type that is either boolean, or a struct/class that can substitute for boolean - how do you do that without using the "private" TypeOfBoolean thing?
Re: std.traits.isBoolean
On Sunday, 18 February 2018 at 15:12:50 UTC, Mike Parker wrote: Generally, no. But with alias this, it can be: = import std.traits : BooleanTypeOf; import std.stdio : writeln; struct NoBool { int x; } struct AliasThisBool { bool b; alias b this; } void main() { static if(is(BooleanTypeOf!NoBool)) writeln("NoBool"); static if(is(BooleanTypeOf!AliasThisBool)) writeln("AliasThisBool"); } Thanks! It doesn't appear that BooleanTypeof is documented on dlang.org (outside of it's placement on the isBooleanType page). At least it isn't coming up in a "BooleanTypeOf site:dlang.org" search and not on the traits page: https://dlang.org/library/std/traits.html
std.traits.isBoolean
At https://dlang.org/library/std/traits/is_boolean.html it has: enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; per: https://dlang.org/library/std/traits/is_aggregate_type.html isAggregateType is true for [struct, union, class, interface]. So BooleanTypeOf!T is true for structs, unions, classes and interfaces? And if yes, why is that so?
Re: std.zip size limit of 2 GB?
On Thursday, 15 February 2018 at 18:49:55 UTC, Steven Schveighoffer wrote: I think it's inherent in the zlib API. I haven't used all of the library, but the portion I did use (using zstream) uses uint for buffer sizes. Wouldn't using a uint for buffer size give a size limit of greater than 4GB? Seems like an int is in the mix somewhere.
Re: Which language futures make D overcompicated?
On Friday, 9 February 2018 at 19:19:03 UTC, H. S. Teoh wrote: But none of these features are *necessary* to start coding in D. They are optional extras that are nice once you're comfortable with the language. I got by fine for *years* without even using a single mixin, or knowing what 'inout' does, or use any attributes. It's like human language, there's a set of core words ("basic features") that you have to know to hold a conversation, but there's a vast vocabulary of more specialized words ("advanced features") to draw from when you need to be more precise or in special situations. You don't need to know the *entire* language to be functional in it. E.g., there's a vast body of scientific vocabulary that 90% of the general population (of native English speakers) has no idea about. Yet they can live and function in society just fine. But that vocabulary is there when you *do* need it. That's true for writing your own code, but when you look at other code like the standard library and are trying to understand it - if it's written using a plethora of features, then you have to learn a plethora of features. Ali G
Wiki spam
Don't know if there is a better place to report this, but the wiki attracted a spammer: https://wiki.dlang.org/The_Search_Of_Charter_Yacht_Designer https://wiki.dlang.org/User:MichelMeudell
Re: Bootstrap D template
On Friday, 2 February 2018 at 01:16:50 UTC, Seb wrote: `DEFAULT_GOAL` allows to set an explicit target and keep a everything nicely ordered. Thanks! (didn't even notice that line) Is something not working when you just type `make`? No Or are you just trying to understand how things work? Yes, sorry for the confusion. What are you planning to do? I was only trying to understand the Makefile.
Re: Bootstrap D template
On Thursday, 1 February 2018 at 22:01:52 UTC, Mike Wey wrote: https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html#Prerequisite-Types Thanks! Couldn't seem to get a search to work. I was hoping the "|" would explain the behavior that I don't understand, but I don't think it does. The instructions say to just type "make". My understanding is that without a specified target, the topmost target in the Makefile is used. In this case it is "bin", which has no dependencies, and one action - mkdir. I would think that the Makefile would stop after making that directory as no other actions are given and no dependencies were specified. But it doesn't.
Re: Bootstrap D template
On Monday, 29 January 2018 at 11:04:19 UTC, Seb wrote: https://github.com/wilzbach/d-bootstrap Happy bootstrapping! What does "|" do in a makefile?
Re: String Type Usage. String vs DString vs WString
On Monday, 15 January 2018 at 02:09:25 UTC, rikki cattermole wrote: Unicode has three main variants, UTF-8, UTF-16 and UTF-32. The size of a code point is 1, 2 or 4 bytes. I think to be technically correct, 1 (UTF-8), 2 (UTF-16) or 4 (UTF-32) bytes are referred to as "code units" and the size of a code point varies in UTF-8 and UTF-16.
Re: Rvalue references
On Sunday, 14 January 2018 at 00:55:27 UTC, Jonathan M Davis wrote: [...] It the simplest case, it means that the compiler does a bitwise copy rather than a deep copy, but in other cases, it means that the compiler is able to use the object in-place rather than creating a deep copy that it places elsewhere. If you want to know more on the topic, you can always look into C++ move constructors. They were added so that C++ could avoid a lot of unnecessary copies. D took the approach of requiring that structs be moveable (e.g. it's undefined behavior to have a struct contain a pointer to itself), which simplifies things considerably. [...] Thanks!
Re: The name "Phobos" in user-facing docs
I had similar feelings when starting out with D - "why don't they say "standard library" instead of "Phobos"? I don't know that it would change D's image, but I think it would be better for newcomers if they only saw "standard library".
Re: Rvalue references
On Monday, 8 January 2018 at 23:31:27 UTC, Jonathan M Davis wrote: auto foo(T)(auto ref T t) { return t; } foo(42); will result in foo being instantiated as int foo(int t) { return t; } whereas int i; foo(i); will result in foo being instantiated as int foo(ref int t) { return t; } So, by using auto ref, a function can accept both lvalues and rvalues. And in D, rvalues get moved, not copied. What does it mean to "move" a variable/value instead of copying it? Was "auto ref" created for anything besides structs?
DUB and lib curl (-lcurl)
I am on Ubuntu 16.04. I was looking at Getting Started with DUB: http://code.dlang.org/getting_started I did the "dub init myproject" and it worked fine. Then I added dependency: ' dependency "dub" version="~>1.3.0" ' as shown in the next step. This got an error: - dub build Fetching dub 1.3.0 (getting selected version)... Performing "debug" build using dmd for x86_64. dub 1.3.0: building configuration "library"... ../../../.dub/packages/dub-1.3.0/dub/source/dub/internal/sdlang/token.d(26,2): Deprecation: struct core.time.FracSec is deprecated - FracSec has been deprecated in favor of just using Duration for the sake of simplicity ../../../.dub/packages/dub-1.3.0/dub/source/dub/internal/sdlang/token.d(26,2): Deprecation: struct core.time.FracSec is deprecated - FracSec has been deprecated in favor of just using Duration for the sake of simplicity myproject ~master: building configuration "application"... Linking... /usr/bin/ld: cannot find -lcurl collect2: error: ld returned 1 exit status Error: linker exited with status 1 dmd failed with exit code 1. - I am wondering if the tutorial should caution that "you need to have lib curl already on your system", or if I have a bad DUB install (lib curl should have been installed with DUB).
Re: load data from txt file
On Thursday, 4 January 2018 at 05:52:35 UTC, codephantom wrote: On Wednesday, 3 January 2018 at 05:45:32 UTC, Tony wrote: Someone else should know what the correct replacement is for removechars(). the replacement is known as 'programming' ;-) //string trimmed = removechars!string(line,"[\\[\\]\"\n\r]"); string trimmed; foreach(c; line) { if(c != '[' && c != ']' && c != '\"' && c != '\r' && c != '\n' ) trimmed ~= c; } OK, thanks. The removechars() note about deprecation said to use std.regex instead so I have been looking at that and after a struggle did make some use of std.regex.replaceAll. Reminded me of the famous Jamie Zawinski quote: "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. import std.stdio; import std.string; import std.algorithm; import std.regex; import std.file; import std.format : format; void checkLine(string line,long line_number) { // not expecting any whitespace or extra colons. Each line: // ["key":"value"] long colon_pos = std.string.indexOf(line,':'); assert(colon_pos != -1,format("ERROR: no colon on line %s",line_number)); long splitter_string_pos = std.string.indexOf(line,"\":\""); assert(splitter_string_pos != -1, format("ERROR: line %s missing quote(s) adjacent to :",line_number)); assert(line[0..2] == "[\"",format("ERROR: no [\" at line %s start",line_number)); assert(line[line.length - 2 .. line.length] == "\"]", format("ERROR: no \"] at end of line %s",line_number)); } void main() { string[string] data; string filename = "users.txt"; assert( std.file.exists(filename), format("ERROR: file %s not found",filename)); auto f = std.stdio.File("users.txt","r"); scope(exit) { f.close(); } string line = f.readln!(); long line_number = 0; while ( line !is null) { import std.uni : lineSep; line_number++; checkLine(std.string.chomp!(string)(line),line_number); auto fields = std.algorithm.findSplit(line,"\":\""); string key = std.regex.replaceAll(fields[0],regex(`^\["(.*)$`),"$1"); string value = std.regex.replaceAll(fields[2],regex(`^(.*)"\]\r?\n$`),"$1"); data[key] = value; line = f.readln!(); } writeln(data); writeln("value for key admin:",data["admin"]); writeln("value for key test:",data["test"]); }
Re: Error trying to build dlang.org
On Thursday, 4 January 2018 at 02:20:32 UTC, Seb wrote: On Thursday, 4 January 2018 at 01:50:47 UTC, Tony wrote: Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to successfully complete: --- make[1]: Leaving directory '/home/user/dlang/dmd/src' ../dmd/generated//release//dmd -c -o- -Df/home/user/dlang/dlang.org/web/spec/spec.html macros.ddoc html.ddoc dlang.org.ddoc doc.ddoc .generated/2.078.0.ddoc .generated/dblog_latest.ddoc .generated/twid_latest.ddoc spec/spec.ddoc spec/spec.dd make: ../dmd/generated//release//dmd: Command not found posix.mak:466: recipe for target '/home/user/dlang/dlang.org/web/spec/spec.html' failed make: *** [/home/user/dlang/dlang.org/web/spec/spec.html] Error 127 1) Did you clone the `dmd` repository yourself? yes 2) Is ../dmd existent? Try nuking ../dmd and doing a fresh clone of ../dmd I forgot to check, but I deleted the dlang.org directory and tried again starting from git clone and this time it appears to have worked. Guess I should have tried that first before posting.
Error trying to build dlang.org
Following the instructions here on Ubuntu 16.04: https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md I did the command make -f posix.mak html but it failed to successfully complete: --- make[1]: Leaving directory '/home/user/dlang/dmd/src' ../dmd/generated//release//dmd -c -o- -Df/home/user/dlang/dlang.org/web/spec/spec.html macros.ddoc html.ddoc dlang.org.ddoc doc.ddoc .generated/2.078.0.ddoc .generated/dblog_latest.ddoc .generated/twid_latest.ddoc spec/spec.ddoc spec/spec.dd make: ../dmd/generated//release//dmd: Command not found posix.mak:466: recipe for target '/home/user/dlang/dlang.org/web/spec/spec.html' failed make: *** [/home/user/dlang/dlang.org/web/spec/spec.html] Error 127
Re: Maybe D is right about GC after all !
On Wednesday, 3 January 2018 at 21:11:06 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 3 January 2018 at 19:42:28 UTC, Tony wrote: Why would someone choose to use a language with a Garbage Collector and then complain that the language has a Garbage Collector? People always complain about garbage collectors that freeze up the process. Irrespective of the language. It's the antithesis of low level programming… Why would they choose D for low level programming when they knew before they chose it that it had a Garbage Collector? It seems like their programming language decision methodology was flawed. To me, the only people who should be complaining about D's garbage collector are people who don't use D, not people who do. But maybe that is the case, the people who complain about the Garbage Collector in this D forum are not using D.
Re: How to use the -I command line switch?
On Wednesday, 3 January 2018 at 12:21:28 UTC, tipdbmp wrote: // C:\libs\my_module.d module my_module; void foo() {} // main.d module main; import my_module; void main() { foo(); } Running dmd with: dmd -IC:\libs main.d my_module.d I get: Error: module my_module is in file 'my_module.d' which cannot be read import path[0] = C:\libs import path[1] = path\to\dmd\D\dmd2\windows\bin\..\..\src\phobos import path[2] = path\to\dmd\D\dmd2\windows\bin\..\..\src\druntime\import As has already been mentioned, the -I is not used for command-line files. Just compiling (-c option) shows that the -I is enough for DMD to find the import file: dmd -c main.d -Ic:\libs successfully compiles main.d into main.obj To do a full compile and link of main without compiling my_module.d each time: C:\libs>dmd -lib -ofmy_module.lib my_module.d creates "my_module.lib". Then use it to link with in main.d compile/link: C:\code\d\forum>dmd main.d -Ic:\libs -Llib c:\libs\my_module OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 9: Unknown Option : NOILIB main.exe is created even though there is a mysterious warning.
Re: How to use the -I command line switch?
On Wednesday, 3 January 2018 at 18:35:21 UTC, Ali Çehreli wrote: On 01/03/2018 09:10 AM, tipdbmp wrote: dmd main.d C:\libs\my_module.d That does not use the -I switch. It compiles if I specify the full path to my_module.d: dmd -IC:\libs main.d C:\libs\my_module.d I don't understand the error message though. -I is for import directives only. imports are needed to compile the importing module. All other modules still need to be compiled themselves and added to the program either as individual .o files or as libraries (e.g. .a, .lib, etc.). The method you've shown is a shorthand for "compile each to .o and add each to the program." Working as expected... :) What about the error message? If -I is only for DMD finding "import ..." files, and not files on the command line, why does DMD list what was in the -I "where to look for import directives" when saying that it can't find a command-line file? It says that it can't locate my_module.d and then lists the directory that my_module.d is in.
Re: Maybe D is right about GC after all !
Why would someone choose to use a language with a Garbage Collector and then complain that the language has a Garbage Collector?
Re: load data from txt file
On Tuesday, 2 January 2018 at 22:08:52 UTC, aerto wrote: Hello and happy new year im new in d so i have a question i have into a txt file named users.txt the bellow ["admin":"123456789"] ["test":"test345"] im my app string[string] data; so i need to load users.txt content into data in order to be able to run writeln(data["admin"]); // i want this to print 123456789 writeln(data["test"]); // i want this to print test345 This seems to work (on Linux with no error checking) but is using the deprecated removechars() which gets deleted May 2018. There should be a simple fix using std.regex.replaceAll but I can't even get a successful compile right now (templates aren't deducing). Someone else should know what the correct replacement is for removechars(). import std.stdio; import std.string; import std.algorithm; void main() { string line; string[string] data; auto f = File("users.txt","r"); while ((line = f.readln('\n')) !is null) { string trimmed = removechars!string(line,"[\\[\\]\"\n\r]"); auto fields = findSplit(trimmed,":"); data[fields[0]] = fields[2]; } writeln(data); writeln("data for key admin:",data["admin"]); f.close(); }
Re: Slices and Dynamic Arrays
On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote: The DLang Tour should probably be fixed to use the term dynamic array though. Or embrace both terms but take care that it is clear that they are synonyms and one may be preferred depending on context. As a beginner, I had some confusion seeing both terms used. There is dual terminology in use outside of dlang.org. The book Programming In D says: Slice: Another name for dynamic array. When I write slice I will specifically mean a slice; and when I write array, I will mean either a slice or a fixed-length array, with no distinction. Slices Slices are the same feature as dynamic arrays. They are called dynamic arrays for being used like arrays, and are called slices for providing access to portions of other arrays. They allow using those portions as if they are separate arrays. ---
Re: How do you safely deal with range.front?
On Sunday, 31 December 2017 at 13:14:10 UTC, aliak wrote: On Sunday, 31 December 2017 at 01:03:17 UTC, Tony wrote: For me, front() should throw a pre-defined exception when called on an empty range in order to eliminate undefined behavior. It does take some time to make a check, but D does array bounds checking by default. Ideally the front() check could be turned off somehow ("-boundschecks=off") by the user for those who want maximum speed, but I guess there is no way to do that when using pre-compiled functions in a library. That sounds like a good idea. Wouldn't the same apply to array bounds checking for precompiled functions though? Yeah, seems like the standard library must be doing one or the other (bounds checking array indexes or not bounds checking them) all the time, depending on how it was compiled. Also, is going out of array bounds well-defined behavior in D even with bounds check off? I'm no expert, but I can't think of how it could be. And any links to docs on UB in D? This thread was the first time I have heard it used with regard to D.
Re: Slices and Dynamic Arrays
On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis wrote: The D Slices article does an excellent job of explaining all of this. It's just that it calls the GC-allocated memory buffer the dynamic array instead of calling T[] the dynamic array like the language and spec do. Regardless, all non-null dynamic arrays are slices of memory. The DLang Tour also uses the term slice to refer to T[]. "The type of arr is int[], which is also called a slice." "A slice consists of two members - a pointer to the starting element and the length of the slice:"
Re: Slices and Dynamic Arrays
On Sunday, 31 December 2017 at 04:20:28 UTC, codephantom wrote: On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote: On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a slice of pi" a slice of pi is irrational. Even on special occasions?
Re: Slices and Dynamic Arrays
On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a slice of pi"
Re: Slices and Dynamic Arrays
On Friday, 29 December 2017 at 23:13:20 UTC, Jonathan M Davis wrote: The term "slice" is a bit overused in D, meaning a variety of things. It doesn't help that some folks dislike the official terminology. In general, a slice is a contiguous group of elements. A slice of memory would be a contiguous block of memory. A dynamic array therefore refers to a slice of memory and could be called a slice, but it's also the case that using the slice operater on a container is called slicing - e.g. rbt[] would give you a range over the container rbt, and that range is a slice of the container, but it's not an array at all. For me, it is confusing to use "slice" and "dynamic array" as synonyms. My initial impression was that they must have different code underlying them, and different behavior. I would pick one or the other. It should be: D Arrays - Static - Dynamic or D Arrays - Static - Slice The DLang Tour has a section on Slices that says in bold "Slices and dynamic arrays are the same". I think that sentence deserves an explanation as to why there are two terms being utilized for the same thing. I would prefer that "slice" as a noun was used only for the time when a dynamic array was initialized from a slice of another array. Or better yet - slice was never used as a noun - only a verb or adjective: took a slice of array A to form a slice dynamic array B (or slice-intialized dynamic array B). D Arrays - Static - Dynamic - Slice-Initialized Dynamic
Re: How do you safely deal with range.front?
For me, front() should throw a pre-defined exception when called on an empty range in order to eliminate undefined behavior. It does take some time to make a check, but D does array bounds checking by default. Ideally the front() check could be turned off somehow ("-boundschecks=off") by the user for those who want maximum speed, but I guess there is no way to do that when using pre-compiled functions in a library.
Slices and Dynamic Arrays
In DLang Tour:Arrays https://tour.dlang.org/tour/en/basics/arrays there is: --- int size = 8; // run-time variable int[] arr = new int[size]; The type of arr is int[], which is a slice. --- In "D Slices" https://dlang.org/d-array-article.html there is: --- int[] a; // a is a slice Based on those two web pages it appears that the name for a dynamic arrayin D is "slice". That is, anytime you have a dynamic array (even a null reference version) it is called a slice. Is that correct?
DLang Tour : Functions as arguments
On this page: https://tour.dlang.org/tour/en/basics/delegates there is: void doSomething(int function(int, int) doer) { // call passed function doer(5,5); } doSomething(add); // use global function `add` here // add must have 2 int parameters I can't get it to compile unless it is: doSomething();
Re: Maybe D is right about GC after all !
On Sunday, 24 December 2017 at 22:04:00 UTC, Dan Partelly wrote: 1995. A dark year. Two of the crappiest language ever devised by man arrived. Both gained traction. Java, through marketing. PhP though tribalism. What makes Java a "crappy" language? I think PHP's success is due to its ability to integrate HTML statements. Also, it was often the only option back in the day from cheap web hosting services. And it seemed like on those cheap web hosts, when offered, Python and Perl were accessed via CGI, while PHP used via an Apache module which I think gave it a speed/resource utilization advantage.
Re: Maybe D is right about GC after all !
I have heard with regard to reference counting as is done in Python, that if two objects each have a reference to the other, that they will never be deleted, even if neither is used elsewhere in the program. Garbage collection is not supposed to have that issue, although I don't know how a garbage collector determines that there usage is just via each other and that they can be deleted.
Ddoc - No Documentation
Wondering what the rationale is for this: https://dlang.org/spec/ddoc.html#no_documentation No Documentation No documentation is generated for the following constructs, even if they have a documentation comment: Invariants Postblits Destructors Static constructors and static destructors Class info, type info, and module info