Re: Is there a cleaner way of doing this?
On 07/08/17 12:37, Timon Gehr wrote: struct S(T...) { T param; void initialize(T param) { this.param = param; // Other stuff } } Then, use S!() instead of S!void. It's an interesting approach. It has the down side that it also accepts S!(int, string, int[23], double), and I'm still not sure what I think about this option (i.e. - whether I want to allow it). If not, then things start to look quite misleading to the user, and I'd rather have the ugly static-ifs than do that. Shachar
Re: How do you use D?
On Tuesday, 8 August 2017 at 01:20:37 UTC, Nicholas Wilson wrote: On Monday, 7 August 2017 at 19:54:51 UTC, Eugene Wissner wrote: Yes. Everything I know about low-level network programming, assembler, memory management, I learned from my working on my library, tanya. OT but tanya's readme has a wrong comment: ``` int i = arr[7]; // Access 7th element. ``` should be 8th element. Fixed, thanks!
Weekend Project: Vulkan-DPP
Hi All, I am toying with the idea to use https://github.com/KhronosGroup/Vulkan-Hpp to target the D language. I haven't started it yet, but would like to hear people's thought and opinion on it. My goal is learning about vulkan and D in general. The existing wrappers we have namely: ErupteD is directly one-to-one wrapper based on C. Thanks, Swoorup
Re: Mixin templates vs interface files
On Tuesday, 8 August 2017 at 01:04:30 UTC, Jean-Louis Leroy wrote: On Sunday, 6 August 2017 at 13:24:23 UTC, Jean-Louis Leroy wrote: Consider: // app.d [...] I see no reason why this() is kept and ~this() not. Should I report this as a bug? It seems to be happening here: https://github.com/dlang/dmd/blob/master/src/ddmd/hdrgen.d#L1982 Maybe if (hgs.hdrgen) return; should read: if (hgs.hdrgen && !hgs.tpltMember) return; When I make that change I get my static ~this in the .di file. Beyond that, I don't see the reason why visit(StaticDtorDeclaration d) is not a copy-paste of visit(StaticCtorDeclaration d) with one tilde added. PR?
Re: How do you use D?
On Monday, 7 August 2017 at 19:54:51 UTC, Eugene Wissner wrote: Yes. Everything I know about low-level network programming, assembler, memory management, I learned from my working on my library, tanya. OT but tanya's readme has a wrong comment: ``` int i = arr[7]; // Access 7th element. ``` should be 8th element.
Re: Mixin templates vs interface files
On Sunday, 6 August 2017 at 13:24:23 UTC, Jean-Louis Leroy wrote: Consider: // app.d [...] I see no reason why this() is kept and ~this() not. Should I report this as a bug?
Re: [OT] Bitcoin's Split Is Good for Progress
On Wednesday, 2 August 2017 at 16:21:41 UTC, jmh530 wrote: I was surprised to see a familiar name here: https://www.bloomberg.com/view/articles/2017-08-02/bitcoin-s-split-is-good-for-progress Here's an interview with Amaury about the Bitcoin split: https://bitcoinmagazine.com/articles/future-bitcoin-cash-interview-bitcoin-abc-lead-developer-amaury-séchet/ I've been meaning to interview him for the D blog, about D of course, need to get around to that.
Re: [OT] Bitcoin's Split Is Good for Progress
On Wednesday, 2 August 2017 at 19:00:05 UTC, Ali Çehreli wrote: On 08/02/2017 09:21 AM, jmh530 wrote: I was surprised to see a familiar name here: https://www.bloomberg.com/view/articles/2017-08-02/bitcoin-s-split-is-good-for-progress "They -- led by former Facebook developer Amaury Sechet -- moved ahead with new software that would increase the maximum block size to 8 MB." Ali We won't stop to 8 :)
Who here uses vibe-s3 from code.dlang.org?
vibe-s3 (https://code.dlang.org/packages/vibe-s3) is an Amazon s3 object storage API for D. Has anyone here used or tested it? What was your experiences? It has the tagline "this library is highly alpha and mostly untested. use at your own risk".
Re: DMD license question
On Monday, 7 August 2017 at 21:28:52 UTC, Andre Pany wrote: Hi, as DMD is now under Boost Software License, can I distribute it as part of my commercial product? I want to provide script support within my application. The idea is to compile the scripts (D coding) to shared libraries and load the shared libraries into the main program. Kind regards André Yes, the idea of the Boost Software License is that you don't have to ask such questions. Boost allows you to do anything you want with the source, whether embedding, modifying, etc. and you don't have to ask anyone for permission or even mention that you're using someone else's software to your users, as the BSD advertising clause requires. Boost gives you the freedom to do almost anything you want, with the only exception that you cannot claim the copyright to the source or binary as your own. Given that you can use it almost any way you want, ie basically all rights under copyright have been given to you, there would be no point in claiming the copyright anyway, only a false claim that you wrote it too.
Re: DMD license question
On 8/7/2017 2:28 PM, Andre Pany wrote: as DMD is now under Boost Software License, can I distribute it as part of my commercial product? Yes.
DMD license question
Hi, as DMD is now under Boost Software License, can I distribute it as part of my commercial product? I want to provide script support within my application. The idea is to compile the scripts (D coding) to shared libraries and load the shared libraries into the main program. Kind regards André
Re: How do you use D?
I'm a self-employed web-developer, mostly working with PHP and Javascript and markup languages like HTML and stuff like CSS and SQL databases. On the other hand at school (in Russia) we began with QBasic, then Turbo Pascal and could choose if we use Turbo Pascal or something else for solving class excercises. It was the first time I learned C. After school I continued to use C for some open source projects I was participating for fun. Two years ago I started to look for a language that gives you a control over the system like C but at the same time has high-level constructs I was fimilar with from PHP. Here D comes into play (my second choice would be Haskell and Rust). How do you use D? In work, (key projects or smaller side projects) I'm living now in Germany and a year ago I found a job, where I can use D all the time, but I still continue doing web-development with PHP, Javascript and & Co. in your side project, (github, links please) Still my primary interest on D was to replace C in my projects, I started to work on a library that would give me C++ with the syntax of a modern high-level programming language. See https://github.com/caraus-ecms/tanya. just to learn something new? (I would easily argue that learning D will make you a better C++ programmer, maybe not the most efficient way, but I a sure it i very effective) Yes. Everything I know about low-level network programming, assembler, memory management, I learned from my working on my library, tanya. Did you introduce D to your work place? How? What challenges did you face? Though it is not reallistic to replace PHP and js with D for small end customers I want to start some web-service based on D on my own. After some work on tanya, I'm planning to continue to work on my web-framework, I've started before: https://github.com/caraus-ecms/caraus. What is you D setup at work, which compiler, which IDE? neovim, dmd and gcc on Slackware Linux.
Re: Is there a cleaner way of doing this?
On Monday, 7 August 2017 at 08:01:26 UTC, Shachar Shemesh wrote: It is often desired to have a struct with an extra parameter. The common way to do this is like so: struct S(T) { T param; void initialize(T param) { this.param = param; // Other stuff } } The problem is what happens when the param is optional. The common way to do this is to set T to void. This results in the following code: struct S(T) { enum HasParam = !is(T == void); static if( HasParam ) { T param; } static if( HasParam ) { void initialize(T param) { this.param = param; // Other stuff } } else { void initialize() { // Same other stuff as above! } } } This is both tedious and error prone. Is there a cleaner way of doing this? Just as an unrealistic fantasy, if the following code was legal, the problem would be resolved on its own: void func(void p) { void param; param = p; return param; } Of course, that code has its own set of problems, and I'm not really suggesting that change. Shachar Why don't you use a factory method? struct S(T) { T p; static make(T p) { S s; s.p = p; return s; } static make() { return S(); } } void main() { auto s1 = S!int.make; auto s2 = S!string.make; }
Re: threads, fibers and GPU kernels
On Monday, 7 August 2017 at 08:57:35 UTC, Nicholas Wilson wrote: On Monday, 7 August 2017 at 07:38:34 UTC, Suliman wrote: Modern GPU have thousands of GPU kernels, it's far from CPU kernels, but it's interesting for me is there any chance that in future they be used in same maner as CPU kernels? Do you mean threads? Not really, they are more like SIMD lanes that together are more analogous to a CPU thread. See John Colvin's 2015/2016 DConf talks. As deadalnix reminded me after my 2016 talk, the wider picture of the GPU is SIMT, not SIMD, but from a computation point of view I find I don't need to conceptually separate the two so much. In my experience, most things that work well on GPU end up working very like SIMD on an OoO CPU when you do them right, even if they don't look like it in the code.
Re: Is there a cleaner way of doing this?
On Monday, 7 August 2017 at 08:01:26 UTC, Shachar Shemesh wrote: It is often desired to have a struct with an extra parameter. The common way to do this is like so: struct S(T) { T param; void initialize(T param) { this.param = param; // Other stuff } } The problem is what happens when the param is optional. The common way to do this is to set T to void. This results in the following code: struct S(T) { enum HasParam = !is(T == void); static if( HasParam ) { T param; } static if( HasParam ) { void initialize(T param) { this.param = param; // Other stuff } } else { void initialize() { // Same other stuff as above! } } } This is both tedious and error prone. Is there a cleaner way of doing this? Just as an unrealistic fantasy, if the following code was legal, the problem would be resolved on its own: void func(void p) { void param; param = p; return param; } Of course, that code has its own set of problems, and I'm not really suggesting that change. Shachar You can use type default initialization property: struct S(T) { T param; void initialize(T param = T.init) { this.param = param; // Other stuff } } S!int s; s.initialize(42); // works s.initialize(); // also works; s.param == int.init == 0
Re: Is there a cleaner way of doing this?
On 07.08.2017 10:01, Shachar Shemesh wrote: It is often desired to have a struct with an extra parameter. The common way to do this is like so: struct S(T) { T param; void initialize(T param) { this.param = param; // Other stuff } } The problem is what happens when the param is optional. The common way to do this is to set T to void. This results in the following code: struct S(T) { enum HasParam = !is(T == void); static if( HasParam ) { T param; } static if( HasParam ) { void initialize(T param) { this.param = param; // Other stuff } } else { void initialize() { // Same other stuff as above! } } } This is both tedious and error prone. Is there a cleaner way of doing this? ... struct S(T...) { T param; void initialize(T param) { this.param = param; // Other stuff } } Then, use S!() instead of S!void. Just as an unrealistic fantasy, if the following code was legal, the problem would be resolved on its own: void func(void p) { void param; param = p; return param; } Of course, that code has its own set of problems, and I'm not really suggesting that change. Shachar The only reason this code is problematic is that void.sizeof == 1.
Re: Is there a cleaner way of doing this?
On 08/07/2017 01:01 AM, Shachar Shemesh wrote: It is often desired to have a struct with an extra parameter. The common way to do this is like so: struct S(T) { T param; void initialize(T param) { this.param = param; // Other stuff } } The problem is what happens when the param is optional. The common way to do this is to set T to void. This results in the following code: struct S(T) { enum HasParam = !is(T == void); static if( HasParam ) { T param; } static if( HasParam ) { void initialize(T param) { this.param = param; // Other stuff } } else { void initialize() { // Same other stuff as above! } } } This is both tedious and error prone. Is there a cleaner way of doing this? A mixin template can work. The whole param-related code is in one place and the void specialization obviates the need for static if: mixin template ParamCode(T) { T param; void initializeParam(T param) { this.param = param; initialize(); } } template ParamCode(T : void) { } struct S(T) { mixin ParamCode!T; void initialize() { // ... } } unittest { auto a = S!int(); static assert(a.sizeof == int.sizeof); a.initializeParam(42); auto b = S!void(); static assert(b.sizeof == 1); b.initialize(); } void main() { } Ali
Re: threads, fibers and GPU kernels
On Monday, 7 August 2017 at 07:38:34 UTC, Suliman wrote: Modern GPU have thousands of GPU kernels, it's far from CPU kernels, but it's interesting for me is there any chance that in future they be used in same maner as CPU kernels? Do you mean threads? Not really, they are more like SIMD lanes that together are more analogous to a CPU thread. See John Colvin's 2015/2016 DConf talks. If yes is there any reasons of exit for fibers? Or it would be easier to map one thread to one kernel? On system with 1k kernels/cores I do not see any reason for fibers for exiten. Fibres are for I/O bound problems related to the overheads of task switching. They offer no benefits (unless you want stateful generators) for compute bound problems. Also here was few topics about D3. But what about about you are thinging about threading model? I think in next 10 yers even CPU would have 32-64 cores.
Is there a cleaner way of doing this?
It is often desired to have a struct with an extra parameter. The common way to do this is like so: struct S(T) { T param; void initialize(T param) { this.param = param; // Other stuff } } The problem is what happens when the param is optional. The common way to do this is to set T to void. This results in the following code: struct S(T) { enum HasParam = !is(T == void); static if( HasParam ) { T param; } static if( HasParam ) { void initialize(T param) { this.param = param; // Other stuff } } else { void initialize() { // Same other stuff as above! } } } This is both tedious and error prone. Is there a cleaner way of doing this? Just as an unrealistic fantasy, if the following code was legal, the problem would be resolved on its own: void func(void p) { void param; param = p; return param; } Of course, that code has its own set of problems, and I'm not really suggesting that change. Shachar
threads, fibers and GPU kernels
Modern GPU have thousands of GPU kernels, it's far from CPU kernels, but it's interesting for me is there any chance that in future they be used in same maner as CPU kernels? If yes is there any reasons of exit for fibers? Or it would be easier to map one thread to one kernel? On system with 1k kernels/cores I do not see any reason for fibers for exiten. Also here was few topics about D3. But what about about you are thinging about threading model? I think in next 10 yers even CPU would have 32-64 cores.