log for complex
Simple question: how do I get the log of a complex number? If I try the simple logtest = log(complex(1.0, 2.0)) I get the compiler error Error: function core.stdc.math.log(double x) is not callable using argument types (Complex!double) Some basic functions are described in https://dlang.org/phobos/std_complex.html, but not the log...
Re: can't build libuid examples
On Tuesday, 6 March 2018 at 19:19:05 UTC, greatsam4sure wrote: Try to build libuid examples get the following error. dub build, build successfully on the root folder. I will appreciate any help. Just try to build a gui app using dlang. OPTLINK (R) for Win32 Release 8.00.17 Those "Undefined Symbol" errors all mean you aren't linking with the libui library. Looking at the dub.json for libuid, it obviously *is* configured to link with libui to build the examples: https://github.com/mogud/libuid/blob/c36e994df238f03516abbb4a75ed054e44b602b5/dub.json#L21 However, if you read the project README, you'll see this: libuid is a binding of libui. So you have to build libui first. Did you do so? libuid provides the proper version of the libui source via a git submodule. If you did build it, you probably used Visual Studio. In which case, you also see this in the README: You can use --arch to specify architecture of you platform. Note in windows, use --arch=x86_mscoff to create 32bit binary. By default, DMD uses the OPTLINK linker, which expects object files in the OMF format and is incompatible with binaries produced by Visual Studio (which uses the COFF format). Passing --arch=x86_mscoff on your dub command line will cause DMD to use the MS linker instead of OPTLINK.
Setting executable's information by resources
I'm trying to use this resource to set executable's information/metadata but it fail to set anything but the icon, without any error message. Could anyone point out if there's anything wrong with my approach? (if anyone use a different approach/toolset to set those data, your suggestion is very welcome) commands: C:\dm\bin\rcc.exe -32 -D__NT__ res.rc dmd app.d res.res resource file IDI_ICON1 ICONDISCARDABLE "ico.ico" #include "version.h" VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION PRODUCTVERSION VER_PRODUCTVERSION BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName",VER_COMPANYNAME_STR VALUE "FileDescription",VER_FILEDESCRIPTION_STR VALUE "FileVersion",VER_FILEVERSION_STR VALUE "InternalName", VER_INTERNALNAME_STR VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR VALUE "ProductName",VER_PRODUCTNAME_STR VALUE "ProductVersion", VER_PRODUCTVERSION_STR END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END
Re: Profiling after exit()
On Thursday, 27 July 2017 at 15:16:35 UTC, Eugene Wissner wrote: Are there profilers that work well with dmd? valgrind? OProfile? Yes, any sampling profiler works fine, e.g. perf on linux, Intel VTune/AMD CodeXL on Windows. Those directly monitor CPU performance counters and have a negligible performance overhead compared with dmd's instrumenting profiler, also they don't require rebuilding of binaries.
Re: How to use globals correctly?
On Tuesday, March 06, 2018 11:52:05 H. S. Teoh via Digitalmars-d-learn wrote: > On Tue, Mar 06, 2018 at 11:46:04AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Tuesday, March 06, 2018 18:34:34 bauss via Digitalmars-d-learn wrote: > [...] > > > > Singletons are always smelly code tbh. > > > > > > Especially in D with thread-local storage. > > > > > > I can't think of a situation where you truly need singletons in D. > > > > I confess that I've never really understood why some folks dislike > > singletons so much, but then again, I've only rarely found cases where > > I thought that they made sense, and I gather that some folks out there > > use the singleton pattern way too much (I've heard it suggested that > > it's because it was one of the few design patterns from the design > > pattern book that was easy). > > [...] > > To me, a singleton is a symptom of excessive dogmatic adherence to the > OO religion where Everything Must Be A Class No Matter What. When there > can only be one of something, it's clearly no longer a *class*, but is > either a module, a global variable, or a (set of) global function(s). > > I'm curious to know what are the few cases where you think a singleton > made sense, where it wouldn't be more appropriately implemented as a > module, global variable, or global function(s). It makes sense whenever it doesn't make sense to have multiple instances of a particular class, and it makes sense to enforce that. As I explained, LocalTime and UTC from std.datetime do that for exactly that reason. Cases like that are rare, but they do exist. However, they also exist rarely enough that it's going to be hard to come up with more examples. I judge whether singletons makes sense on a case-by-case basis. Sometimes, they do make sense, so I wouldn't say that they're necessarily a code smell, but I also completely agree that they rarely make sense. So, I don't disagree that singletons should rarely be used. I just disagree with the idea that they should never be used. And for better or worse, singletons are one of those things that seems to me like it should usually be obvious whether they make sense in a particular case, but that doesn't seem to be true for everyone, otherwise there wouldn't be as much of a dislike of singletons as there seems to be, since they wouldn't come up very often. - Jonathan M Davis
Re: See docs compiler message
On 3/6/18 9:50 AM, ixid wrote: On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer wrote: Now, there aren't actually docs for Transposed, but you can find it if you look at std.range.transposed: https://dlang.org/phobos/std_range.html#transposed Thanks, I had found that but that is not an explanation unless you have a lot of prior technical understanding of what save is and why it's not working. I guess it's a general doc quality issue - unless you're already very knowledgeable it's pretty much useless to understand the problem you have. There are 2 problems. One is that Transposed offered .save as a member, when it shouldn't have (it's not a valid forward range). This is clear from trying to even use it as a forward range. Even when you call save, it destroys the original. The other problem is that I think algorithms are seeing that .save is there, and thinking it's a forward range, so using it that way. I transposed a range of ranges to pass to a function to get the distance between characters in strings. That works fine, as does printing the result. But it then complains if I try to do anything like fold with the result. I have no idea how save is called, but apparently it is somewhere in there. -Steve
Re: How to use globals correctly?
On Tue, Mar 06, 2018 at 11:46:04AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, March 06, 2018 18:34:34 bauss via Digitalmars-d-learn wrote: [...] > > Singletons are always smelly code tbh. > > > > Especially in D with thread-local storage. > > > > I can't think of a situation where you truly need singletons in D. > > I confess that I've never really understood why some folks dislike > singletons so much, but then again, I've only rarely found cases where > I thought that they made sense, and I gather that some folks out there > use the singleton pattern way too much (I've heard it suggested that > it's because it was one of the few design patterns from the design > pattern book that was easy). [...] To me, a singleton is a symptom of excessive dogmatic adherence to the OO religion where Everything Must Be A Class No Matter What. When there can only be one of something, it's clearly no longer a *class*, but is either a module, a global variable, or a (set of) global function(s). I'm curious to know what are the few cases where you think a singleton made sense, where it wouldn't be more appropriately implemented as a module, global variable, or global function(s). T -- Старый друг лучше новых двух.
Re: Speed of math function atan: comparison D and C++
On Tuesday, 6 March 2018 at 18:41:15 UTC, H. S. Teoh wrote: The fix itself may be straightforward, but how to do it without breaking tons of existing code and provoking user backlash is the tricky part. [snip] Ah, I see what you're saying. People may be depending on the extra accuracy for these functions. Would just require something like double sin(double x) @safe pure nothrow @nogc { version (FP_Math) { ///double sin implementation } else { return sin(cast(real) x); } }
can't build libuid examples
Try to build libuid examples get the following error. dub build, build successfully on the root folder. I will appreciate any help. Just try to build a gui app using dlang. OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(App) Error 42: Symbol Undefined _uiControlDestroy ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(App) Error 42: Symbol Undefined _uiMain ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowTitle ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetTitle ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowPosition ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetPosition ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowCenter ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowContentSize ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetContentSize ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowFullscreen ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetFullscreen ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowBorderless ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetBorderless ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetChild ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowMargined ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowSetMargined ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiOpenFile ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiSaveFile ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiMsgBox ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiMsgBoxError ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiNewWindow ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowOnPositionChanged ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowOnContentSizeChanged ..\..\AppData\Roaming\dub\packages\libuid-0.0.7\libuid\.dub\build\lib-debug-windows-x86-dmd_2079-7AA4D084E1AB1DF72ADCC536E95F2BDA\uid.lib(Window) Error 42: Symbol Undefined _uiWindowOnClosing
Re: How to use globals correctly?
On Tuesday, March 06, 2018 18:34:34 bauss via Digitalmars-d-learn wrote: > On Monday, 5 March 2018 at 19:51:33 UTC, Steven Schveighoffer > > wrote: > > On 3/5/18 2:25 PM, Marc wrote: > >> Can __gshared be used instead of static in the singleton > >> pattern? I, comming from C++, ignorantly, have never used > >> _gshared so I went to static instead of (being static also > >> means thread-safe, as far I know)... > > > > static in D is thread safe, because it's thread-local. > > __gshared is shared between threads, so it's not thread safe, > > but has the exact same type as just static data. > > > > Can you use it for singleton? Sure, classic singleton is shared > > between threads. But using thread-local data, you can solve the > > singleton problem in a better way: > > > > https://wiki.dlang.org/Low-Lock_Singleton_Pattern > > > > Note, it still uses __gshared, which means it doesn't protect > > you from race conditions when you actually USE the singleton > > object. This means you need some synchronization inside the > > methods. > > > > -Steve > > Singletons are always smelly code tbh. > > Especially in D with thread-local storage. > > I can't think of a situation where you truly need singletons in D. I confess that I've never really understood why some folks dislike singletons so much, but then again, I've only rarely found cases where I thought that they made sense, and I gather that some folks out there use the singleton pattern way too much (I've heard it suggested that it's because it was one of the few design patterns from the design pattern book that was easy). In fact, one of my coworkers was telling me at one point about how someone had argued to him about how a "doubleton" pattern made sense, which just seems crazy to me, but I've found that a disturbingly large percentage of programmers are not what I would consider competent. I think that the singleton pattern should be used when it really makes sense to use it, but in most cases, there's no reason to restrict the type to a singleton. And I expect that the dislike for singletons comes from them being used far too often when it clearly made no sense. The one place that I can think of that I've used singletons in the last decade or so is with the LocalTime and UTC classes for time zones (both in std.datetime and in the C++ version that I wrote for work at one point). Having multiple instances of those classes made no sense and would have been pointlessly inefficient. But at the moment, that's the only case I can think of where I've used singletons. They just don't make sense very often. - Jonathan M Davis
Re: Speed of math function atan: comparison D and C++
On Tue, Mar 06, 2018 at 06:05:59PM +, jmh530 via Digitalmars-d-learn wrote: > On Tuesday, 6 March 2018 at 17:51:54 UTC, H. S. Teoh wrote: > > [snip] > > > > I'm not advocating for getting *rid* of 80-bit float support, but > > only to make it *optional* rather than the default, as currently > > done in std.math. [...] > Aren't there two issues: 1) std.math functions that cast to real to > perform calculations, 2) the compiler sometimes converts things to > real in the background when people don't want it to. > > Number 1 seems straightforward to fix. Introduce new versions of the > std.math functions for float/double and the user can cast to real if > the additional accuracy is necessary. The fix itself may be straightforward, but how to do it without breaking tons of existing code and provoking user backlash is the tricky part. > Number 2 would require a compiler switch, I imagine. It may not always be the compiler's fault. In the case of x87, it's the hardware itself that internally promotes to 80-bit and truncates later. IIRC, the original intent was that user code would only deal with 64-bit, and the 80-bit stuff would only happen inside the x87 (C, for example, does not provide direct access to this type, except via vendor extensions). However, due to the necessity to be able to save intermediate computational states, there are instructions that can load/extract 80-bit intermediate values to/from the x87, and eventually people ended up just using these instructions for working with the 80-bit type directly. You can suppress the compiler from issuing these instructions, but 64-bit doubles may still be internally converted by the hardware to 80-bit intermediate values during computation. But I suppose you could force the compiler to use SSE instructions for double operations instead of x87, then it would bypass the 80-bit intermediate values completely. T -- Being able to learn is a great learning; being able to unlearn is a greater learning.
Re: How to use globals correctly?
On Monday, 5 March 2018 at 19:51:33 UTC, Steven Schveighoffer wrote: On 3/5/18 2:25 PM, Marc wrote: Can __gshared be used instead of static in the singleton pattern? I, comming from C++, ignorantly, have never used _gshared so I went to static instead of (being static also means thread-safe, as far I know)... static in D is thread safe, because it's thread-local. __gshared is shared between threads, so it's not thread safe, but has the exact same type as just static data. Can you use it for singleton? Sure, classic singleton is shared between threads. But using thread-local data, you can solve the singleton problem in a better way: https://wiki.dlang.org/Low-Lock_Singleton_Pattern Note, it still uses __gshared, which means it doesn't protect you from race conditions when you actually USE the singleton object. This means you need some synchronization inside the methods. -Steve Singletons are always smelly code tbh. Especially in D with thread-local storage. I can't think of a situation where you truly need singletons in D.
Re: Speed of math function atan: comparison D and C++
On Tuesday, 6 March 2018 at 17:51:54 UTC, H. S. Teoh wrote: [snip] I'm not advocating for getting *rid* of 80-bit float support, but only to make it *optional* rather than the default, as currently done in std.math. T Aren't there two issues: 1) std.math functions that cast to real to perform calculations, 2) the compiler sometimes converts things to real in the background when people don't want it to. Number 1 seems straightforward to fix. Introduce new versions of the std.math functions for float/double and the user can cast to real if the additional accuracy is necessary. Number 2 would require a compiler switch, I imagine.
Re: What's the proper way to add a local file dependence to dub?
On 2018-03-04 17:46, Marc wrote: then copy it to sources folder? let's say I have a small library folder at C:\mylibrary\D where I want to use dir.d from it. How do I add that file dependence to dub? But I do not want to that file be passed directly to dmd, I want to that file be copied to application's source folder (so it's easy to distribuite, with the dependences together as possible) then compiled. So, what I want to some extension is dub work with loca files. Is this possible to do solely with dub? I know I can easily write a script to run before dub which copies the dependence files from C:\mylibrary to application's source but I'm looking for a more elegant approach as possible; I'm afraid of rewriting a makefile-like soon (I find cmake/make/makefiles just ugly). You can use "preGenerateCommands" or "preBuildCommands" to run arbitrary commands before Dub builds the project [1]. Alternativly you can use the "import" expression [2], together with the "stringImportPaths" Dub build setting. The "import" expression will embed the file into the executable as a string literal. [1] https://code.dlang.org/package-format?lang=sdl#build-settings [2] https://dlang.org/spec/expression.html#import_expressions -- /Jacob Carlborg
Re: Is it possible to return the subclass from a method of the parent class in dlang?
On 2018-03-02 21:23, Christian Köstlin wrote: To give an example: class Thread { ... Thread start() {...} } class Timer : Thread { ... } void main() { // Timer timer = new Timer().start; // this does not work auto timer = new Timer().start; // because timer is of type Thread } You can also try a template this parameter [1] in the base class: class Thread { T start(this T) () { ... } } But if this "Thread" is core.thread.Thread that won't work. [1] https://dlang.org/spec/template.html#template_this_parameter -- /Jacob Carlborg
Re: Speed of math function atan: comparison D and C++
On Tue, Mar 06, 2018 at 08:12:57AM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2018-03-05 20:11:06 +, H. S. Teoh said: > > > Walter has been adamant that we should always compute std.math.* > > functions with the `real` type, which on x86 maps to the non-IEEE > > 80-bit floats. However, 80-bit floats have been deprecated for a > > while now, > > Hi, do you have a reference for this? I can't believe this, as the > 80-bit are pretty important for a lot of optimization algorithms. We > use it all the time and it's absolutly necessary. [...] http://www.zdnet.com/article/nvidia-de-optimizes-physx-for-the-cpu/?tag=nl.e539 Quotation: Intel started discouraging the use of x87 with the introduction of the P4 in late 2000. AMD deprecated x87 since the K8 in 2003, as x86-64 is defined with SSE2 support; VIA’s C7 has supported SSE2 since 2005. In 64-bit versions of Windows, x87 is deprecated for user-mode, and prohibited entirely in kernel-mode. Pretty much everyone in the industry has recommended SSE over x87 since 2005 and there are no reasons to use x87, unless software has to run on an embedded Pentium or 486. I'm not advocating for getting *rid* of 80-bit float support, but only to make it *optional* rather than the default, as currently done in std.math. T -- Once bitten, twice cry...
Re: See docs compiler message
On Tuesday, 6 March 2018 at 14:50:05 UTC, ixid wrote: On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer wrote: Now, there aren't actually docs for Transposed, but you can find it if you look at std.range.transposed: https://dlang.org/phobos/std_range.html#transposed -Steve Thanks, I had found that but that is not an explanation unless you have a lot of prior technical understanding of what save is and why it's not working. I guess it's a general doc quality issue - unless you're already very knowledgeable it's pretty much useless to understand the problem you have. I transposed a range of ranges to pass to a function to get the distance between characters in strings. That works fine, as does printing the result. But it then complains if I try to do anything like fold with the result. What is the correct way to iterate a range of ranges as transposed does?
dub preBuildCommand not working
I added the followiing to my dub.json: "preBuildCommand": [ "C:\\Users\\user003\\Desktop\\Nova pasta\\a.exe", "C:\\dm\\bin\\rcc.exe -32 -D__NT__ res.rc -o sources\\res.res" ] But neither command is executed. "C:\\Users\\user003\\Desktop\\Nova pasta\\a.exe" is a D application created by myself to check if that command is being run. It creates a text file when it does run. What possibily can be? I've tried: dub dub --build=debug dub --build-release and dub clear then all the build attempts again but none worked. I getting to know dub so I still have no idea what can be.
Re: See docs compiler message
On Tuesday, 6 March 2018 at 14:37:27 UTC, Steven Schveighoffer wrote: Now, there aren't actually docs for Transposed, but you can find it if you look at std.range.transposed: https://dlang.org/phobos/std_range.html#transposed -Steve Thanks, I had found that but that is not an explanation unless you have a lot of prior technical understanding of what save is and why it's not working. I guess it's a general doc quality issue - unless you're already very knowledgeable it's pretty much useless to understand the problem you have. I transposed a range of ranges to pass to a function to get the distance between characters in strings. That works fine, as does printing the result. But it then complains if I try to do anything like fold with the result.
Re: See docs compiler message
On 3/6/18 9:28 AM, ixid wrote: /opt/compilers/dmd2/include/std/algorithm/iteration.d(663): Deprecation: function `std.range.Transposed!(string[], cast(TransverseOptions)0).Transposed.save` is deprecated - This function is incorrect and will be removed November 2018. See the docs for more details. If it's going to say 'See the docs' how about linking the docs or even just specifying which docs it's referring to? It's referring to the docs for std.range.Transposed.save (the deprecated symbol) I thought that was clear. Now, there aren't actually docs for Transposed, but you can find it if you look at std.range.transposed: https://dlang.org/phobos/std_range.html#transposed -Steve
Re: See docs compiler message
On Tuesday, 6 March 2018 at 14:28:52 UTC, ixid wrote: /opt/compilers/dmd2/include/std/algorithm/iteration.d(663): Deprecation: function `std.range.Transposed!(string[], cast(TransverseOptions)0).Transposed.save` is deprecated - This function is incorrect and will be removed November 2018. See the docs for more details. If it's going to say 'See the docs' how about linking the docs or even just specifying which docs it's referring to? I agree that compiler error messages should be improved. If you are still wondering though, https://dlang.org/phobos/std_range.html#transposed is the relevant documentation
See docs compiler message
/opt/compilers/dmd2/include/std/algorithm/iteration.d(663): Deprecation: function `std.range.Transposed!(string[], cast(TransverseOptions)0).Transposed.save` is deprecated - This function is incorrect and will be removed November 2018. See the docs for more details. If it's going to say 'See the docs' how about linking the docs or even just specifying which docs it's referring to?
Re: Validity of cast(void*)size_t.max
On 3/6/18 1:08 AM, Kagamin wrote: On Monday, 5 March 2018 at 18:28:43 UTC, Steven Schveighoffer wrote: Note, I think the error is bogus, you should be able to create hard-coded addresses of data at compile time -- I'm not sure how you would do hardware registers otherwise. I'd do them as extern variables, it wouldn't be nice to have them as pointers. extern int reg1; And use linker option to define address: --defsym reg1=0x I hadn't thought of that. It's probably a better solution than pointers. However, I would expect D to have a proper way to do this without resorting to linker tricks. -Steve
Generic test bit function (core.bitop)
Hi all, I would like to use bt function (core.bitop) on generic array but it seems that's not possible. I would like to know if there is some reasons to have a fixed type (size_t) instead of something like : pure @system int bt(T)(in T* p,size_t bitnum) if(__traits(isIntegral,T)) { return p[bitnum/ (T.sizeof*8)] & (1 << (bitnum& ((T.sizeof*8) - 1))); } Thank you for your help.
Re: Thread Function does not executes
On Monday, 5 March 2018 at 13:50:28 UTC, Vino wrote: Hi All, Request your help, I have 3 functions such as below, I am calling these function using another function ptManage which executes these function's in parallel as each of the below 3 function run's on 10 - 12 different file systems, The issue is as below Issue: Most of the time the program executes perfectly, some time the function 2 is skipped, after analysis further I was able to find that if the 1st and 3rd functions(deleteFile, SizeDir) completes before the 2nd function(deleteAgedDir) then it skips, meaning the program is not waiting for all the thread to be completed before exiting the main. so any help on this would be much appreciated. Ti does not throw any exception or error the program exits' smoothly. Function: deleteFile : Delete file after a certain date deleteAgedDir : Delete folder after a certain date SizeDir : Finde Size of folder after a certain date Ex: auto deleteFile (string FFs, int AgeSize) { } auto deleteAgedDir (string FFs, int AgeSize) { } auto SizeDir (string FFs, int AgeSize) { auto TP = new TaskPool(TL); foreach (d; TP.parallel(dFiles[],1)) { Thread.sleep(5.seconds); TP.finish; } } void ptManage(T)(T function(string, string, int) coRoutine, Array!string Dirlst, int AgeSize) { alias scRType = typeof(coRoutine(string.init, string.init, int.init)); auto PFresult = taskPool.workerLocalStorage!scRType(); ReturnType!coRoutine rData; foreach (string FFs; parallel(Dirlst[0 .. $],1)) { PFresult.get ~= coRoutine(FFs.strip, Step, AgeSize); } foreach(i; PFresult.toRange) { rData ~= i[][]; } writeln(rData[]); } Void main() { ptManage(, CleanDirlst, AgeSize1); ptManage(, AgedDirlst, AgeSize2); ptManage(, AgeSize3); } From, Vino.B Hi All, On further analysis, as to why the function deleteAgedDir is not getting executed, found that if this function finds a folder to be deleted then it should delete the folder(rmdirRecurse(dirname)), but in this case it does not delete the folder if it finds so the return of this function is empty, if there are no file to be deleted then this function works perfectly but if there is any folder preset to be deleted this that folder is not getting deleted, so i am suspecting that the issue is with the function rmdirRecurse is not working as expected on Windows 2007, so request your help on this please. From, Vino.B
Re: Speed of math function atan: comparison D and C++
On Tuesday, 6 March 2018 at 08:20:05 UTC, J-S Caux wrote: On Tuesday, 6 March 2018 at 07:12:57 UTC, Robert M. Münch wrote: On 2018-03-05 20:11:06 +, H. S. Teoh said: [snip] Now, with Uknown's trick of using the C math functions, I can reconsider. It's a bit of a "patch" but at least it works. I'm glad I could help! In an ideal world, I'd like the language I use to: - have double-precision arithmetic with equal performance to C/C++ - have all basic mathematical functions implemented, including for complex types - *big bonus*: have the ability to do extended-precision arithmetic (integer, but most importantly (complex) floating-point) on-the-fly if I so wish, without having to rely on external libraries. D has std.complex and inbuilt complex types, just like C [0][1]. I modified the mandelbrot generator on Wikipedia, using D's std.complex and didn't have too much of an issue with performance.[2] Also, std.bigint and mir might be of interest to you.[3] C++ was always fine, with external libraries for extended precision, but D is so much more pleasant to use. Many of my colleagues are switching to e.g. Julia despite the performance costs, because it is by design a very maths/science-friendly language. D is however much closer to a whole stack of existing codebases, so switching to it would involve much less extensive refactoring. Theres a good chance D can interface with those libraries you mentioned... [0]: https://dlang.org/phobos/std_complex.html [1]: https://dlang.org/phobos/core_stdc_complex.html [2]: https://github.com/Sirsireesh/Khoj-2017/blob/master/Mandelbrot-set/mandelbrot.d [3]: https://github.com/libmir
Re: Speed of math function atan: comparison D and C++
On Tuesday, 6 March 2018 at 07:12:57 UTC, Robert M. Münch wrote: On 2018-03-05 20:11:06 +, H. S. Teoh said: Walter has been adamant that we should always compute std.math.* functions with the `real` type, which on x86 maps to the non-IEEE 80-bit floats. However, 80-bit floats have been deprecated for a while now, Hi, do you have a reference for this? I can't believe this, as the 80-bit are pretty important for a lot of optimization algorithms. We use it all the time and it's absolutly necessary. and pretty much nobody cares to improve their performance on newer CPUs, Really? focusing instead on SSE/MMX performance with 64-bit doubles. People have been clamoring for using 64-bit doubles by default rather than 80-bit floats, but so far Walter has refused to budge. IMO this is all driven by the GPU/AI hype that just (seems) to be happy with rough precision. Speaking for myself, the reason why I haven't made the switch from C++ to D many years ago for all my scientific work is that for many computations, 64 bit precision is certainly sufficient, and the performance I could get out of D (factor 4 to 6 slower in my tests) was simply insufficient. Now, with Uknown's trick of using the C math functions, I can reconsider. It's a bit of a "patch" but at least it works. In an ideal world, I'd like the language I use to: - have double-precision arithmetic with equal performance to C/C++ - have all basic mathematical functions implemented, including for complex types - *big bonus*: have the ability to do extended-precision arithmetic (integer, but most importantly (complex) floating-point) on-the-fly if I so wish, without having to rely on external libraries. C++ was always fine, with external libraries for extended precision, but D is so much more pleasant to use. Many of my colleagues are switching to e.g. Julia despite the performance costs, because it is by design a very maths/science-friendly language. D is however much closer to a whole stack of existing codebases, so switching to it would involve much less extensive refactoring.
Re: Speed of math function atan: comparison D and C++
On Monday, 5 March 2018 at 20:11:06 UTC, H. S. Teoh wrote: Walter has been adamant that we should always compute std.math.* functions with the `real` type T I don't understand why atan(float) returns real and atan(double) return real too. If I'm working with float, why does it return a real? If you want to comute with real is ok, but shouldn't be T atan(T) rather than real atan(T)? I'm missing something. Andrea