Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 21:36:36 UTC, Q. Schroll wrote: [1] https://wiki.dlang.org/Building_under_Windows You might try Digger. That will hide all the tedious bits. https://code.dlang.org/packages/digger
Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 21:36:36 UTC, Q. Schroll wrote: On Wednesday, 25 November 2020 at 21:16:15 UTC, Steven Schveighoffer wrote: I typically do: make -f posix.mak std/.test -Steve For some reason, [1] says `make.exe` would be installed by the DMD installer, but I found none. It explicitly says not to use GNU make. (I'm on Windows.) [1] https://wiki.dlang.org/Building_under_Windows The digital mars make is actually distributed with the c compiler. Developing on Windows is such a complete pain e.g. setting it up so it can find the linker and cl. For that reason I currently just do all dmd/phobos/druntime hacking inside WSL because that way I can just press build (dmd has build.d which is cross-platform but druntime and phobos both aren't fun to build on windows unless you've done it recently)
Re: Simulating computed goto
On Wednesday, 25 November 2020 at 18:44:52 UTC, NonNull wrote: Is there a good way to simulate computed goto in D? I haven't used assembly myself, but it's possible that you can define a mixin that does this, using inline assembly.
Re: How to unit-test a phobos module?
On Thursday, 26 November 2020 at 00:17:26 UTC, Q. Schroll wrote: One of the issues is, I don't know what DRuntime really is. As far as I understand on the surface-level, it's functionality one would expect to be implemented by the compiler, but actually implemented in plain D code. A low-level Phobos if you want. So I'm a little confused why there's even a need for it to be "built". Isn't it "just code" like Phobos? Phobos depends on DRuntime, and both Phobos and DRuntime depend on the D compiler. When you download version 2.094.2 of the compiler (the latest release), it comes with the corresponding versions of Phobos and DRuntime, and is configured to automatically include them in its import paths. If you want to compile the development version of Phobos, you will generally need the development versions of DRuntime and DMD as well, because of the dependency relationships between them. If you try to compile the development version of Phobos using the latest released versions of DMD and DRuntime, you are liable to run into dependency issues like the one in your original post. *ME* Why would I need those? I haven't needed them back then. I wrote that not saying "do the work for me, guys" but "please tell me what changed". I have no idea what changed for *your* setup, because (a) I develop on Linux, not Windows, and (b) I've only been involved in D development since 2018. Personally, I followed the instructions on the "Starting as a Contributor" and "Contributing to Phobos" pages, and they worked for me.
Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 21:57:12 UTC, H. S. Teoh wrote: On Wed, Nov 25, 2020 at 09:49:12PM +, Paul Backus via Digitalmars-d-learn wrote: On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll wrote: > On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus > wrote: > > On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll > > wrote: > > > My setup: > > > * A fresh DMD installed a few minutes ago. > > > * Clone of my Phobos fork with up-to-date changes from > > > dlang/phobos/master. > > > > Do you have clones of dmd and druntime too? > > Why would I need those? I haven't needed them back then. copyEmplace isn't in druntime 2.094.2. My guess is that the problem is caused by trying to compile Phobos with a compiler that uses an incompatible version of druntime. One of the issues is, I don't know what DRuntime really is. As far as I understand on the surface-level, it's functionality one would expect to be implemented by the compiler, but actually implemented in plain D code. A low-level Phobos if you want. So I'm a little confused why there's even a need for it to be "built". Isn't it "just code" like Phobos? I'm increasingly frustrated because, honestly, it seems I don't know enough about the build processes or build tools used. The Wiki expects Digital Mars make to be there, also says explicitly not to confuse it with GNU make, but in my DMD folder there is none. Since it's a plain install, I suspect the Wiki is outdated. How am I expected to figure things out? It seems like everyone else knows how to do it, just I'm too stupid. *ME* Why would I need those? I haven't needed them back then. I wrote that not saying "do the work for me, guys" but "please tell me what changed".
Re: How to unit-test a phobos module?
On Wed, Nov 25, 2020 at 09:49:12PM +, Paul Backus via Digitalmars-d-learn wrote: > On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll wrote: > > On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus wrote: > > > On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll wrote: > > > > My setup: > > > > * A fresh DMD installed a few minutes ago. > > > > * Clone of my Phobos fork with up-to-date changes from > > > > dlang/phobos/master. > > > > > > Do you have clones of dmd and druntime too? > > > > Why would I need those? I haven't needed them back then. > > copyEmplace isn't in druntime 2.094.2. My guess is that the problem is caused by trying to compile Phobos with a compiler that uses an incompatible version of druntime. T -- Insanity is doing the same thing over and over again and expecting different results.
Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll wrote: On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus wrote: On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll wrote: My setup: * A fresh DMD installed a few minutes ago. * Clone of my Phobos fork with up-to-date changes from dlang/phobos/master. Do you have clones of dmd and druntime too? Why would I need those? I haven't needed them back then. copyEmplace isn't in druntime 2.094.2.
Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 21:16:15 UTC, Steven Schveighoffer wrote: I typically do: make -f posix.mak std/.test -Steve For some reason, [1] says `make.exe` would be installed by the DMD installer, but I found none. It explicitly says not to use GNU make. (I'm on Windows.) [1] https://wiki.dlang.org/Building_under_Windows
Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus wrote: On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll wrote: My setup: * A fresh DMD installed a few minutes ago. * Clone of my Phobos fork with up-to-date changes from dlang/phobos/master. Do you have clones of dmd and druntime too? Why would I need those? I haven't needed them back then.
Re: How to unit-test a phobos module?
On 11/25/20 3:58 PM, Q. Schroll wrote: When trying to unit-test an unchanged phobos module from phobos/master, I get errors such as module core.lifetime import copyEmplace not found and template instantiation errors. What is the correct arguments to pass to (r)dmd? I know it worked for me some years ago, but somehow, it doesn't work now. I've looked at [1], [2], [3] which didn't work (maybe outdated?). How do you do it and what am I doing wrong? My setup: * A fresh DMD installed a few minutes ago. * Clone of my Phobos fork with up-to-date changes from dlang/phobos/master. In the clone's folder, ~/dlang/phobos, I tried the following commands: $ dmd -main -unittest -version=StdUnittest -I. -run std/.d and $ rdmd -main -unittest -version=StdUnittest -I. std/.d I have the feeling I'm missing something quite obvious. [1] https://wiki.dlang.org/Contributing_to_Phobos#Test_a_single_Phobos_module [2] https://wiki.dlang.org/Building_under_Windows#Building_Phobos_2 [3] https://github.com/dlang/phobos/blob/master/CONTRIBUTING.md I typically do: make -f posix.mak std/.test -Steve
Re: How to unit-test a phobos module?
On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll wrote: My setup: * A fresh DMD installed a few minutes ago. * Clone of my Phobos fork with up-to-date changes from dlang/phobos/master. Do you have clones of dmd and druntime too? If not, try following these instructions: https://wiki.dlang.org/Starting_as_a_Contributor#Typical_Contributor_Workflow
How to unit-test a phobos module?
When trying to unit-test an unchanged phobos module from phobos/master, I get errors such as module core.lifetime import copyEmplace not found and template instantiation errors. What is the correct arguments to pass to (r)dmd? I know it worked for me some years ago, but somehow, it doesn't work now. I've looked at [1], [2], [3] which didn't work (maybe outdated?). How do you do it and what am I doing wrong? My setup: * A fresh DMD installed a few minutes ago. * Clone of my Phobos fork with up-to-date changes from dlang/phobos/master. In the clone's folder, ~/dlang/phobos, I tried the following commands: $ dmd -main -unittest -version=StdUnittest -I. -run std/.d and $ rdmd -main -unittest -version=StdUnittest -I. std/.d I have the feeling I'm missing something quite obvious. [1] https://wiki.dlang.org/Contributing_to_Phobos#Test_a_single_Phobos_module [2] https://wiki.dlang.org/Building_under_Windows#Building_Phobos_2 [3] https://github.com/dlang/phobos/blob/master/CONTRIBUTING.md
Re: Simulating computed goto
On Wednesday, 25 November 2020 at 19:04:45 UTC, H. S. Teoh wrote: FWIW, D's switch statement is flexible enough to directly write Duff's device. How good is optimization in ldc2, gdc, dmd at compiling chained jumps into one jump each time? I'm pretty sure ldc2 and gdc will optimize away any such chained jumps. But if performance is important to you, I recommend *not* bothering with dmd. Yes this is about efficiency. Is there a good way to simulate computed goto in D? With a switch statement. ;) OK, so I took a look at switch documentation and tried out something. It looked like switch can have computed goto using case labels. case 5: //... goto case ; //doesn't compile when is not a constant So to simulate computed goto have to 1. wrap switch(x) in a loop [ while(0) ] 2. inside each case recompute x (instead of jump to computed y) 3. jump back to execute switch again [ continue ] It does look as if a nested switch can contain case labels from an outer switch which is very good. Did not try this out. Any more ideas, advice?
Re: Reflection on the book D web development.
On Wednesday, 25 November 2020 at 17:26:44 UTC, Alaindevos wrote: hunt-http has no documentation and does not looks usable to me. What looks usable is kemal & the crystal language, https://kemalcr.com/guide/ Looks like Sinatra. That makes sense given the relationship of Crystal to Ruby. Many languages have a Sinatra-inspired framework, but to my knowledge not D. I think Adam Ruppe's libraries are closer to that approach.
Re: Simulating computed goto
On Wed, Nov 25, 2020 at 06:44:52PM +, NonNull via Digitalmars-d-learn wrote: > For automatically generated code of some low level kinds it is > convenient to have "computed goto" like this: > > https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html > > and D does not have this. > > A switch could be used to simulate it. But this would lead to what > could have been a single jump being chained jumps. FWIW, D's switch statement is flexible enough to directly write Duff's device. > How good is optimization in ldc2, gdc, dmd at compiling chained jumps > into one jump each time? I'm pretty sure ldc2 and gdc will optimize away any such chained jumps. But if performance is important to you, I recommend *not* bothering with dmd. > Is there a good way to simulate computed goto in D? With a switch statement. ;) T -- They pretend to pay us, and we pretend to work. -- Russian saying
Re: Simulating computed goto
On Wednesday, 25 November 2020 at 18:44:52 UTC, NonNull wrote: How good is optimization in ldc2, gdc, dmd at compiling chained jumps into one jump each time? The easiest way to find the answer to a question like this is to use the compiler explorer: https://d.godbolt.org/
Simulating computed goto
For automatically generated code of some low level kinds it is convenient to have "computed goto" like this: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html and D does not have this. A switch could be used to simulate it. But this would lead to what could have been a single jump being chained jumps. How good is optimization in ldc2, gdc, dmd at compiling chained jumps into one jump each time? Is there a good way to simulate computed goto in D?
Re: Reflection on the book D web development.
hunt-http has no documentation and does not looks usable to me. What looks usable is kemal & the crystal language, https://kemalcr.com/guide/
Re: Ways to parse D code.
On Wednesday, 25 November 2020 at 16:27:41 UTC, Jan Hönig wrote: What is the "easiest" way to parse D code? (...) libdparse seems to do it as well with `parseModule` function. https://github.com/dlang-community/libdparse/blob/master/src/dparse/parser.d I recommend libdparse. dmd has to do it somewhere as well. Although I don't know exactly where. I do know ldc uses dmd's frontend for parsing. https://dlang.org/phobos/dmd_parse.html DMD as a library is still experimental. You can try to use it, but libdparse is more stable. I am also a little confused about who uses what. Does D-Scanner use libdparse? Yes, most tools that parse D code do, including Adam's documentation generator: https://github.com/adamdruppe/adrdox Only LDC, GDC and VisualD use the dmd front-end as far as I know. Is there a D grammar for pegged? https://github.com/PhilippeSigaud/Pegged Not complete and outdated, but it's a start: https://github.com/PhilippeSigaud/Pegged/tree/master/examples/dgrammar
Ways to parse D code.
What is the "easiest" way to parse D code? Given an Expression/Statement/Function/Template I want to put it into a program, and it returns me an AST. D-Scanner seems to do that with `--ast` argument. I would need to dig into it, to get it programmatically, instead of as XML on the stdout. https://github.com/dlang-community/D-Scanner libdparse seems to do it as well with `parseModule` function. https://github.com/dlang-community/libdparse/blob/master/src/dparse/parser.d dmd has to do it somewhere as well. Although I don't know exactly where. I do know ldc uses dmd's frontend for parsing. https://dlang.org/phobos/dmd_parse.html I am also a little confused about who uses what. Does D-Scanner use libdparse? Is there a D grammar for pegged? https://github.com/PhilippeSigaud/Pegged Thank you for any hints!
Re: Article about Ranges
On Wednesday, 25 November 2020 at 12:28:20 UTC, Paul Backus wrote: Maybe this is the one you're thinking of? https://www.informit.com/articles/article.aspx?p=1407357 Ye, it is. Thank you very much Paul.
Re: Article about Ranges
On Wednesday, 25 November 2020 at 11:13:24 UTC, ddcovery wrote: Months ago I read an Andrei article explaining why Ranges (comparing with C++). I remember article introduction included a python "false" quick-sort algorithm. I'm really interested in a more detailed read of the article, but I can't find it. If some one can post the link :-) Thank you Maybe this is the one you're thinking of? https://www.informit.com/articles/article.aspx?p=1407357
Article about Ranges
Months ago I read an Andrei article explaining why Ranges (comparing with C++). I remember article introduction included a python "false" quick-sort algorithm. I'm really interested in a more detailed read of the article, but I can't find it. If some one can post the link :-) Thank you
Re: How to rebind the default tkd GUI keybinds?
On Saturday, 17 October 2020 at 18:39:54 UTC, starcanopy wrote: On Saturday, 17 October 2020 at 09:33:04 UTC, tastyminerals wrote: On Sunday, 11 October 2020 at 18:51:17 UTC, tastyminerals wrote: [...] So, this is even tricky in Python TkInter but possible. In tkd this is not possible unfortunately. You could try directly calling [bindtags](https://www.tcl.tk/man/tcl8.4/TkCmd/bindtags.htm) with _tk.eval. Modifying and extending tkd is easy from my experience where I had added support for additional image formats. (After blundering about on how to get tcl/tk to work, lol.) So, there is a way. It just needs substantial time investment :) Thanks for point it out.