Re: Access violation when using IShellFolder2
On Wednesday, 9 September 2020 at 07:18:04 UTC, John Chapman wrote: On Tuesday, 8 September 2020 at 22:24:22 UTC, FreeSlave wrote: However if I change the type of recycleBin variable to IShellFolder (not IShellFolder2), the crash does not happen. Does IShellFolder2 require some special handling? The issue is caused by druntime's definition of IShellFolder2. To fix it temporarily, just redefine it in your module somewhere: interface IShellFolder2 : IShellFolder { HRESULT GetDefaultSearchGUID(GUID*); HRESULT EnumSearches(IEnumExtraSearch*); HRESULT GetDefaultColumn(DWORD, ULONG*, ULONG*); HRESULT GetDefaultColumnState(UINT, SHCOLSTATEF*); HRESULT GetDetailsEx(LPCITEMIDLIST, const(SHCOLUMNID)*, VARIANT*); HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*); HRESULT MapColumnToSCID(UINT, SHCOLUMNID*); } IShellFolder2 isn't the only culprit - IShellView2 will need fixing too if you intend to use it. There are probably others as well. Redefinition did the trick, thank you. Btw do you know how to parse a date returned by GetDetailsOf? Couldn't find any examples in C++. I actually can see digits representing date and time as a part of the string, but I would prefer to use some winapi function to translate it into some time type instead of manually parsing the result.
Re: How to use labeled break in static foreach?
https://run.dlang.io/is/xiqi4P not pretty :)) but ...
Re: How to use labeled break in static foreach?
On Wednesday, 9 September 2020 at 17:02:26 UTC, visitor wrote: On Friday, 14 February 2020 at 06:41:02 UTC, cc wrote: import std.meta; enum A = AliasSeq!(1, 2, 3, 4); static foreach (idx, field; A) { static if (__traits(compiles, THREELOOP)) {} else { static if (field == 3) { pragma(msg, "Got a 3!"); enum THREELOOP = 1; // works with enum, alias etc... } static if (idx == A.length - 1) { static assert(0, "Got no 3..."); } } } https://run.dlang.io/is/BDmIml oops the online editor saved a mix of an old iteration and a new one ... (probably my fault) import std.stdio; float test(float x) { float r = -1; static foreach(i; 0 .. 100) { static if (__traits(compiles, Check)) {} else { static if (i == 10) enum Check = 1; r = i * x; } } return r; } void main() { float ret = test(4.2); writefln("ret = %s", ret); }
Re: How to use labeled break in static foreach?
On Friday, 14 February 2020 at 06:41:02 UTC, cc wrote: import std.meta; enum A = AliasSeq!(1, 2, 3, 4); static foreach (idx, field; A) { static if (__traits(compiles, THREELOOP)) {} else { static if (field == 3) { pragma(msg, "Got a 3!"); enum THREELOOP = 1; // works with enum, alias etc... } static if (idx == A.length - 1) { static assert(0, "Got no 3..."); } } } https://run.dlang.io/is/BDmIml
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 9 September 2020 at 15:30:33 UTC, Shaleen Chhabra wrote: [snip] Hi, I updated my dmd version to dmd-2.093.1 Now it throws a conflict error between 1. function mir.ndslice.topology.iota!(long, 1LU).iota at mir/ndslice/topology.d(630) conflicts with function std.range.iota!int.iota at /home/shaleen/.dvm/compilers/dmd-2.093.1/linux/bin/../../src/phobos/std/range/package.d 2. template mir.ndslice.topology.map(fun...) if (fun.length) at mir/ndslice/topology.d(2565) conflicts with template std.algorithm.iteration.map(fun...) if (fun.length >= 1) at /home/shaleen/.dvm/compilers/dmd-2.093.1/linux/bin/../../src/phobos/std/algorithm/iteration.d(482) Below would generate the same error for iota. There are iota functions in std.range and mir.ndslice.topology and the compiler does not know which one to use. You can use one or the other or use static imports. In the future, it will be a little easier to identify the issues if you post the code as well. You can also start with simpler examples and work your way to larger ones. ``` /+dub.sdl: dependency "mir-algorithm" version="*" +/ import std.range; import mir.ndslice.topology; void main() { auto x = iota(5); } ```
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 9 September 2020 at 11:43:16 UTC, Fynn Schröder wrote: On Wednesday, 9 September 2020 at 11:36:56 UTC, Shaleen Chhabra wrote: but i am unable to configure the libraries, have dmd v2.076.1 installed on my PC. DMD v2.076 is ancient (almost 2 years old!). Current is DMD 2.093.1. I can only recommend to download and install an up-to-date version of DMD or LDC. This should solve your issues with using the mir libraries (and others). Then, try to get a simple example from numir working with your installation. Hi, I updated my dmd version to dmd-2.093.1 Now it throws a conflict error between 1. function mir.ndslice.topology.iota!(long, 1LU).iota at mir/ndslice/topology.d(630) conflicts with function std.range.iota!int.iota at /home/shaleen/.dvm/compilers/dmd-2.093.1/linux/bin/../../src/phobos/std/range/package.d 2. template mir.ndslice.topology.map(fun...) if (fun.length) at mir/ndslice/topology.d(2565) conflicts with template std.algorithm.iteration.map(fun...) if (fun.length >= 1) at /home/shaleen/.dvm/compilers/dmd-2.093.1/linux/bin/../../src/phobos/std/algorithm/iteration.d(482)
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 9 September 2020 at 11:44:35 UTC, Fynn Schröder wrote: On Wednesday, 9 September 2020 at 11:43:16 UTC, Fynn Schröder wrote: DMD v2.076 is ancient (almost 2 years old!) typo: its almost 3 years old thanks, I have upgraded my dmd to latest version. I now import numir and face this error: /home/.dub/packages/mir-core-1.1.11/mir-core/source/mir/math/ieee.d:974: undefined reference to `_D3mir10checkedint4addsFNaNbNiNfiiKbZi' collect2: error: ld returned 1 exit status Error: linker exited with status 1 ../blackbird//etc/build.makefile:295: recipe for target 'tools/mir_utils.d:unittest' failed make: *** [tools/mir_utils.d:unittest] Error 1 What can be the reason?
Re: bindbc OpenGL ES
On Monday, 31 August 2020 at 22:25:48 UTC, Mike Parker wrote: On Monday, 31 August 2020 at 14:04:19 UTC, Danny Arends wrote: Don't know exactly where to post this, so I hope the bindbc team will see the post here in learn. I was wondering if it would be possible to have bindbc OpenGL ES bindings ? I can make time for it sometime this week. Hey Mike, Started with OpenGL ES bindings in bindbc style, find them here: https://github.com/DannyArends/bindbc-gles Danny
Re: Named parameters in function call
On Wednesday, 9 September 2020 at 11:48:28 UTC, Paul Backus wrote: On Tuesday, 8 September 2020 at 13:28:22 UTC, Cecil Ward wrote: I wonder if there is any way in which we could combine this with strong typing of some sort (how?) to detect errors such as int xcoord; int ycoord; myfunc( x : ycoord, y : xcoord, color : blue )[3] where the arguments are the wrong way around. Would have to change the types of the xcoord and ycoord variables somehow, something I have asked about earlier. import std.typecons: Typedef; alias XCoord = Typedef!(int, int.init, "XCoord"); alias YCoord = Typedef!(int, int.init, "YCoord"); auto myfunc(XCoord x, YCoord y) { ... } Brilliant. Thank you Paul.
Re: Named parameters in function call
On Tuesday, 8 September 2020 at 13:28:22 UTC, Cecil Ward wrote: I wonder if there is any way in which we could combine this with strong typing of some sort (how?) to detect errors such as int xcoord; int ycoord; myfunc( x : ycoord, y : xcoord, color : blue )[3] where the arguments are the wrong way around. Would have to change the types of the xcoord and ycoord variables somehow, something I have asked about earlier. import std.typecons: Typedef; alias XCoord = Typedef!(int, int.init, "XCoord"); alias YCoord = Typedef!(int, int.init, "YCoord"); auto myfunc(XCoord x, YCoord y) { ... }
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 9 September 2020 at 11:43:16 UTC, Fynn Schröder wrote: DMD v2.076 is ancient (almost 2 years old!) typo: its almost 3 years old
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 9 September 2020 at 11:36:56 UTC, Shaleen Chhabra wrote: but i am unable to configure the libraries, have dmd v2.076.1 installed on my PC. DMD v2.076 is ancient (almost 2 years old!). Current is DMD 2.093.1. I can only recommend to download and install an up-to-date version of DMD or LDC. This should solve your issues with using the mir libraries (and others). Then, try to get a simple example from numir working with your installation.
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 9 September 2020 at 11:30:58 UTC, Shaleen Chhabra wrote: On Wednesday, 2 September 2020 at 08:19:30 UTC, 9il wrote: On Wednesday, 2 September 2020 at 07:01:48 UTC, Shaleen Chhabra wrote: Hi, The libmir libraries can be found here: https://github.com/libmir I wish to use mir-algorithm and numir so that i can directly use .npy format from python and perform the required analysis. I checked out latest commits of each of the libraries mentioned --> mir-algorithm, mir-random and numir. But they don't seem to build together. what are the correct dependencies for each library. You can just import numir, it will automatically include mir-algorithm, mir-core, and mir-random. https://github.com/libmir/numir/blob/master/dub.json#L9 TASK: how can i read / write mir.ndslice matrices and in what preferable format, an example should be good. I also wish to read / write in .npy format, how can i do this? import std.stdio; import mir.ndslice; void main() { auto mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].fuse; writefln("%(%(%d %)\n%)", mat); writeln(); writefln("[%(%(%d %)\n %)]", mat); writeln(); writefln("[%([%(%d %)]%|\n %)]", mat); writeln(); } See also https://dlang.org/phobos/std_format.html Hi I ran dub build on the numir library, it fetched some dependencies from dub.json. But there was an error ../../.dub/packages/mir-core-1.1.10/mir-core/source/mir/conv.d(9,15): Error: module lifetime is in file 'core/lifetime.d' which cannot be read when i do dub build. Also, do i need to upgrade my dmd version in order to get it working? The task which i want to achieve is: From scratch, i need numir and mir-algorithm to work on my system as a part of one of my repositories. I need to achieve the following targets as the first go and then use mir-algorithm to perform the needful research. 1. Load/save mir.ndslice arrays in NPY format 2. Load/save mir.sparse arrays in coordinate format as NPY files but i am unable to configure the libraries, have dmd v2.076.1 installed on my PC. thanks
Re: How to use libmir --> mir-algorithm, numir, mir-random?
On Wednesday, 2 September 2020 at 08:19:30 UTC, 9il wrote: On Wednesday, 2 September 2020 at 07:01:48 UTC, Shaleen Chhabra wrote: Hi, The libmir libraries can be found here: https://github.com/libmir I wish to use mir-algorithm and numir so that i can directly use .npy format from python and perform the required analysis. I checked out latest commits of each of the libraries mentioned --> mir-algorithm, mir-random and numir. But they don't seem to build together. what are the correct dependencies for each library. You can just import numir, it will automatically include mir-algorithm, mir-core, and mir-random. https://github.com/libmir/numir/blob/master/dub.json#L9 TASK: how can i read / write mir.ndslice matrices and in what preferable format, an example should be good. I also wish to read / write in .npy format, how can i do this? import std.stdio; import mir.ndslice; void main() { auto mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].fuse; writefln("%(%(%d %)\n%)", mat); writeln(); writefln("[%(%(%d %)\n %)]", mat); writeln(); writefln("[%([%(%d %)]%|\n %)]", mat); writeln(); } See also https://dlang.org/phobos/std_format.html Hi I ran dub build on the numir library, it fetched some dependencies from dub.json. But there was an error ../../.dub/packages/mir-core-1.1.10/mir-core/source/mir/conv.d(9,15): Error: module lifetime is in file 'core/lifetime.d' which cannot be read when i do dub build. Also, do i need to upgrade my dmd version in order to get it working?
Re: Range checked assignment
On Tuesday, 8 September 2020 at 16:04:29 UTC, Harry Gillanders wrote: On Tuesday, 8 September 2020 at 14:18:14 UTC, Cecil Ward wrote: [...] If you want to define an integral-like type which is more-or-less interchangeable with the native integral types, you'll need to provide the following overloads and members: [...] Harry, thank you indeed for your generous help. Much appreciated.
Re: Named parameters in function call
On Tuesday, 8 September 2020 at 13:28:22 UTC, Cecil Ward wrote: int xcoord; int ycoord; You can define your own types, of course: struct xcoord { int x; alias x this; } struct ycoord { int y; alias y this; } void myfunc(xcoord x; ycoord y, color c) {}
Re: Access violation when using IShellFolder2
On Tuesday, 8 September 2020 at 22:24:22 UTC, FreeSlave wrote: However if I change the type of recycleBin variable to IShellFolder (not IShellFolder2), the crash does not happen. Does IShellFolder2 require some special handling? The issue is caused by druntime's definition of IShellFolder2. To fix it temporarily, just redefine it in your module somewhere: interface IShellFolder2 : IShellFolder { HRESULT GetDefaultSearchGUID(GUID*); HRESULT EnumSearches(IEnumExtraSearch*); HRESULT GetDefaultColumn(DWORD, ULONG*, ULONG*); HRESULT GetDefaultColumnState(UINT, SHCOLSTATEF*); HRESULT GetDetailsEx(LPCITEMIDLIST, const(SHCOLUMNID)*, VARIANT*); HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*); HRESULT MapColumnToSCID(UINT, SHCOLUMNID*); } IShellFolder2 isn't the only culprit - IShellView2 will need fixing too if you intend to use it. There are probably others as well.