DIP 1029---Add throw as Function Attribute---Community Review Round 1 Begins
The first round of Community Review for DIP 1029, "Add throw as Function Attribute", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/sbdrybtyfkxfhxxjg...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: books for learning D
On Monday, 13 January 2020 at 11:58:51 UTC, mark wrote: Both those books are published by Packt who normally have no quality control at all as I've discovered to my cost. However It's hit and miss in my experience. I've picked up some utter crap from them, but I've also found some real gems. There's no real vetting of the authors they sign, so the writing quality and knowledge level vary. Assuming those are up to snuff, much depends on feedback from the technical reviewers and the author's ability to evaluate the editor's revisions. Packt's editors follow a rote process where certain words and phrases are *always* replaced from a set of alternatives and certain phrases are *always* inserted in certain circumstances (e.g., to introduce a code snippet) without any regard for the surrounding context. Fortunately, they give the author a chance to review the edits before publication. In my case, they were willing to accept my revision of the revisions (the ones I caught, anyway). Sadly, I never had a chance to do the same with the two chapters they published online. I can attest that Adam's and Kai's books are worth the buy. I own and have enjoyed both. If either of them were to do a 2nd edition, I'd pick it up!
Re: DConf 2020: Double Decker Edition
On Friday, 10 January 2020 at 21:58:27 UTC, Murilo wrote: On Saturday, 4 January 2020 at 12:23:40 UTC, Mike Parker wrote: The announcement is on the blog and dconf.org is up to date. Read all about it! https://dlang.org/blog/2020/01/04/dconf-2020-double-decker-edition/ https://dconf.org/2020/index.html Is it okay if I make many submissions? I have several ideas in mind. Yes.
Re: Win32 Api: How create Open/"Save as" Dialog?
On Friday, 10 January 2020 at 15:06:07 UTC, Marcone wrote: Very complicated. Can you send me the simple clear code? https://docs.microsoft.com/en-us/windows/win32/dlgbox/using-common-dialog-boxes
Re: On the Blog: Recent D Compiler Releases
On Wednesday, 8 January 2020 at 18:17:40 UTC, Rainer Schuetze wrote: With the current GC implementation, it’s illegal to perform any GC operations during finalization. There are some exceptions, namely addRoot/addRange and removeRoot/removeRange and the iterators over roots or ranges. I guess it might be possible to support some querying functions during finalization, too. I'll replace the "any" with "some". Thanks!
Re: DConf 2020: Double Decker Edition
On Friday, 10 January 2020 at 01:11:44 UTC, Murilo wrote: On Saturday, 4 January 2020 at 12:23:40 UTC, Mike Parker wrote: The announcement is on the blog and dconf.org is up to date. Read all about it! https://dlang.org/blog/2020/01/04/dconf-2020-double-decker-edition/ https://dconf.org/2020/index.html Once I submit a proposal for a talk, how long will it take to be reviewed and replied to? Soon, I'll update the website with all of the deadline dates. There will be a submission deadline and a deadline for the announcement of selections. Typically, the announcement takes place one week after the submission deadline and the submission authors are notified by email the day before. I anticipate the submission deadline will be some time in March.
On the Blog: Recent D Compiler Releases
I've posted an overview of LDC 1.19.0 and DMD 2.090.0 on the blog, and a reminder that GDC is available as part of the GCC 9 series. The blog: https://dlang.org/blog/2020/01/08/recent-d-compiler-releases/ Reddit: https://www.reddit.com/r/programming/comments/elq5yx/recent_d_compiler_releases_ldc_dmd_and_gdc/
Re: ssll - simple shared library loader
On Sunday, 5 January 2020 at 23:23:48 UTC, Oleg B wrote: Nice work! One thing I would recommend, though, is that you not bake in extern(C). Some libraries require extern(System) (because they're stdcall on Windows and cdecl everywhere else). There's also the issue with the Windows stdcall name-mangling scheme in 32-bit libraries, where the symbol name incorporates the size of the function parameters. Some stdcall libraries (like OpenGL) are configured to compile with the unmangled names, but others (like FreeImage) are not and require transforming the symbol name into the mangled form. So to be robust, you'll want to implement support for both into SSLL. It's analog of bindbc, but without need write boilerplate code. May be bindbc is designed for another cases, but I don't understand need writing triple definition for one function (pointer, loading, wrap-function). There are only two declarations required for the dynamic bindings in BindBC: an alias and a pointer. And of course the loader is separate. The reason is historical. When I was working on the earliest version of Derelict back in 2004, we didn't have all the fancy compile-time features we have now. I (and a couple of contributors) tried doing it by declaring the function pointers without aliases, but we ran into a couple of issues and settled for taking the alias + pointer approach. (It's been so long that I can't recall what the issues were). In the 4th iteration of Derelict (the bindings in DerelictOrg on github), I experimented with UDAs and single function declarations that I could generate static and dynamic bindigs with. But I was still mixing in the alias and pointer declarations for the dynamic bindings and could never figure out a way to distinguish between them during introspection. I posted about it here on the forums and no one had an answer, so I gave up. So bindbc is implemented the way it is because that's the way I've done it for almost 16 years.
Re: DConf 2020: Double Decker Edition
On Sunday, 5 January 2020 at 18:08:28 UTC, DanielG wrote: Is there a deadline for submissions? Not looking to inconvenience the evaluation team, just busy with something else for the next few weeks and wanting to give a submission the attention it deserves. I’ll update the site with the submission deadline and the early-bird & regular registration periods as soon as we get the dates sorted. The submission deadline will likely be some time in March.
DConf 2020: Double Decker Edition
The announcement is on the blog and dconf.org is up to date. Read all about it! https://dlang.org/blog/2020/01/04/dconf-2020-double-decker-edition/ https://dconf.org/2020/index.html
DIP 1028---Make @safe the Default---Community Review Round 1 Begins
The first round of Community Review for DIP 1028, "Make @safe the Default", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/ejaxvwklkyfnksjkl...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
DIP 1024---Shared Atomics---Accepted
DIP 1024, "Shared Atomics", was accepted without comment. https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1024.md
Re: Default values in derived class
On Saturday, 28 December 2019 at 20:22:51 UTC, JN wrote: import std.stdio; class Base { bool b = true; } class Derived : Base { bool b = false; } void main() { // 1 Base b = new Derived(); writeln(b.b); // true // 2 Derived d = new Derived(); writeln(d.b); // false } Expected behavior or bug? 1) seems like a bug to me. Expected. Member variables do not override base class variables. b is declared as Base, so it knows nothing about Derived’s member variable even though you instantiated it with an instance of Derived. There’s no vtable for variables. If you want it to print false, then you either have to cast b to Derived or provide a getter function in Base that Derived can override.
Re: What kind of Editor, IDE you are using and which one do you like for D language?
On Wednesday, 25 December 2019 at 10:57:45 UTC, Ron Tarrant wrote: On Tuesday, 24 December 2019 at 16:43:06 UTC, Mike Parker wrote: But now that VS Code's performance is within my tolerance range Just curious what you mean by this, Mike. For a while, typing in VS Code was clunky compared to Sublime. I gave it a spin every couple of months to see how it was shaping up and eventually I stopped noticing the difference.
Re: What kind of Editor, IDE you are using and which one do you like for D language?
On Monday, 23 December 2019 at 20:45:53 UTC, TheGag96 wrote: I've loved Sublime for years. I use it for everything, really. So pretty, so fast. I really like Sublime, too. Paid for it. But now that VS Code's performance is within my tolerance range, the built-in console makes the difference. I've got the Terminal plugin for Sublime that allows you to press ctrl-shift-alt-t to open the terminal in the project folder, but it just isn't the same experience. I still use Sublime when I just need a quick edit or single file. Otherwise, VS Code has become my goto editor for any multi-file D, Markdown, HTML, etc., project.
Re: array of functions/delegates
On Tuesday, 24 December 2019 at 13:13:12 UTC, MoonlightSentinel wrote: On Tuesday, 24 December 2019 at 10:40:16 UTC, Mike Parker wrote: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not clear to me wy the one requires casting the pointer type and the other doesn't. Because typeof() == void function(S) Right. I didn't modify the alias declaration when I took the functions out of the struct. I saw the immutable in the error message and thought that was the problem. alias Func = void function(S);
Re: Static linking, specifying binary and test-library folder
On Tuesday, 24 December 2019 at 05:51:37 UTC, Adnan wrote: Hello, how does one: 1. Force static linking (build with `-defaultlib` flag) Generally, when you don't see a buildOption in the docs for the compiler flag you want, use dflags. https://dub.pm/package-format-json.html 2. Specify binary file generated by the `dub buid` command targetPath, described under Build Settings in the docs. 3. Specify binary file generated by the `dub test` command You can override some of the settings for the build types (like the unittest build type), but targetPath is not one of them. https://dub.pm/package-format-json.html#build-types I would try to do it using a configuration. Name it whatever you want (perhaps "testing"). Set the targetPath in the configuration block, then run: dub -ctesting test https://dub.pm/package-format-json.html#configurations
Re: array of functions/delegates
On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: I am trying to create an array of functions inside a struct. struct S { void f1() {} void f2() {} alias Func = void function(); immutable Func[2] = [, ] } What I got: Error: non-constant expression '' Tried also with delegates (since I am in a struct context but I got: no `this` to create delegate `f1`. So, is there any way to have an array of functions without adding them at runtime? This isn't an array of functions you're creating here. A pointer to a member function is *always* a delegate, unless the function is static. Pointers to functions can be known at compile time, so this works: struct S () { static void f1() {} static void f2() {} alias Func = void function(); immutable Func[2] funcs = [, ]; } As does this: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not clear to me wy the one requires casting the pointer type and the other doesn't.
Re: Beta 2.090.0
On Sunday, 22 December 2019 at 18:51:45 UTC, berni44 wrote: On Sunday, 22 December 2019 at 15:23:32 UTC, Martin Nowak wrote: Glad to announce the first beta for the 2.090.0 release, ♥ to the 48 contributors. I'm wondering, why I'm listed twice there (as Bernhard Seckinger and as berni44). IMHO berni44 should not have been listed there... Do I have to change something in my git settings to get this right? You can submit a PR to add a mapping to tools/.mailmap: https://github.com/dlang/tools/blob/master/.mailmap https://github.com/git/git/blob/master/Documentation/mailmap.txt
Re: Beta 2.090.0
On Sunday, 22 December 2019 at 15:27:15 UTC, rikki cattermole wrote: On 23/12/2019 4:23 AM, Martin Nowak wrote: Glad to announce the first beta for the 2.090.0 release, ♥ to the 48 contributors. http://dlang.org/download.html#dmd_beta http://dlang.org/changelog/2.090.0.html As usual please report any bugs at https://issues.dlang.org -Martin 404'ing The changelog, that is.
Re: unicode characters are not printed correctly on the windows command line?
On Sunday, 22 December 2019 at 06:25:42 UTC, rikki cattermole wrote: On 22/12/2019 7:11 PM, moth wrote: is there any function i can call or setting i can adjust to get D to do the same, or do i have to wait for something to be fixed in the language / compiler itself? Not a bug. This is a known issue on the Windows side for people new to developing natively for it. Yes, and it's not just D programs. And setting the code page isn't always perfect, as it matters which font cmd is configured to use. Google for "windows command prompt unicode output". MS has updated the command prompt to support Unicode, but I don't know how to use it: https://devblogs.microsoft.com/commandline/windows-command-line-unicode-and-utf-8-output-text-buffer/ If you're on Windows 10, there's also Windows Terminal, which was released on the app store in June: https://devblogs.microsoft.com/commandline/windows-terminal-preview-v0-7-release/
DIP 1027---String Interpolation---Community Review Round 1 Begins
The first round of Community Review for DIP 1027, "String Interpolation", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/abhpqwxqgiyzgqxmj...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Goings-on in DLand
My latest post on the D Blog is an update on some current and upcoming events, a thank you note to all of our contributors, and a plea to help us fill our ongoing need for contributions.
Re: Goings-on in DLand
On Tuesday, 10 December 2019 at 10:09:22 UTC, Mike Parker wrote: My latest post on the D Blog is an update on some current and upcoming events, a thank you note to all of our contributors, and a plea to help us fill our ongoing need for contributions. https://dlang.org/blog/2019/12/10/goings-on-in-dland/
DIP 1023--Resolution of Template Alias Formal Parameters in Template Functions--Postponed
DIP 1023, "Resolution of Template Alias Formal Parameters in Template Functions", has been postponed at the request of the DIP author. https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md
DIP 1024---Shared Atomics---Final Review Begins
The Final Review for DIP 1024, "Shared Atomics", is now underway. Please do not leave any feedback in this thread, but rather in the review thread in the General forum: https://forum.dlang.org/post/ippdfqxnxbhxwzfdo...@forum.dlang.org
DIP 1026---Deprecate Context-Sensitive String Literals---Withdrawn
As a result of the feedback in the Community Review Round 1 discussion thread at https://forum.dlang.org/post/eevjgascbrqefbncc...@forum.dlang.org the DIP author has withdrawn the DIP from the review process. https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1026.md
Re: How to create a custom max() function without the ambiguity error.
On Friday, 6 December 2019 at 21:02:53 UTC, realhet wrote: Here's my latest attempt on EXTENDING std.algorithm.max's functionality with a max operation on a custom type. The type is the GLSL vec2 type which does the max operation component-wise. The D std implementation uses the < operator, but with overriding that for my custom type it is impossible to realise. -> max(vec2(1, 2), vec2(2,1)) == vec2(2,2) The reason you're having so much trouble with this is that you're violating the contract of max. It's a template, so it's already set up to work with custom types without any need to write a custom max function, as long as the types adhere to the contract. Consider other functions in std.algorithm, such as sort or equal, that allow you to pass a custom predicate. max doesn't have that because, by defintion, there is only one comparison for it to do: >. Any type that doesn't support that isn't going to work with max. Moreover, your return value violates the function's contract: "Iterates the passed arguments and return the maximum value." You aren't returning the maximum value. You're returning a new value constructed from the maximum components of the two parameters. That is not the same behavior as max(1, 3). Given that your function has a different contract, it should also have a different name.
Re: Unexpectedly nice case of auto return type
On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote: On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be able to name the type of null. I think this relates to TBottom too a bit. https://github.com/dlang/DIPs/blob/40352337053998885fbd0fe2718c300a322d3996/DIPs/DIP1NNN-DK.md Ah, well. I meant to post the link to the PR: https://github.com/dlang/DIPs/pull/172
Re: Unexpectedly nice case of auto return type
On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be able to name the type of null. I think this relates to TBottom too a bit. https://github.com/dlang/DIPs/blob/40352337053998885fbd0fe2718c300a322d3996/DIPs/DIP1NNN-DK.md
DIP 1026---Deprecate Context-Sensitive String Literals---Community Review Round 1 Begins
The first round of Community Review for DIP 1026, "Deprecate Context-Sensitive String Literals", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/eevjgascbrqefbncc...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: Exceptions on Windows being "swallowed"
On Wednesday, 27 November 2019 at 05:15:10 UTC, cartland wrote: No MS installed. Just using DMD. - dub -a x86_mscoff --force -v : So please try it without dub dmd -m32mscoff x.d If that works, add some debug flags like dub does: dmd -m32mscoff -debug -g x.d And see what happens.
Re: Exceptions on Windows being "swallowed"
On Wednesday, 27 November 2019 at 02:48:53 UTC, cartland wrote: Trying out exception handling. When an exception occurs, program seems to just exit. dub -a x86_mscoff I compiled it with dmd and ran it directly from the command line and it worked fine: C:\dev\D\scratch>ex finally catch %sfirst done Did you try that? And do you have the MS linker installed or are you using the lld that ships with DMD? Two things regarding your code: writeln does no formatting. You want writefln for that. But with writeln, you can provide multiple string arguments and they will be concatenated into the final output, like this: writeln("catch ", e.msg); Also, you don't need the `int main` signature if you don't actually need the return value to signify anyting: void main() { }} is just fine.
DIP 1022---foreach auto ref---Final Review Begins
The Final Review for DIP 1022, "foreach auto ref", is now underway. Please do not leave any feedback in this thread, but rather in the review thread in the General forum: https://forum.dlang.org/post/ugkhpbbvqugvlafek...@forum.dlang.org
Re: how to implement a function in a different D source file
On Tuesday, 26 November 2019 at 03:55:24 UTC, mipri wrote: On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote: the page here https://dlang.org/spec/function.html suggests you can implement a function in a different file ... mentioned the endeavour of no-bodied-functions as a way of presenting a black-box type of interface. oh, that's what you were asking. Consider: $ cat interface/references.d module references; string greeting(); $ cat implementation/references.d module references; string greeting() { return "Hello, Dave"; } $ cat main.d import references; void main() { import std.stdio: writeln; writeln(greeting); } And trying to build it: $ dmd -c implementation/references.d $ dmd -Iinterface -c main.d $ dmd main.o references.o $ ./main Hello, Dave The idiomatic way to do that is to put the interface in a "D interface" file (.di) and the implementation in a .d file: foo/bar.di foo/bar.d Then, when importing foo.bar, the compiler will pick up the .di file automatically. And you can actually have the compiler generate the interface file for you from a source file with the -H option.
Re: How to simulate Window's "Press any key to continue..."
On Friday, 22 November 2019 at 04:45:21 UTC, Mike Parker wrote: On Friday, 22 November 2019 at 04:22:07 UTC, FireController#1847 wrote: Right, but readln will only wait until the user presses the delimiter (by default Enter/Return). I want it to wait until ANY key is pressed, not a specific key The documentation for std.stdio.File shows two functions for reading input: readln and readf. If readln isn't what you want, then readf probably is: https://dlang.org/phobos/std_stdio.html#.File.readf Also, there's a freely available book online to help get you up to speed: Programming in D. Here's the section on reading from stdin with readf: http://ddili.org/ders/d.en/input.html Sorry, I just noticed the book doesn't cover how to do what you want and it's probably not obvious. You need to call readf with a character format string (%c): import std.stdio; void main() { writeln("Press any key to continue..."); char c; readf("%c", ); writeln("Thanks!"); }
Re: How to simulate Window's "Press any key to continue..."
On Friday, 22 November 2019 at 04:22:07 UTC, FireController#1847 wrote: Right, but readln will only wait until the user presses the delimiter (by default Enter/Return). I want it to wait until ANY key is pressed, not a specific key The documentation for std.stdio.File shows two functions for reading input: readln and readf. If readln isn't what you want, then readf probably is: https://dlang.org/phobos/std_stdio.html#.File.readf Also, there's a freely available book online to help get you up to speed: Programming in D. Here's the section on reading from stdin with readf: http://ddili.org/ders/d.en/input.html
Re: csvReader & specifying separator problems...
On Thursday, 14 November 2019 at 12:25:30 UTC, Robert M. Münch wrote: From the docs, which I find extremly hard to understand: auto csvReader(Contents = string, Malformed ErrorLevel = Malformed.throwException, Range, Separator = char)(Range input, Separator delimiter = ',', Separator quote = '"') Contents, ErrorLevel, Range, and Separator are template (i.e. compile-time) parameters. Input, delimiter, and quote are function (i.e. runtime) parameters. So, let's see if I can decyphre this, step-by-step by trying out: csv_records = csv_data.csvReader(); Here, you aren't providing any template parameters and only the first function parameter, so it's the equivalent to calling the function like so: csvReader!(string, Malformed.throwException, typeof(csv_data), char)(csv_data, ',', '"'); Which indicates some problem because not all fields are set in my CSV data. So let's ignore any error by specifying Malformed.ignore; csv_records = csv_data.csvReader(Malformed.ignore); csv_records = csv_data.csvReader!(string, Malformed.ignore)(); The docs state Malformed as 2nd parameter, since I use UFCS I assume that this becomes the first parameter. I don't Malformed is the 2nd template parameter, your UFCS value is the first function parameter. understand what the 3rd parameter (Range) is about. Range is the type of the first parameter. It's common outside of Phobos use T and U for template types, but any valid symbol name can be used. This template has three type parameters which are named according to their purpose (Contents, Range, and Separator). Since Range is also the type of the first function parameter, the compiler will infer the type if you don't specify it. 4th parameter is my separator, which I need to set to ';' somehow. The fourth _template_ parameter is the _type_ of your separator (and is set to default to char) not the actual separator. You want to set the delimiter, which is the second _function_ parameter. csv_records = csv_data.csvReader!(string, Malformed.ignore)(';');
DIP 1025--Dynamic Arrays Only Shrink, Never Grow--Withdrawn from Consideration
The author of DIP 1025, "Dynamic Arrays Only Shrink, Never Grow", has withdrawn the DIP from consideration. The current round of review has been terminated and the DIP has been removed from the review queue. https://forum.dlang.org/post/iouzzeyscvwekbsan...@forum.dlang.org
DIP 1025--Dynamic Arrays Only Shrink, Never Grow--Community Review Round 1 Begins
The first round of Community Review for DIP 1025, "Dynamic Arrays Only Shrink, Never Grow", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/wvbeyxlcdthqvzsgl...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: How to import & export modules
On Monday, 11 November 2019 at 01:28:54 UTC, userTY wrote: import all; // can see App, Form and Button exported (public) symbols --- The approach of using an "all" module is an old hack that is no longer necessary. Today, the way to approach is to use a "package module". https://dlang.org/spec/module.html#package-module Given a package "mylib" containing multiple modules, create a file "mylib/package.d". Use the package name as the module name and follow it with your public imports: module mylib; public import mylib.foo, mylib.bar, mylib.baz; Then users of the package can simply: import mylib;
Re: Release D 2.089.0
On Sunday, 3 November 2019 at 13:35:36 UTC, Martin Nowak wrote: Glad to announce D 2.089.0, ♥ to the 44 contributors. The Blog: https://dlang.org/blog/2019/11/06/dmd-2-089-0-released/ Reddit: https://www.reddit.com/r/programming/comments/dsgrc2/d_20890_released/
Re: Release D 2.089.0
On Wednesday, 6 November 2019 at 13:49:16 UTC, Ron Tarrant wrote: On the one hand, it's nice to get a shiny, new version (thanks to all involved), but is there any way the installer can be more selective about what it tosses out so I don't have to reconfigure GtkD libs, etc. in its aftermath? Are you putting libs in the compiler's directory tree? Or are you editing sc.ini/dmd.conf? You really shouldn't be doing the former.
Re: A question about postblit constructor
On Tuesday, 5 November 2019 at 10:32:03 UTC, Ferhat Kurtulmuş wrote: On Tuesday, 5 November 2019 at 10:31:05 UTC, Ferhat Kurtulmuş wrote: On Tuesday, 5 November 2019 at 10:13:59 UTC, Mike Parker wrote: [...] Yep, it is obvious that my code is wrong. s1 and s2 point to the same memory address. I could obtain my desired behavior with copy constructor. The documentation also say "WARNING: The postblit is considered legacy and is not recommended for new code. Code should use copy constructors defined in the previous section". I meant the example as an answer to your statement, "I wonder how new memory is allocated without an explicit malloc here". The postblit was intended as a chance to "fixup" everything when you needed a deep copy. The new struct is initialized as a shallow copy, so when you enter into the postblit, the pointer is already pointing at the original location. Without assigning it a new malloc'ed address, your memcpy was essentially overwriting the original location with its own data.
Re: A question about postblit constructor
On Tuesday, 5 November 2019 at 08:47:05 UTC, Ferhat Kurtulmuş wrote: value of int which is 0. I wonder how new memory is allocated without an explicit malloc here. Sorry for this noob question in advance, I could not find any doc mentioning a similar case. int* vals = cast(int*)malloc(len * S.sizeof); vals[0] = 4; vals[1] = 5; S s1 = S(vals, len); S s2 = s1; writeln(s2.vals[0]); writeln(s2.vals); writeln(s1.vals); } https://run.dlang.io/is/D0nfeT
Re: When will you announce DConf 2020?
On Tuesday, 5 November 2019 at 03:04:30 UTC, Murilo wrote: Oh, so they cover the costs if I can give an interesting talk? I already had several ideas in mind to speak during DConf but I never imagined that could get my costs covered. If you submit a talk proposal and it's accepted, then you are eligible after the conference to have your travel and accommodation expenses reimbursed. As long as they're reasonable (e.g. no first-class plane tickets or 5-star hotels, etc.).
Re: Which is the active fork in DFL gui library ?
On Saturday, 2 November 2019 at 20:01:27 UTC, Vinod K Chandran wrote: Hi all, I just found that DFL gui library very interesting. But after some searching, i can see that DFL is inactive and there is few other forks for it. So this is my question - Which fork is good for a gui development in windows platform. DFL is a long, long dead library. It was created with D1. I'm unaware of any active fork. BTW, i just tested the gtkD and successfully compiled a hello app. How do i avoid the console window when compiling gtkD app ? Thanks in advance. Any Windows executable compiled with a main function is by default considered a "console subsystem" application. You can specify to the linker that it should be a "windows subsystem" application (for which a console window will not be created) with a linker command line switch. Assuming you're using DMD, when you're using the OPTLINK linker (which is the default when invoking DMD directly or when passing -m32, or the DUB switch -ax86), the switch is /SUBSYSTEM:WINDOWS. You can pass it on the DMD command line with -L, as in: -L/SUBSYSTEM:WINDOWS With the Microsoft linker (-m32mscoff or -m64 on the dmd command line, -ax86mscoff or -x86_64 with dub, or the default with recent 64-bit dub versions), it's the same switch. But you also need to specify the entry point as being main and not WinMain, so: -L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTStartup When using dub, you can put the appropriate flags in a "dflags" entry in your dub.json or dub.sdl. Here's an example, winhello.d, that should work with all of the following command lines: dub -ax86 --single winhello.d dub -ax86_mscoff --single winhello.d dub -ax86_64 --single winhello.d dmd -L/SUBSYSTEM:WINDOWS winhello.d dmd -L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTstartup -m32mscoff winhello.d dmd -L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTstartup -m64 winhello.d If you don't have the Microsoft build tools installed, -m32mscoff and -m64 will use the lld linker that ships with DMD (if you chose to install it when you installed dmd). In that case, I'm not sure if the switches are the same. I've never used it and don't have it installed.
Re: Which is the active fork in DFL gui library ?
On Sunday, 3 November 2019 at 07:06:12 UTC, Mike Parker wrote: Here's an example, winhello.d, that should work with all of the following command lines: Sorry, here's the example: == winhello.d /+ dub.sdl: name "entry" dflags "-L/SUBSYSTEM:WINDOWS" "-L/ENTRY:mainCRTStartup" platform="windows-dmd" +/ import core.sys.windows.windows; pragma(lib, "user32"); void main() { MessageBoxA(null, "Hello", "Hello", MB_OK); }
Re: When will you announce DConf 2020?
On Sunday, 3 November 2019 at 00:51:38 UTC, Murilo wrote: Hi guys. I'm eager to attend the next DConf, which is why I'm already planning everything about how I will travel from Brazil to the UK(or maybe Germany). When will you announce the place and date of the next DConf? When our plans are finalized.
DLang Tour Now Supports Korean
BOSKorea has a few Korean programmers who had never used D before joining the company. Now future hires can take the DLang Tour in Korean. Thanks to Mathias Lang for initiating the translation effort. https://tour.dlang.org/tour/en/welcome/languages
DIP 1024---Shared Atomics---Community Review Round 2---Begins
The second round of Community Review for DIP 1024, "Shared Atomics", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/jetqewtibsnrsdpcy...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: DIP 1021--Argument Ownership and Function Calls--Formal Assessment
On Wednesday, 23 October 2019 at 04:20:19 UTC, Exil wrote: it's a bad idea. Why have two community reviews? Those are made with the assumption that the DIP will actually change between the reviews. No, that's not the assumption. You're conflating Community Review with Final Review. There can be multiple rounds of the former as required and only one of the latter. In a perfect scenario, no revisions are required between CR and FR. The purpose of the Final Review is to provide one final opportunity to catch any major issues that might have been missed during the CR round(s) and to allow anyone who missed the CR round(s) a final opportunity to have their say. Revisions are expected after a CR round, but not after the FR. As the documentation explains: https://github.com/dlang/DIPs/blob/master/docs/process-reviews.md
Re: DIP 1021--Argument Ownership and Function Calls--Formal Assessment
On Wednesday, 23 October 2019 at 04:20:19 UTC, Exil wrote: Should create a DIPW process then, duck the foundation and any formalities. Which stands for DIPWalter, which simply consists of a single step where a single topic tries to convince Walter it's a bad idea. Why have two community reviews? Those are made with the assumption that the DIP will actually change between the reviews. What's the point of a "formal review" when there's just Walter talking to himself (rip Andrei). Why waste everyone's time on formalities when they obviously are irrelevant? The formal assessment isn't Walter by himself. Atila took Andrei's place in that role. There is no automatic approval. Had Atila objected to the DIP, Walter would have had to either convince him to come around to his point of view or revise the DIP to meet Atila's concerns.
Re: D for sciencetific scripting / rapid protoryping
On Tuesday, 22 October 2019 at 07:40:01 UTC, Prokop Hapala wrote: 1) I'm not speaking about OpenGL and SDL specifically (that was just small example which I tried first) FYI, the BindBC bindings can be configured as dynamic (in which all the of C library functions are declared as function pointers and the C shared library must be loaded manually at runtime) or static (in which the C library functions become normal function declarations with no implementation and there is a link-time dependency on the C static or shared library). The exception is OpenGL, for which there is no static binding. The dynamic bindings add the overhead of the function pointer declarations when linked. It's insignificant for most of them. The biggest bindbc-opengl, depending on how many extensions you configure (it's extremely high for DerelictGL3 most of the time, as it tends to pull in more extensions). 2) I'm more concerned about how to D compiler links dependencies when it compiles simple .d program (with lot of dependencies). When using dub, it depends on the package configuration of each dependency. All of the Derelict and BindBC packages, for example, are configured to build as static libraries. It didn't (and doesn't) make sense to me to compile a binding as a shared library. Dub packages can also be configured as shared libraries, or simply as "library" (I haven't investigated what that means). Some might provide custom subconfigurations to choose static or shared. The biggest overhead with DMD output tends to come from the standard library. On Windows, the static library the only option. IIRC on Linux it's necessary to pass -defaultlib=libphobos2.so to DMD to link the shared lib. I don't know how LDC handles it.
DIP 1021--Argument Ownership and Function Calls--Formal Assessment
DIP 1021, "Argument Ownership and Function Calls", has been formally accepted with minor revision. It was updated to make clear that the proposal is one piece of a bigger plan. https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md
DIP 1022---foreach auto ref---Community Review Round 2 Begins
The second round of Community Review for DIP 1022, "foreach auto ref", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/kgfzzttzjwnmhmqca...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: Any 3D Game or Engine with examples/demos which just work (compile) out of the box on linux ?
On Saturday, 19 October 2019 at 00:57:48 UTC, Prokop Hapala wrote: The dmech/demos also seems to be almost running just it somehow cannot find or use my libsdl.so library which it just compiled (it is in 'dmech/demos/lib') derelict.util.exception.SharedLibLoadException@derelict/util/exception.d(43): Failed to load one or more shared libraries: ./lib/libsdl.so - ./lib/libsdl.so: wrong ELF class: ELFCLASS32 The problem is there in the error message. You have a 32-bit version of SDL, but you're compiling a 64-bit app. You need the 64-bit SDL.
Átila's Vision of D's Future
Shortly after DConf, I asked Átila to consider writing a blog post once he got settled into his new role as a language maintainer. I didn't have a clear idea of what the content should be, but about three months ago GreatSam4sure requested in the forums that Átila write a post about his vision for D's future. That blog post is now live. The blog: https://dlang.org/blog/2019/10/15/my-vision-of-ds-future/ Reddit: https://www.reddit.com/r/d_language/comments/di7gwl/%C3%A1tilas_vision_of_ds_future/ You'll see that he mentions the items on the list were the result of his thoughts during a long walk around Lake Geneva. It wasn't a three-month walk. The delay is because this is one of those instances where I could use @safe on my long-term memory storage. Átila would love to have feedback on this. Though you are free to post comments on the blog post or in the reddit thread, it would be great to keep all community-centric discussion in the forums. I've started a thread in the General forum for that purpose. https://forum.dlang.org/post/nrqyvxcbqlrgbvgnf...@forum.dlang.org
Re: Blog Post: Beating std::visit Without Really Trying
On Saturday, 5 October 2019 at 12:27:06 UTC, Mike Parker wrote: On Saturday, 5 October 2019 at 02:59:58 UTC, Paul Backus wrote: I was curious how C++17's std::variant compared to the options we have in D, like Algebraic and SumType, so I did a simple comparison of the generated assembly for each of them. You can read about it at the link below. And as you can probably guess from the title, D comes out ahead, in the end. https://pbackus.github.io/blog/beating-stdvisit-without-really-trying.html This is my first attempt at sharing something like this, so any comment or feedback is very much appreciated! Reddit: https://www.reddit.com/r/programming/comments/ddmlfy/beating_stdvisit_without_really_trying/ Correction: https://www.reddit.com/r/programming/comments/ddi5wb/beating_stdvisit_without_really_trying/ I missed that someone had already shared it.
Re: Blog Post: Beating std::visit Without Really Trying
On Saturday, 5 October 2019 at 02:59:58 UTC, Paul Backus wrote: I was curious how C++17's std::variant compared to the options we have in D, like Algebraic and SumType, so I did a simple comparison of the generated assembly for each of them. You can read about it at the link below. And as you can probably guess from the title, D comes out ahead, in the end. https://pbackus.github.io/blog/beating-stdvisit-without-really-trying.html This is my first attempt at sharing something like this, so any comment or feedback is very much appreciated! Reddit: https://www.reddit.com/r/programming/comments/ddmlfy/beating_stdvisit_without_really_trying/
New Funding Initiatives from the D Language Foundation
The latest post on the blog details some new funding initiatives from the D Language Foundation. This includes putting some of the HR Fund to use and seeding the first two of a set of forthcoming Bugzilla bounties. https://dlang.org/blog/2019/10/04/d-language-foundation-funding-new-platforms-new-bounties/
Re: Struct initialization has no effect or error?
On Thursday, 3 October 2019 at 04:57:44 UTC, mipri wrote: On Thursday, 3 October 2019 at 04:33:26 UTC, Brett wrote: I was trying to avoid such things since X is quite long in name. Not a huge deal... and I do not like the syntax because it looks like a constructor call. It is a constructor call, though. You can define your own as well: Technically it's a struct literal. It's only a constructor if you define one, in which case struct literals no longer work. E.g., struct Foo { int x; this(int a, int b) { x = a + b; } } Without the constructor, the literal Foo(10) would be valid, but with the constructor you'll get a compiler error.
Re: Why is it difficult to reference arrays in structs?
On Thursday, 3 October 2019 at 04:32:52 UTC, Brett wrote: Ok, fine! auto r = Now r is a reference, great! No, r is a pointer, not a reference. D does not have reference variables. But now the semantics of using the array completely change and errors abound! Probably because you're trying to use r as if it were of type Y[] when it's really of type Y[]*, i.e. if you wanted to append to it you would need to first dereference the pointer: *r ~= Y(10.0); Normal D pointers tend to act very nice, e.g., we don't have to use the C++ -> BS But with arrays it seems things are all screwed up and do not work correctly. No, they're working as intended. I can't just use r like I used x.a. I can't even use *r as things then get even more screwed up. Appending to *r works as expected: https://run.dlang.io/is/IQa619 What sort of trouble did you encounter? I want to have a slice of an array that I can append to as a sort of temporary and have it append to the main array(the end of the slice always is the end of the main array).. Your issue has nothing to do with structs. As per the documentation: https://dlang.org/spec/arrays.html#slicing the initialization of b here creates a slice referencing a: int[] a = [0, 1, 2]; int[] b = a; As a slice, b has its own .ptr and .length properties that are distinct from those of a. They are initialized with the values of a's properties, but they *are not references* to a's properties and b is *not a reference* to a. assert(b.ptr == a.ptr); assert(b.length == a.length); Because b.ptr and a.ptr point to the same memory, any updates to existing array elements through one will be reflected in the other: a[1] = 3; writeln(b); // prints [0, 3, 2] But any changes to the .ptr or .length of one will not be reflected in the other: a ~= 10; assert(a.length == 4); assert(b.length == 3); writeln(a); // prints [0, 3, 2, 10]; writeln(b); // prints [0, 3, 2]; Though at this point, depending on whether or not a reallocation took place, they might still be pointing to the same block of memory. I've tried assumeSafeAppend but it does nothing to help. assumeSafeAppend is for telling the runtime that you want to reuse an existing memory block backing an array and there's no need to reallocate it in append. https://dlang.org/articles/d-array-article.html#slice-members-appender The reason is because i have an algorithm that generates data and stores it in an array > and it is more efficient and easier to code if I can just append data to a "slice" of the array(there are no issues with overwriting). Essentially it just acts as an alias. By using pointers it would work but it screws up the entire syntax of all the code and > then still doesn't work. Could you adjust the signature of your algorithm to take the array by ref? void myAlgo(ref Y[] arr) { arr ~= Y(10.2); } Or to take x by ref (or as a pointer) and manipulate the array directly: void myAlgo(ref X x) { x.a ~= Y(10.2); }
Re: want to know precise GC benchmarks
On Tuesday, 1 October 2019 at 16:24:49 UTC, a11e99z wrote: why I want to know such info? CodinGame sometimes use time-limit for bot move for example 100ms, and bot will be disqualified in case no answer Simple solution: don't allocate every frame. The GC only runs when it needs to and it only needs to if an allocation request takes it over a certain threshold. If you need to allocate at all, do it up front. Or better, do it statically. Then the GC won't run at all. What sort of CodinGame bot would you need to allocate from the GC for anyway?
DIP 1024--Shared Atomics--Community Review Round 1 Begins
The first round of Community Review for DIP 1024, "Shared Atomics", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/wcoboszbrdgxcsidw...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: commonmark-d: A fast CommonMark and Github Flavoured Markdown parser, translation of MD4C
On Monday, 30 September 2019 at 23:06:42 UTC, Guillaume Piolat wrote: Hello, commonmark-d is a D translation of MD4C, a fast SAX-like Markdown parser. Thumbs up!
Saving Money by Switching from PHP to D
Andrea Fontana has contributed a guest post to the D blog about his company's experience moving their online magazine from PHP to D. Not only did they gain performance, they also saved quite a bit of money as a result. The blog: https://dlang.org/blog/2019/09/30/saving-money-by-switching-from-php-to-d/ Reddit: https://www.reddit.com/r/programming/comments/dbbc0l/saving_money_by_switching_from_php_to_d/
Re: Help making a game with transparency
On Saturday, 28 September 2019 at 13:41:24 UTC, matheus wrote: Ok, I took a look over my old projects and I found exactly what you want, by the way it's from 2012. It uses Derelict 2.0 bindings and will draw a PNG image where you can move around with cursor keys. Murilo, if you do decide to use this example as a basis for your project, please don't use DerelictSDL2. I'm not maintaining it anymore. bindbc-sdl, which I linked in my previous post, is what you should prefer. The API to load the library and handle errors is different, but the SDL API calls will all be the same.
Re: Help making a game with transparency
On Friday, 27 September 2019 at 22:55:22 UTC, Murilo wrote: Ahhh, that clears everything up. I will then leave the program without the transparency and wait until you get around to implement the fixes to it, I am not a developer, I am a scientist, I only use libraries, I don't know how to make them properly. You might consider using SDL and SDL_image: https://libsdl.org/download-2.0.php https://www.libsdl.org/projects/SDL_image/ D bindings for both are available here: https://code.dlang.org/packages/bindbc-sdl You don't actually *need* SDL_image, as core SDL can load images in the BITMAP format, and you can then use the API to create transparency from a specific color. But if you want to load PNG files with alpha, you'll want SDL_image. There are numerous tutorials online for SDL, though if you're searching, make sure to look for SDL 2 tutorials and ignore anything for SDL 1.x. The tutorials will all be in either C or C++, but the SDL API using the D bindings is the same. The Lazy Foo tutorials are often recommended: https://lazyfoo.net/tutorials/SDL/ But again, these are C++, so you have to consider the differences in D and C++ when porting the code over. For example, he uses class destructors to free resources. Do that in D and you'll run into trouble. So just ignore how he structures his programs and focus on the main concepts of using SDL: how to acquire/release resources, how to render, etc. You can adapt that to any architecture you want. There's no need for classes at all, for example. Some tutorials out there will show you how to use SDL with OpenGL. Please ignore those. SDL's 2D Rendering API is what you want when you're learning, so focus on tutorials tat show you how to use it. The SDL Wiki has API documentation: http://wiki.libsdl.org/APIByCategory
Re: Indexed graphics for retro engine?
On Thursday, 19 September 2019 at 18:25:05 UTC, Shadowblitz16 wrote: I wanted to do 4bpp 16 color graphics. and I didn't want to load anything unnecessary in the image like the palette but instead supply it myself as a Color[16]; I see. In that case, I suggest you find some tutorials on software rendering in C or C++ and adapt them to D. Most of the modern stuff out there is going to be targeting 24-bit or 32-bit graphics. You might find some older tutorials on indexed 8-bit rendering that you can adapt to 4-bit. Nothing to it but storing the palette indices in a byte array.
Re: combining libraries into 1 or 1 for each system?
On Thursday, 19 September 2019 at 18:28:25 UTC, Shadowblitz16 wrote: I mean I don't want to have multiple dependency dll's but instead just my own dll with the dependencies packed inside. of course dll is only for windows so I would like this done for mac and linux too Then statically link all your dependencies.
Re: Indexed graphics for retro engine?
On Thursday, 19 September 2019 at 03:47:05 UTC, Shadowblitz16 wrote: Is there a way to make a indexed graphics library that can handle importing and exporting true color images? I don't see why not. I would guess something like this could be simulated with pointers and references right? If you want to, say, take a 24-bit or 32-bit and treat it as an 8-bit image, you'll probably want to actually do a conversion rather than a simulation. In which case you'd probably be better off just using an existing C library like FreeImage. You can find a binding here: https://github.com/BindBC/bindbc-freeimage Otherwise, you'll want to hit up a graphics programming forum for resources on image conversion. Two possibilities: https://www.reddit.com/r/GraphicsProgramming/ https://www.gamedev.net/forums/forum/5-graphics-and-gpu-programming/
Re: combining libraries into 1 or 1 for each system?
On Thursday, 19 September 2019 at 03:44:28 UTC, Shadowblitz16 wrote: let's say I have a project the relies on multiple packages.. is it possible to combine these libraries into a single one (or 1 per os) for final shipment of a program? I assume you're referring to dub packages, in which case any dependencies you have will usually be configured to compile as static libraries. That means they'll be compiled into the executable without any extra effort on your part. If they're configured as dynamic libraries, you'll need to ship the dynamic library with your executable or manually edit the configurations to compile as static libraries. If they're bindings to C libraries, you'll need to ship the C dynamic libraries unless you statically link them. If none of this answers your question, please clarify what you mean by "multiple packages".
DIP 1021--Argument Ownership and Function Calls--Final Review Begins
The last chance for community feedback on DIP 1021, "Argument Ownership and Function Calls", is now underway. Please do not leave any feedback in this thread, but rather in the review thread in the General forum: https://forum.dlang.org/post/udqmnxucjsnuswdas...@forum.dlang.org
Re: Make executable archive just like Java's .jar archive?
On Thursday, 12 September 2019 at 12:53:27 UTC, BoQsc wrote: On Thursday, 12 September 2019 at 12:52:48 UTC, BoQsc wrote: Is there a way to archive multiple .d source code files and make that archive executable, or something similar? https://en.wikipedia.org/wiki/JAR_(file_format) A JAR file is just a standard zip file. The Java Virtual Machine loads .class files (which are Java bytecode files, not Java source) and executes them at runtime. It doesn't matter if they're in a jar file or not. Java was designed for this from the beginning. If you're really talking about loading .d *source* files, that means they either have to be interpreted like a scripting language, in which case you'll need a D interpreter, or they'll need to be compiled at runtime into bytecode (in which case you'll need a bytecode interpreter), or compiled at runtime into object files, in which case you'll need a mechanism for loading object files into a program (there was an object loader library around back in the D1 days). If you want to do what Java does and compile ahead of time to a bytecode format and distribute the bytecode in an archive to be loaded at runtime, then that requires implementing a bytecode compiler, a loader, and a bytecode interpreter. I know that LLVM can output bytecode, so with LDC that's the first step out of the way. Now all you need is for someone to implement a loader and bytecode interpreter.
Re: Using CSS Data from Within My Code
On Thursday, 12 September 2019 at 11:40:33 UTC, Ron Tarrant wrote: string myCSS = "tab { background-color: #f2f2f2; }"; enum will work just as well here and without the need for the variable: enum myCSS = "tab { background-color: #f2f2f2; }"; The original error was because q strings have to be valid D, not because of the enum.
Re: Blog Post #69: TextView and TextBuffer Basics
On Tuesday, 10 September 2019 at 08:29:59 UTC, Ron Tarrant wrote: This morning's discussion covers the basic workings and relationship between the TextView and TextBuffer widgets. Here's the link: https://gtkdcoding.com/2019/09/10/0069-textview-and-textbuffer.html Seriously impressed that you're able to keep this up so consistently. Keep on trucking!
DIP 1020--Named Parameters--Community Review Round 2 Begins
The second round of Community Review for DIP 1020, "Named Parameters", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/guvpjsspfzaruimrm...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* Thanks!
Re: DMD 2.088.0 and Other New Blog Post
On Friday, 6 September 2019 at 14:15:14 UTC, JN wrote: Minor typo in blog post: getAvaliable. Thanks. Could use some more descriptive title on reddit, because no one who doesn't know D will click it. Perhaps something like "DMD 2.088.0 released - comes with std::string and std::vector bindings". I've found that using "D 2.xxx Released" draws more traffic than "DMD 2.xxx Released". Perhaps mentioning the C++ bindings would have helped, perhaps not. Too late now though, as it's not possible to edit titles.
Re: DMD 2.088.0 and Other New Blog Post
On Friday, 6 September 2019 at 14:32:21 UTC, Mike Parker wrote: On Friday, 6 September 2019 at 14:15:14 UTC, JN wrote: Minor typo in blog post: getAvaliable. Thanks. Could use some more descriptive title on reddit, because no one who doesn't know D will click it. Perhaps something like "DMD 2.088.0 released - comes with std::string and std::vector bindings". I've found that using "D 2.xxx Released" draws more traffic than "DMD 2.xxx Released". I meant to prefix that with "Anecdotally". I've done more of the "DMD" form than I have of the "D" form, but will keep up with the latter for a few releases to see how it goes.
DMD 2.088.0 and Other New Blog Post
I've just published a new blog post announcing the 2.088.0 release of DMD and tacked on a few other news items at the end. Most of it will not be news to readers of the forums, but please keep an eye on the reddit comments if you've got time to spare. Blog: https://dlang.org/blog/2019/09/06/dmd-2-088-0-released/ Reddit: https://www.reddit.com/r/programming/comments/d0gtq7/d_20880_released/
DIP 1023--Resolution of Template Alias Formal Parameters in Template Functions--Community Review Round 1 Begins
The first round of Community Review for DIP 1023, "Resolution of Template Alias Formal Parameters in Template Functions", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/dnyqxmgdazczwmmva...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* In other DIP news, DIP 1020 will begin its second round of Community Review next week. Thanks!
Re: Old code no longer working on any DMD compilers
On Friday, 6 September 2019 at 05:59:30 UTC, Jamie wrote: time and fmod is called so it breaks. In case 3, with default struct arguments, I thought that the constructor I have defined was being called, however the default constructor was being called (this()) so fmod wasn't being called. The reason why my old code worked was because it used the default arguments and I wasn't actually calling the constructor I defined. When I removed the default arguments in the constructor and tried case 2 it obviously didn't work. Am I understanding correctly? Thanks You're right about case 1 and case 2, and partially correct about case 3. Structs don't actually have default constructors. They have default *initializers*. In other words, s = S() is the same as s = S.init. See item #4 in the documentation for struct destructors [1]: "If the ParameterList is empty, the struct instance is default initialized." So yes, your constructor is not being called. 1. https://dlang.org/spec/struct.html#struct-constructor
Re: Is there has an pdf document for Phobos.
On Wednesday, 4 September 2019 at 12:24:47 UTC, lili wrote: On Wednesday, 4 September 2019 at 04:21:10 UTC, Mike Parker wrote: On Wednesday, 4 September 2019 at 03:07:18 UTC, lili wrote: Hi: For some reason it too slow that some times i visited dlang.org, Can admin make a pdf document for download. Documentation is installed with the compiler. How to open it? If you're on Windows, it's located in dmd2/html. I don't know where it's installed on other platforms and I assume it depends on which installation method you used.
Re: Is there has an pdf document for Phobos.
On Wednesday, 4 September 2019 at 03:07:18 UTC, lili wrote: Hi: For some reason it too slow that some times i visited dlang.org, Can admin make a pdf document for download. Documentation is installed with the compiler.
Re: Why is sformat and formattedWrite (appender) allocating GC mem here?
On Saturday, 31 August 2019 at 12:07:56 UTC, cc wrote: And what, if anything, can I do to avoid it? import core.stdc.stdio : printf; There are no @nogc versions of the Phobos write* and format functions.
Re: Input/Output multiple values from function
On Wednesday, 28 August 2019 at 04:19:49 UTC, Jabari Zakiya wrote: I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values (2 integers and 2 arrays of integers). Then inside another function (say func2) I provide the 1 input to func1 and then want to assign its 4 output values to their appropriate final variables that will use them. Conceptually I want to do below: func2 { ...; (a, b, c, d) = func1(i) } I tried using a struct but compiler keeps complaining. Thanks for help in advance. A struct should work just fine: https://run.dlang.io/is/aMBGD0 import std.stdio; struct Results { int a, b; int[] aa, ab; } Results func1() { return Results(1, 2, [0, 1, 2, 3], [10, 11, 12]); } void main() { writeln(func1); } What is the compiler complaining about?
Re: Five Projects Selected for SAOC 2019
On Sunday, 25 August 2019 at 13:38:24 UTC, Mike Parker wrote: The Symmetry Autumn of Code 2019 application selection process has come to an end. This year, we've got five projects instead of three. Congratulations to everyone who was selected! You can read about them and their projects over at the D Blog: https://dlang.org/blog/2019/08/25/saoc-2019-projects-and-participants/ Reddit: https://www.reddit.com/r/d_language/comments/cv8jtd/saoc_2019_projects_and_participants/ I need to apologize to Laeeth and Manu. I mistakenly attributed the stl-containers repository to Suleyman: https://github.com/dlang-cpp-interop/stl-containers/ That was a major oversight on my part.
Five Projects Selected for SAOC 2019
The Symmetry Autumn of Code 2019 application selection process has come to an end. This year, we've got five projects instead of three. Congratulations to everyone who was selected! You can read about them and their projects over at the D Blog: https://dlang.org/blog/2019/08/25/saoc-2019-projects-and-participants/ Reddit: https://www.reddit.com/r/d_language/comments/cv8jtd/saoc_2019_projects_and_participants/
Re: D1: Trying to update Juno Library to 1.076
On Friday, 23 August 2019 at 16:09:16 UTC, jicman wrote: } That looks like D2 code. I am trying to compile D1 code. I think the linker is not getting something right. You might try declaring the offending functions as extern(Windows) function pointers and then loading them from the appropriate DLLs via LoadLibrary/GetProcAddress. I had to do that with some Win32 functions I used back before we got support for COFF and the Windows SDK because, for whatever reason, they were missing from the OMF libs that ship with DMD.
DIP 1019--Named Arguments Lite--Final Review Begins
The last chance for community feedback on DIP 1019, "Named Arguments Lite", is now underway. Please do not leave any feedback in this thread, but rather in the review thread in the General forum: https://forum.dlang.org/post/gcirbltrwuhntbsvf...@forum.dlang.org
SAOC 2019 Applications Closed
I want to thank everyone who has submitted an application to SAOC 2019. The application deadline has passed and we are no longer accepting new applications. This year, the SAOC committee consists of the following members: John Colvin Mathias Lang Átila Neves Robert Schadek Ethan Watson They will be reviewing the applications over the next few days and will be submitting their selections to me by the end of this week. We should be ready to announce the participants on the 25th. We had a total of 8 applications. At this time, I cannot guarantee how many will be selected to participate. At a minimum, it will be 3 just like last year, but we may have a little room to increase the participant count this year. Thanks also to everyone who has already agreed to be a mentor. Depending on which applicants are selected, we may need to search for one or more mentors starting next week. I ask anyone willing to act as a mentor to keep an eye out for the announcement Sunday in case a project that fits your interests and skill set is in need of one.
The New Bug Bounty System
Thanks to BOS Platform Korea, the new Bug Bounty system is live. Anyone willing to seed new bounties or increase the existing ones is free to do so. We hope to see the number of bounties grow and a few folks make some money from it. The details are in the blog post: https://dlang.org/blog/2019/08/17/bug-bounties-have-arrived/ Reddit: https://www.reddit.com/r/d_language/comments/crla4a/bug_bounties_have_arrived/ And for those who want to skip the blog post for now and get straight to work (read it later, though!): https://www.flipcause.com/secure/cause_pdetails/NjI2Njg= I'll see about getting this into the Community menu sometime soonish.
SAOC 2019 Application Deadline
The Symmetry Autumn of Code application deadline is this Sunday (midnight AoE). If you haven't yet sent your application in, be sure to read the SAOC page to make sure you get the details right. https://dlang.org/blog/symmetry-autumn-of-code/ Don't be late!
Re: How should I sort a doubly linked list the D way?
On Tuesday, 13 August 2019 at 22:12:23 UTC, Mirjam Akkersdijk wrote: Though, it left me with some semi-offtopic questions unanswered: (1) Ali, do you mean that from an optimization viewpoint, it's better to keep appending like `nodes ~= ...` instead of setting the length first? I would like to have some more background on that claim. He's not saying it will be better, but that the cost will be negligible. On every append, the GC allocates new memory only if the current capacity == 0. When it does allocate, it allocates more space than it actually needs based on the current length of the array, so you don't actually have an allocation on every append. Also, when the adjacent memory block is free and can hold the additional elements, the allocation consists of extending the array's memory block and no copying is performed, making the cost of the allocation even cheaper than it could be. Anyway, you can use `reserve` when appending rather than setting the length. This will allocate enough memory without default-initializing anything and you don't have to worry about bounds checking. int[] ints; ints.reserve(100); foreach(i; 0..100) { ints ~= i; } See Steve Schveighoffer's array article for details: https://dlang.org/articles/d-array-article.html
Re: Why is this allowed? Inheritance variable shadowing
On Tuesday, 13 August 2019 at 04:40:53 UTC, Chris Katko wrote: You can drop this straight into run.dlang.io: import std.stdio; class base{ float x=1;} class child : base {float x=2;} //shadows base variable! void main() { base []array; child c = new child; array ~= c; writeln(c.x); //=2 writeln(array[0].x); //=1 //uses BASE's interface, yes, //but why does the CHILD instance one exist at all? } It appears to be legal C++ as well but I can't imagine a situation where you'd want to allow the HUGE risk of shadowing/aliasing variables in an child class. Why is inheritance shadowing allowed? Especially when in D you have to explicitly "override" existing _methods_ but not fields/variables? To quote a Stack Overflow comment on C++ having this "It's not a compile error, but it's certainly a design one." Is this allowed just because "C++ does it" or because it has some sort of real world use that justifies the risk? Personally, I'd love a compile-time warning that I could turn on that flags this situation. Thanks for your help, --Chris I don't know if I'd call that shadowing. This is how it works in Java, too. There's no such thing as a vtable for member variables -- each class gets its own set and they don't conflict. The only time it could be really be called shadowing is when the base class member is protected, as then it's accessible in the subclass scope. Also, it's not the same thing as overriding. Overriding means that when you call base.foo(), you get sub.foo()'s implementation. But when you access base.var, you get base.var and not sub.var. I would find it extremely annoying if it worked the way you're expecting it to.
D Summer School Postmortem
Razvan Nitu and Eduard Staniloiu recently announced in the forums that they taught a D Summer School at University POLITEHNICA of Bucharest. They were kind enough to do a write-up for the D Blog. Please give it a read and wish them luck for V2! The blog: https://dlang.org/blog/2019/08/08/d-summer-school-postmortem/ Reddit: https://www.reddit.com/r/programming/comments/cnlfs2/d_summer_school_postmortem/
DIP 1022--foreach auto ref--Community Review Round 1 Begins
The first round of Community Review for DIP 1022, "foreach auto ref", has begun. To participate, please visit the review thread for the details: https://forum.dlang.org/post/nphczadgbedjzowuh...@forum.dlang.org *Please leave all feedback in the review thread rather than here!* In other DIP news, we're still revising DIP 1020. Its second round of community review will begin as soon as revision is complete. DIP 1019 will begin Final Review next week. Thanks!
Re: The DLang Swag Emporium is Open For Business!
On Friday, 2 August 2019 at 07:23:28 UTC, JN wrote: By the way, why call it Digital Mars logo and not just D logo? Because I think of it as the "Digital Mars D logo" as opposed to the "D Rocket logo" or the "Royal D logo". I've renamed those items to "Digital Mars D".
Re: The DLang Swag Emporium is Open For Business!
On Friday, 2 August 2019 at 01:13:33 UTC, James Blachly wrote: Looking great. Can you set up die-cut stickers of the D Rocket logo? I've added standard stickers (round & square on the store page, though you can select the shape during the order process) and die-cut vinyl stickers. It could take up to 24-hours for the store page to update with the new items.