Re: Create object from a library's Class returns Null
On Wednesday, 29 May 2019 at 05:04:54 UTC, dangbinghoo wrote: On Wednesday, 29 May 2019 at 02:42:23 UTC, Adam D. Ruppe wrote: Object.factory is pretty unreliable and has few supporters among the developers. I wouldn't suggest relying on it and instead building your own factory functions. oh, that's bad news, but the hibernated library is using this feature. what should I do with this? now we found that, class from a module library won't work, if I move gwlib to testobj/source, it works.
Re: Create object from a library's Class returns Null
On Wednesday, 29 May 2019 at 02:42:23 UTC, Adam D. Ruppe wrote: Object.factory is pretty unreliable and has few supporters among the developers. I wouldn't suggest relying on it and instead building your own factory functions. oh, that's bad news, but the hibernated library is using this feature. what should I do with this?
Re: Create object from a library's Class returns Null
Object.factory is pretty unreliable and has few supporters among the developers. I wouldn't suggest relying on it and instead building your own factory functions.
Re: Create object from a library's Class returns Null
On Tuesday, 28 May 2019 at 14:24:30 UTC, dangbinghoo wrote: On Tuesday, 28 May 2019 at 14:16:44 UTC, Nick Treleaven wrote: On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: yeah, I made a typo mistake in the forum post, but the code in github repo is really with no typo problem. This seems to be a serious problem, I found it works when I using Ldc2 1.12 version even on ARM target. hi there, Anyone help with this? Not a typo problem, even this --- writeln(Object.factory(ns.toString())); --- result in `null`. just try the github demo project: https://github.com/dangbinghoo/DObjectCreatTest.git Thanks! --- binghoo dang
Re: How can I structure a Meson build project in D to use DUB.
On Tuesday, 28 May 2019 at 18:13:17 UTC, GoaLitiuM wrote: On Tuesday, 28 May 2019 at 18:11:09 UTC, Mike Brockus wrote: How can I structure a Meson build project in D to use dub as a method for dependencies like urld, d2sqlite or unit-threaded? If that is not what Meson users of D do then what is the pure Meson of things way? C https://github.com/squidfarts/c-example D https://github.com/squidfarts/d-example You simply change the method to dub for dependencies, as shown here: https://github.com/mesonbuild/meson/blob/master/test%20cases/d/11%20dub/meson.build#L8 So how does it work? Should the dependency be downloaded already or will the dub method get the package from a repository of some kind?
Re: Reuse/reset dynamic rectangular array?
On 5/28/19 4:58 PM, Robert M. Münch wrote: On 2019-05-28 01:52:28 +, 9il said: myRectData[] = null; :-/ Ok... doesn't look to complicated ;-) Still learning a lot about D... Keep in mind, this does not reuse the allocated arrays, it simply resets them to point at nothing (and will need to be reallocated). To reset the way you want, you need a loop: foreach(ref arr; myRectData) { arr.length = 0; arr.assumeSafeAppend; } -Steve
Re: Reuse/reset dynamic rectangular array?
On 2019-05-28 01:52:28 +, 9il said: myRectData[] = null; :-/ Ok... doesn't look to complicated ;-) Still learning a lot about D... -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: Blog Post #0039 - File Dialog V - Adding SaveAs and Titlebar Filename Reflection
Hi WebFreak. I'm glad you're getting something out of it. I started this because it's the kind of thing I wished was out there. It's good to know I'm not the only one. On Tuesday, 28 May 2019 at 12:58:12 UTC, WebFreak001 wrote: Could you maybe add screenshots to each blog post? I've had a ton (Well, four... Five? Six?) requests to do them and I have started down that road, but it's going to take a bit of time what with everything else I've got going on ATM. They could be shown for example right at the top of each post and maybe a thumbnail in the post list and that way greatly simplify searching a tutorial of interest and also massively help with sharing links to your posts online where OpenGraph or Twitter images are embedded. (see https://gethead.info/ for good examples how to add these meta tags) I'll see if I can sort this out. Is the source code of your site available somewhere? I'm not sure what you mean by this... the HTML? the Jekyll code? Or are you asking about the example files? Because the examples are all there with links in the blog posts, if that's what you're asking about. But if you're asking about the HTML/Jekyll/whatever, I have to ask: why do you want access? Also it would be nice if it supported HTTPS. (LetsEncrypt certificates are free and easy to setup for this) Why would I need secure pages?
Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec
Why not simply 17.5531 ms ("%.4f ms") to get rid of the non-ASCII µ prefix? fwiw I like this solution for the output. It is very clear to me. +1 and without space 17.5531ms
Re: How can I structure a Meson build project in D to use DUB.
On Tuesday, 28 May 2019 at 18:13:17 UTC, GoaLitiuM wrote: On Tuesday, 28 May 2019 at 18:11:09 UTC, Mike Brockus wrote: How can I structure a Meson build project in D to use dub as a method for dependencies like urld, d2sqlite or unit-threaded? If that is not what Meson users of D do then what is the pure Meson of things way? C https://github.com/squidfarts/c-example D https://github.com/squidfarts/d-example You simply change the method to dub for dependencies, as shown here: https://github.com/mesonbuild/meson/blob/master/test%20cases/d/11%20dub/meson.build#L8 (Maybe I posted too quickly without reading the post fully...) As for structuring, there is no special handling for dub projects specifically in Meson, but the dub dependencies must be fetched and built for the same compiler you have setup your Meson build to use, as Meson does not try to build the dependencies for you.
Re: How can I structure a Meson build project in D to use DUB.
On Tuesday, 28 May 2019 at 18:11:09 UTC, Mike Brockus wrote: How can I structure a Meson build project in D to use dub as a method for dependencies like urld, d2sqlite or unit-threaded? If that is not what Meson users of D do then what is the pure Meson of things way? C https://github.com/squidfarts/c-example D https://github.com/squidfarts/d-example You simply change the method to dub for dependencies, as shown here: https://github.com/mesonbuild/meson/blob/master/test%20cases/d/11%20dub/meson.build#L8
How can I structure a Meson build project in D to use DUB.
How can I structure a Meson build project in D to use dub as a method for dependencies like urld, d2sqlite or unit-threaded? If that is not what Meson users of D do then what is the pure Meson of things way? C https://github.com/squidfarts/c-example D https://github.com/squidfarts/d-example
Re: [TWiD] static foreach loop variable
Ok, thanks for explaining. Nice idea.
Re: [TWiD] static foreach loop variable
On Tuesday, 28 May 2019 at 13:43:45 UTC, Nick Treleaven wrote: Hi, Last week's TWiD had a tip that didn't make sense: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_05_20.html#tip-of-the-week template Locals(int i) { alias Whatever = int; } static foreach(i; [1, 2, 3]) { Locals!i.Whatever; } The body is just `int;`. Not sure how to reach Adam. What was intended? Yes, intended, but also incomplete. The idea there is to use the template as a namespace for whatever local stuff you had. (I adapted this from a reflection thing where Whatever would have been an alias to a member type, and then in simplifying to get to just the new idea - and in a rush to type it up that day - I removed like all the context). So it might actually be more like (still an incomplete example but more complete): void test(T)() { template Locals(int i) { static if(is(typeof(__traits(getMember, T, __traits(allMembers, T)[i])) Ret == return)) alias ReturnValue = Ret; } static foreach(idx, t; __traits(allMembers, T)) { mixin("auto " ~ t ~ "() { return Locals!idx.ReturnValue.init; }"); } } So now the Locals template wraps a bunch of aliases so we can refer to them more succinctly later. A regular alias defined inside that static foreach would end up being duplicated in future iterations. Putting the extra {} around it would mean the mixed in function would not be visible outside. so the Locals template is just a collection of convenience aliases in a namespace.
Re: Create object from a library's Class returns Null
On Tuesday, 28 May 2019 at 14:16:44 UTC, Nick Treleaven wrote: On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: class NSconf { String name; ... } Does this class have a non-default constructor? yes, I didn't provide constructor, as Class will have a default one if not supplied. Typo, should be NSconf. yeah, I made a typo mistake in the forum post, but the code in github repo is really with no typo problem. This seems to be a serious problem, I found it works when I using Ldc2 1.12 version even on ARM target.
Re: Create object from a library's Class returns Null
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: class NSconf { String name; ... } Does this class have a non-default constructor?
Re: Create object from a library's Class returns Null
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: writeln(Object.factory("gwlib.entity.nsconf.NSConf")); Typo, should be NSconf.
[TWiD] static foreach loop variable
Hi, Last week's TWiD had a tip that didn't make sense: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_05_20.html#tip-of-the-week template Locals(int i) { alias Whatever = int; } static foreach(i; [1, 2, 3]) { Locals!i.Whatever; } The body is just `int;`. Not sure how to reach Adam. What was intended?
Re: Blog Post #0039 - File Dialog V - Adding SaveAs and Titlebar Filename Reflection
On Tuesday, 28 May 2019 at 09:47:23 UTC, Ron Tarrant wrote: Good day to you all. 'Tis another Tuesday and time for a new blog post. This is a continuation of the series on Dialogs and further, a continuation of the mini-series-within-a-series on file Dialogs. The subject is in the title as is fitting for a blog post about putting things in the titlebar. You can find it here: http://gtkdcoding.com/2019/05/28/0039-file-save-as-dialog.html nice work! Such regular tutorials are always great for the community and just recently recommended it to someone asking for one. Could you maybe add screenshots to each blog post? They could be shown for example right at the top of each post and maybe a thumbnail in the post list and that way greatly simplify searching a tutorial of interest and also massively help with sharing links to your posts online where OpenGraph or Twitter images are embedded. (see https://gethead.info/ for good examples how to add these meta tags) Is the source code of your site available somewhere? Also it would be nice if it supported HTTPS. (LetsEncrypt certificates are free and easy to setup for this)
Blog Post #0039 - File Dialog V - Adding SaveAs and Titlebar Filename Reflection
Good day to you all. 'Tis another Tuesday and time for a new blog post. This is a continuation of the series on Dialogs and further, a continuation of the mini-series-within-a-series on file Dialogs. The subject is in the title as is fitting for a blog post about putting things in the titlebar. You can find it here: http://gtkdcoding.com/2019/05/28/0039-file-save-as-dialog.html
Create object from a library's Class returns Null
hi there, I have a set of DB entity class in a library and creating Object from another project which linked with the library returns Null. I don't know what's wrong there. the source is like this: a. I have a library with such a structure: gwlib/source/gwlib/entity/nsconf.d with content: -- module gwlib.entity.nsconf; class NSconf { String name; ... } -- b. I use this gwlib library in another project named testobj testobj/source/app.d : -- import gwlib.entity.nsconf; void main() { writeln(Object.factory("gwlib.entity.nsconf.NSConf")); } -- this print out `null`. dub file cofig is : - "dependencies": { "gwlib": {"path":"../gwlib"} }, - And I just tested with DMD and LDC2, the result is a little different, but all the two is returning a null object. I don't know what's the reason. Could someone help with this? Thanks! > I posted the dub version of the whole project on github: https://github.com/dangbinghoo/DObjectCreatTest one can just clone and reproduce the result. --- binghoo dang
Re: rdmd takes 2-3 seconds on a first-run of a simple .d script
On Tuesday, 28 May 2019 at 06:06:24 UTC, Seb wrote: On Tuesday, 28 May 2019 at 05:11:15 UTC, Andre Pany wrote: On Monday, 27 May 2019 at 07:16:37 UTC, BoQsc wrote: [...] I can confirm, without measuring the exact timing, "dmd -run test.d" feels much faster than "rdmd test.d". I would say 1 second instead of 2 seconds. Kind regards André Well, that's because rdmd is an old legacy tool that runs the compiler twice. Use dmd -i or rund (https://github.com/dragon-lang/rund). When I do remember correctly the shebang line has some issue with arguments. #!/usr/bin/env rdmd Just an idea: Instead of removing rdmd, it could be an "alias" to "dmd -i -run"? Kind regards André
Re: rdmd takes 2-3 seconds on a first-run of a simple .d script
On Tuesday, 28 May 2019 at 06:06:24 UTC, Seb wrote: On Tuesday, 28 May 2019 at 05:11:15 UTC, Andre Pany wrote: On Monday, 27 May 2019 at 07:16:37 UTC, BoQsc wrote: [...] I can confirm, without measuring the exact timing, "dmd -run test.d" feels much faster than "rdmd test.d". I would say 1 second instead of 2 seconds. Kind regards André Well, that's because rdmd is an old legacy tool that runs the compiler twice. Use dmd -i or rund (https://github.com/dragon-lang/rund). FOR WINDOWS OPERATING SYSTEMS ONLY Since I run simple D scripts a lot of time, as an experiment I molded a registry tweak that associate .d files with dmd compiler, with those options in combination: http://dlang.k3.1azy.net/dmd-windows.html#switch-i[ http://dlang.k3.1azy.net/dmd-windows.html#switch-run Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Applications\dmd.exe\shell\open\command] @="\"C:\\D\\dmd2\\windows\\bin\\dmd.exe\" \"-i\" \"-run\" \"%1\"" What this Registry Tweak does: Adds file association for .d file type, so that you can run a .d file by double clicking .d file. To use it: 1. create a simple empty text file 2. change its file extension from .txt to .reg 3. copy the above registry instructions into previously created file. 4. double click this newly created .reg file. 5. confirm that you want to apply these registry changes. Downsides I experienced by using dmd -i and -run switches: .obj and .exe file can be seen generated in the same folder as .d file script, while dmd is running your script. However, they are deleted after the .d script is finished running uninterupted. If dmd is interupted while processing .d script - by being terminated, .obj and .exe files might be left undeleted.
Re: Example of append & rectangualar arrays?
On 2019-05-27 13:14:47 +, 9il said: Appender!(T[][]) can append rows of type T[]. It does not check their lengths, the T[][] is an array of arrays, not a matrix. To append columns one needs an array of Appenders, Appenders!(T[])[]. And to have appenders on both dimensions? Appenders!(T[])Appenders!(T[]) --- not tested. I'm using dynamic arrays at the moment which works. As the amount of data is not very high, the overhead shouldn't be critical. My idea to use an appender instead of dynamic arrays was efficency. T[][] can be converted to Slice!(T*, 2) (ndslice matrix) using the mir.ndslice.fuse module [1]. I took a look at mir, but as I understands it, it needs known dimension sizes (matrix). I don't have these, it's all dynamic. Then the matrix can be transposed. Zero cost transposition can be found in the second example at [1]. `ndarray` function can be used [2] to convert matrix back to an array of array. Yes, as said I don't have a matrix more a collection of differently sized dynamic arrays. -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: rdmd takes 2-3 seconds on a first-run of a simple .d script
On Tuesday, 28 May 2019 at 05:11:15 UTC, Andre Pany wrote: On Monday, 27 May 2019 at 07:16:37 UTC, BoQsc wrote: [...] I can confirm, without measuring the exact timing, "dmd -run test.d" feels much faster than "rdmd test.d". I would say 1 second instead of 2 seconds. Kind regards André Well, that's because rdmd is an old legacy tool that runs the compiler twice. Use dmd -i or rund (https://github.com/dragon-lang/rund).