Re: Shadertoy in Dcompute?
On Thursday, 22 August 2019 at 00:57:26 UTC, Bert wrote: How hard would it be to do something like Shadertoy in Dcompute and would it be any faster? I don't like the basics of Shadertoy, lots of nonsense to do basic stuff. E.g., to work with complex numbers one must essentially do everything manually. Would there be any benefit using Dcompute(last time I tried it I couldn't get it to work). DCompute is primarily for compute at the moment, and not graphics. It targets OpenCL and CUDA, not OpenGL/WebGL/Vulkan/DirectX. Thats not to say that you can't use it for computational graphics but you wouldn't be utilising the specialised hardware for the rendering pipeline, so it would probably be slower. If you want to have a crack at it, I'd take a look at how to do graphics with OpenCL or CUDA and adapt what you can. I haven't tested OpenCL/OpenGL interop at all (with or without DCompute) but it is a thing.
Re: Exercism, call for mentors
After my post, a fellow going by Biotronic on Exercism came along and cleared out the queue. Much appreciated!
Shadertoy in Dcompute?
How hard would it be to do something like Shadertoy in Dcompute and would it be any faster? I don't like the basics of Shadertoy, lots of nonsense to do basic stuff. E.g., to work with complex numbers one must essentially do everything manually. Would there be any benefit using Dcompute(last time I tried it I couldn't get it to work).
Re: Exercism, call for mentors
On Tuesday, 20 August 2019 at 09:40:06 UTC, Björn Lindström wrote: Hello, I've recently decided to pick up D, and have started doing some exercises on https://exercism.io/ (a non-profit programming exercise platform), which I think is an excellent way to pick up the basics in a new language. While doing the exercises on my own is rewarding already, I would greatly appreciate if someone would want to pick up the mantle of mentor in D over there. Evidently someone liked the idea at one point enough to contribute D versions of a lot of the exercises, but based on progress of the queue, nobody is checking it frequently at the moment. I've been doing some mentoring there myself, for Python and Bash, and I think it's quite fun, and I learn a lot that way. It forces me to regularly think hard about the basics, trying to give considered advice to beginners. Anyway, if someone would be willing to give it a go, you can go to https://exercism.io/become-a-mentor and follow the instructions there. Thanks, Björn This is a great idea. I didn't know about https://exercism.io/ I've got a lot on my plate in the following weeks, but I'll try to make some time to mentor. I hope others in the community will join as well. Cheers, Edi
Re: strangely silent compiler
On Wednesday, 21 August 2019 at 13:56:51 UTC, Eugene Wissner wrote: On Wednesday, 21 August 2019 at 13:41:20 UTC, Orfeo wrote: I've: ``` module anomalo.util; // Foo doesn't exist anywhere! Foo toJsJson(string type, Args...)(string id, Args args) { static if (type == "int" || type == "outcome") { return Json(["id" : Json(id), "type" : Json(type), "value" : Json(0),]); } else { static assert(0, "invalid type"); } } ``` So: ``` $ dub build ``` No error! ``` $ /usr/bin/dmd -lib -ofliba.a -debug -g -w -I. src/anomalo/util.d -vcolumns ``` No error! Here [github](https://github.com/o3o/anomalo) my project. Thank you toJsJson is a template. Templates are evaluated first when they are instantiated. Compiler doesn't give an error because it doesn't compile toJsJson, because you don't instantiate it anywhere. You're right: if I add (into util.d) ``` unittest { import std.stdio; writeln(toJsJson!"int"("a")); } ``` voila' : ``` $ dub test src/anomalo/util.d(3,5): Error: undefined identifier Foo src/anomalo/util.d(13,26): Error: template instance `anomalo.util.toJsJson!"int"` error instantiating /usr/bin/dmd failed with exit code 1. ``` Thank you
Re: strangely silent compiler
On Wednesday, 21 August 2019 at 13:41:20 UTC, Orfeo wrote: I've: ``` module anomalo.util; // Foo doesn't exist anywhere! Foo toJsJson(string type, Args...)(string id, Args args) { static if (type == "int" || type == "outcome") { return Json(["id" : Json(id), "type" : Json(type), "value" : Json(0),]); } else { static assert(0, "invalid type"); } } ``` So: ``` $ dub build ``` No error! ``` $ /usr/bin/dmd -lib -ofliba.a -debug -g -w -I. src/anomalo/util.d -vcolumns ``` No error! Here [github](https://github.com/o3o/anomalo) my project. Thank you toJsJson is a template. Templates are evaluated first when they are instantiated. Compiler doesn't give an error because it doesn't compile toJsJson, because you don't instantiate it anywhere.
strangely silent compiler
I've: ``` module anomalo.util; // Foo doesn't exist anywhere! Foo toJsJson(string type, Args...)(string id, Args args) { static if (type == "int" || type == "outcome") { return Json(["id" : Json(id), "type" : Json(type), "value" : Json(0),]); } else { static assert(0, "invalid type"); } } ``` So: ``` $ dub build ``` No error! ``` $ /usr/bin/dmd -lib -ofliba.a -debug -g -w -I. src/anomalo/util.d -vcolumns ``` No error! Here [github](https://github.com/o3o/anomalo) my project. Thank you
Re: Template specialized functions creating runtime instructions?
On Wednesday, 21 August 2019 at 00:11:23 UTC, ads wrote: On Wednesday, 21 August 2019 at 00:04:37 UTC, H. S. Teoh wrote: On Tue, Aug 20, 2019 at 11:48:04PM +, ads via Digitalmars-d-learn wrote: [...] 2) Deducing the string as you describe would require CTFE (compile-time function evaluation), which usually isn't done unless the result is *required* at compile-time. The typical way to force this to happen is to store the result into an enum: enum myStr = fizzbuzz!...(...); writeln(myStr); Since enums have to be known at compile-time, this forces CTFE evaluation of fizzbuzz, which is probably what you're looking for here. T Thank you for clearing those up. However even if I force CTFE (line 35), it doesn't seem to help much. https://godbolt.org/z/MytoLF It does. on line 4113 you have that string .L.str: .asciz "Buzz\n49\nFizz\n47\n46\nFizzBuzz\n44\n43\nFizz\n41\nBuzz\nFizz\n38\n37\nFizz\nBuzz\n34\nFizz\n32\n31\nFizzBuzz\n29\n28\nFizz\n26\nBuzz\nFizz\n23\n22\nFizz\nBuzz\n19\nFizz\n17\n16\nFizzBuzz\n14\n13\nFizz\n11\nBuzz\nFizz\n8\n7\nFizz\nBuzz\n4\nFizz\n2\n1\n" and all main() does is call writeln with that string _Dmain: pushrax lea rsi, [rip + .L.str] mov edi, 203 call@safe void std.stdio.writeln!(immutable(char)[]).writeln(immutable(char)[])@PLT xor eax, eax pop rcx ret You haven't given instruction to the linker to strip unused code so the functions generated by the templates are still there.