Re: Slides share: DMesos - Not only a re-implementation of Mesos
On Monday, 10 July 2017 at 17:29:01 UTC, 鲜卑拓跋枫 wrote: Dear all, I am a D-language amateur from China, and just want to share you with a slides from me that post on MesosCon Asia 2017(Beijing): https://mesosconasia2017.sched.com/event/AZc6/dmesos-not-only-a-re-implementation-of-mesos-ce-feng-li-emc# I do really wanna to implement the design or "dream" as described in this slides, your help and suggestion are very welcome! Thanks! BRs, Koo 我也希望能用D做出来。 我们也在研究过raft, akka这些技术。 raft算法的翻译我同事也有个port到D版本的。只是具体什么样,我没参与也没关心。 我们也在上海,我看链接里介绍,你现在也在上海工作,在EMC? 只是不知道你们开始做没?
Re: Hiring D programmers (with cryptography and blockchain knowledge are preferred)
On 14/07/2017 1:41 AM, Vitor Rozsas wrote: Hmmm... But how would a criminal post be deleted or removed? Even if decentralized, govs could forbid the use of it (specially having a server of this social media), considering that it's database could contain child pornography (undeletable child pornography - really bad). But it doesn't matter, I have other projects to invest my money on D. I will post the links soon. Anyway its just silly to go for removal of servers. The overhead is far too great. Our compression algo's can't back it up. You'll be talking terabytes just to store a few 'websites' soon enough. Nah, anyway decentralized != anonymous. Even in Tor there are servers. What we need isn't a decentralized http replacement. What we need is a decentralized dns with some form of filters available.
Re: char e string em linguagem D
On Thursday, 13 July 2017 at 22:30:29 UTC, crimaniak wrote: On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar? Se acepta utilizar intervalos en lugar de punteros desnudos. (Hola, soy traductor de google) import std.stdio, std.string; //https://www.vivaolinux.com.br/script/GNU-que-bacana class GnuQueBacana { this(){} char[] stalman() { return cast(char[])` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } char[] torvald() { return cast(char[])` # ### ##O#O## ### ##\#/## #lll## #l## #l### ##### OOO#ll#OOO OO#ll#OO OOO#ll#OOO OOO##OOO https://www.kernel.org `; } string stallman() { return ` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } string torvalds() { return ` # ### ##O#O## ### ##\#/## #lll## #l## #l### ##### OOO#ll#OOO OO#ll#OO OOO#ll#OOO OOO##OOO https://www.kernel.org `; } }; void main() { GnuQueBacana gnu = new GnuQueBacana(); writeln(gnu.stalman(), gnu.torvald(), gnu.stallman(), gnu.torvalds()); } muito massa nao achei que era tao simples assim..
Re: nogc string concatenation?
On Friday, 14 July 2017 at 00:40:38 UTC, FoxyBrown wrote: Anyone have an efficient implementation that is easy to use? If you are OK with just a range spanning the two or more strings, then you could use chain as is.
Re: WTF is going on! Corrupt value that is never assigned
On Friday, 14 July 2017 at 00:33:12 UTC, FoxyBrown wrote: What I'm trying to do is fairly straightforward but I've wasted nearly 2 days on it. //added this so it would all compile import core.sys.windows.windows; import core.stdc.stdio; import core.stdc.stdlib; import std.stdio; import std.conv; import std.array; pragma(lib, "advapi32"); struct ServiceData { wstring Name; wstring LongName; int Type; int State; int ControlsAccepted; int Win32ExitCode; int SpecificExitCode; int CheckPoint; int WaitHint; int ProcessId; int Flags; } auto cstr2dstr(wchar* cstr) { import std.array; auto str = appender!wstring; auto len = lstrlen(cstr); str.reserve(len); for(int i = 0; i < len; i++) str.put(cstr[i]); return str.data; } auto EnumServices() { import core.stdc.stdlib, std.traits; ServiceData[] servicesList; auto buf = malloc(5); // Gets changed later, even though never an assignment auto buf2 = buf; // does not change auto schSCManager = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS); if (NULL == schSCManager) { printf("OpenSCManager failed (%d)\n", GetLastError()); return servicesList; } DWORD dwBytesNeeded, dwCount, lpResumeHandle, resume, totalCount; auto servicesType = (SERVICE_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_KERNEL_DRIVER | SERVICE_WIN32 | SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS); int cnt = 0; auto res = 0; do { // Manually copy over data, this is because EnumSErvicesStatus adds data at end of array for some odd ball reason making it difficult to build the correct array sequentially for(int i = 0; i < dwCount; i++) { ENUM_SERVICE_STATUS_PROCESS x; ServiceData d; auto s = cast(ENUM_SERVICE_STATUS_PROCESS*)(buf + i*ENUM_SERVICE_STATUS_PROCESS.sizeof); //before buf is of correct value d.Name = cstr2dstr(s.lpServiceName); // added these to copy the rest of the fields d.LongName = cstr2dstr(s.lpDisplayName); d.tupleof[2 .. $] = s.ServiceStatusProcess.tupleof; //after buf is invalid, yet buf is never assigned // added this so it actually appends to array servicesList ~= d; } res = EnumServicesStatusEx(schSCManager, SC_ENUM_TYPE.SC_ENUM_PROCESS_INFO, servicesType, SERVICE_STATE_ALL, cast(ubyte*)buf, 5, , , , null); if (ERROR_MORE_DATA != GetLastError()) { printf("Error enumerating services."); break; } } while (res == 0); foreach(s; servicesList) { writeln(s.Name, " - ", s.LongName, " - ", s.Type, " = ", s.State); } return servicesList; } void main() { EnumServices(); } I only modified a few lines in there but it works for me on win64.
Re: Why is dlang.org having so many problems lately? I constantly have issues connecting.
On Friday, 14 July 2017 at 00:26:14 UTC, Steven Schveighoffer wrote: On 7/13/17 8:15 PM, FoxyBrown wrote: ? Pretty much at least several times a day I cannot connect. Either stalls, forum is down, etc. I have noticed that the forum is not as speedy as it used to be. Sometimes I have to reload several times to get a message to show up. We're doing server maintenance that is going to take about a week or two, during which things may be slower than usual. The forum and wiki are affected. Sorry for the inconvenience :)
nogc string concatenation?
Anyone have an efficient implementation that is easy to use?
Re: WTF is going on! Corrupt value that is never assigned
On Thursday, 13 July 2017 at 23:30:39 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 22:53:45 UTC, FoxyBrown wrote: On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the strings, the buf location changes, screwing up the copying process. It shouldn't happen, buf never changes value anywhere except the first malloc(which is once). Somehow it is getting changed, but where? [...] The buf value changes when calling cstr2dstr but I've had it with other values to(any function call such as to!string, etc seems to trigger it). [...] - Does this happen every time, or only sometimes? yes, but I've been having this problem and not sure if it was quite as consistent as before or that I just recognized it. - At which loop iteration does it occur? Now it seems to occur after the first iteration, but I've add it happen after a while and in other cases it's worked.. depends on if I use malloc, or a D array, or what. - Which compiler (+version) are you using (with what flags)? Latest DMD official.. whatever default flags exist in debug mode with visual D... why should it matter? [...] Because it's part of the usual "Steps to reproduce" you are supposed to provide so others can verify what you're encountering. - What are the steps to reproduce (i.e. does this e.g. happen with a main that consist of one call to EnumServices) ? Yes, It is basically the first thing I do when I run my program. [...] Okay, I'll setup a Windows VM when I have time and check it out (unless someone solves it beforehand). because D is not interfacing well with C. First, the win32 function does not simply fill in an array but adds additional junk at the end(didn't know that until after a few wasted hours trying to get it to fill in an array properly). To be fair, that's neither C nor D fault; that's Microsoft providing unintuitive, horrible APIs and doing an amazing job of providing documentation (MSDN) that *appears* to be exhaustive and well written, but misses all these little important details that you actually have to know in order to program correct control logic, driving you to the edge of sanity. Been there, done that. I have generally not had that problem. Usually works as it does and pretty straight forward. Might have to fish a little for info from others but most things have been worked out by someone somewhere. What I'm trying to do is fairly straightforward but I've wasted nearly 2 days on it. I had no issues starting or stopping services but I can't get the enumerate code to work(the winapi function works fine, it's getting the info out of what it passes in to D that is the problem). There is no explanation why buf is being changed, I never change it after it is initialized, yet, it changes somehow. Either it is being overwritten because of a pointer that is invalid or it is a stack problem. It is most likely the former, but I have tried many different ways and they all lead to similar results.
Re: Why is dlang.org having so many problems lately? I constantly have issues connecting.
On 7/13/17 8:15 PM, FoxyBrown wrote: ? Pretty much at least several times a day I cannot connect. Either stalls, forum is down, etc. I have noticed that the forum is not as speedy as it used to be. Sometimes I have to reload several times to get a message to show up. -Steve
Re: proposed @noreturn attribute
On 7/13/17 2:37 PM, Timon Gehr wrote: On Thursday, 13 July 2017 at 17:25:18 UTC, Timon Gehr wrote: Anyway, my assertion that Bottom cannot be a subtype of all other types was actually incorrect: the compiler does not need to generate code for implicit conversion from Bottom to some other type, so it can be treated as a subtype. ... (Actually, there are some complications like the .sizeof property. Anyway, it is clear what the semantics of Bottom are, no matter whether it is subtyping or implicit conversion.) I wonder if sizeof could be made size_t.max. -- Andrei
Why is dlang.org having so many problems lately? I constantly have issues connecting.
? Pretty much at least several times a day I cannot connect. Either stalls, forum is down, etc.
Re: WTF is going on! Corrupt value that is never assigned
On Thursday, 13 July 2017 at 22:53:45 UTC, FoxyBrown wrote: On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the strings, the buf location changes, screwing up the copying process. It shouldn't happen, buf never changes value anywhere except the first malloc(which is once). Somehow it is getting changed, but where? [...] The buf value changes when calling cstr2dstr but I've had it with other values to(any function call such as to!string, etc seems to trigger it). [...] - Does this happen every time, or only sometimes? yes, but I've been having this problem and not sure if it was quite as consistent as before or that I just recognized it. - At which loop iteration does it occur? Now it seems to occur after the first iteration, but I've add it happen after a while and in other cases it's worked.. depends on if I use malloc, or a D array, or what. - Which compiler (+version) are you using (with what flags)? Latest DMD official.. whatever default flags exist in debug mode with visual D... why should it matter? [...] Because it's part of the usual "Steps to reproduce" you are supposed to provide so others can verify what you're encountering. - What are the steps to reproduce (i.e. does this e.g. happen with a main that consist of one call to EnumServices) ? Yes, It is basically the first thing I do when I run my program. [...] Okay, I'll setup a Windows VM when I have time and check it out (unless someone solves it beforehand). because D is not interfacing well with C. First, the win32 function does not simply fill in an array but adds additional junk at the end(didn't know that until after a few wasted hours trying to get it to fill in an array properly). To be fair, that's neither C nor D fault; that's Microsoft providing unintuitive, horrible APIs and doing an amazing job of providing documentation (MSDN) that *appears* to be exhaustive and well written, but misses all these little important details that you actually have to know in order to program correct control logic, driving you to the edge of sanity. Been there, done that. I don't know how any stack corruption could be occurring but that is exactly what it looks like. "Return from function call and "static variables"(with respect to the call) are changed.". But that seems really hard to sell given that it's pretty simple and D should have all those basics well covered. It's always possible for the D compiler to generate wrong code (though I'm not convinced that this is the case here), you should have a look at the generated assembly.
Re: WTF is going on! Corrupt value that is never assigned
On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the strings, the buf location changes, screwing up the copying process. It shouldn't happen, buf never changes value anywhere except the first malloc(which is once). Somehow it is getting changed, but where? [...] The buf value changes when calling cstr2dstr but I've had it with other values to(any function call such as to!string, etc seems to trigger it). [...] - Does this happen every time, or only sometimes? yes, but I've been having this problem and not sure if it was quite as consistent as before or that I just recognized it. - At which loop iteration does it occur? Now it seems to occur after the first iteration, but I've add it happen after a while and in other cases it's worked.. depends on if I use malloc, or a D array, or what. - Which compiler (+version) are you using (with what flags)? Latest DMD official.. whatever default flags exist in debug mode with visual D... why should it matter? buf is changing on the only source of that change could be through the winapi call or the temp pointer used to index it.. which is never assigned to, so it can't be modifying it. The c2d function, when called, clearly has no understanding of buff, yet after it returns, it is causing the problem. This seems like the stack is being corrupted by the function call. - What are the steps to reproduce (i.e. does this e.g. happen with a main that consist of one call to EnumServices) ? Yes, It is basically the first thing I do when I run my program. It is a rather isolated function(Just trying to get a list of current services, which has been a total PITA because D is not interfacing well with C. First, the win32 function does not simply fill in an array but adds additional junk at the end(didn't know that until after a few wasted hours trying to get it to fill in an array properly). Hence now I'm trying to convert the returned data one iteration at a time rather than all at once, but I can't get that to work because the pointer to the buffer I created is changing. I could use a temp and get it to work, but that doesn't explain what the hell is going on. The value of buff seems to be erratic, I've had it point valid stuff(other data) and then have small values in it like 8. I don't know how any stack corruption could be occurring but that is exactly what it looks like. "Return from function call and "static variables"(with respect to the call) are changed.". But that seems really hard to sell given that it's pretty simple and D should have all those basics well covered.
Re: proposed @noreturn attribute
On Saturday, 8 July 2017 at 20:27:11 UTC, H. S. Teoh wrote: Also, a @noreturn attribute would allow overriding a non-void class method with a @noreturn one (e.g. the derived class is a sentinel object that forces an exception / termination upon calling that method), whereas you can't do that with a None return type because the signature would not match the base class's. T The reverse is also true, and more disastrous!
Re: char e string em linguagem D
On Thursday, 13 July 2017 at 22:30:29 UTC, crimaniak wrote: On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: char[] stalman() { return cast(char[])` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } Never cast a literal to char[]. modifying the resulting char[] will lead to AV, at least under linux. `.dup` the literal if you really needs char[].
Re: Compilation times and idiomatic D code
On Thu, Jul 13, 2017 at 04:16:50PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] > http://www.schveiguy.com/blog/2016/05/have-your-voldemort-types-and-keep-your-disk-space-too/ > > I was surprised as well at the reduction. I only noticed the problem > because when I was debugging my library, the program was taking an > unreasonably long time to *print a stack trace* (like multiple > seconds). [...] Whoa. I just tried your 'horcrux' trick, and discovered that it causes a further reduction in executable size! Original sizes: 38144296 bytes (38.1 MB) 61412056 bytes (61.4 MB) After factoring out Voldemort structs as module-global private structs: 8332352 bytes (8.3 MB) 10376584 bytes (10.4 MB) After further refactoring to use the "horcrux" trick: 8147392 bytes (8.1 MB) 10124136 bytes (10.1 MB) While this last reduction is rather modest relative to the total executable sizes, it still represents a reduction of 200KB and 300KB worth of symbols(!) each. Given that this code base is a mere 5000+ LOC, I'd expect significant savings in larger template-heavy projects. My guess as to reason for this reduction is because now you only have to instantiate one template for each template function call, rather than two: private struct MyFuncImpl(Args...) { ... } auto myFunc(Args...)(Args args) { return MyFuncImpl!Args(args); } will instantiate two templates, MyFuncImpl and myFunc, each time with the same argument list; whereas: template myFunc(Args...) { auto myFunc(Args args) { return Impl(args); } struct Impl { ... } } only requires a single template instantiation of myFunc, since Impl is instantiated along with the function itself. There's also the slightly shorter names involved (`myFunc!Args.Impl` vs. `MyFuncImpl!Args.MyFuncImpl`), which, given the O(n^2) or O(n^3) symbol length dependency, can quickly add up to non-trivial amounts of savings. T -- Those who don't understand D are condemned to reinvent it, poorly. -- Daniel N
Re: char e string em linguagem D
On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar? Se acepta utilizar intervalos en lugar de punteros desnudos. (Hola, soy traductor de google) import std.stdio, std.string; //https://www.vivaolinux.com.br/script/GNU-que-bacana class GnuQueBacana { this(){} char[] stalman() { return cast(char[])` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } char[] torvald() { return cast(char[])` # ### ##O#O## ### ##\#/## #lll## #l## #l### ##### OOO#ll#OOO OO#ll#OO OOO#ll#OOO OOO##OOO https://www.kernel.org `; } string stallman() { return ` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } string torvalds() { return ` # ### ##O#O## ### ##\#/## #lll## #l## #l### ##### OOO#ll#OOO OO#ll#OO OOO#ll#OOO OOO##OOO https://www.kernel.org `; } }; void main() { GnuQueBacana gnu = new GnuQueBacana(); writeln(gnu.stalman(), gnu.torvald(), gnu.stallman(), gnu.torvalds()); }
[Issue 17624] typo in Fields documentation section of https://dlang.org/library/object/exception.html
https://issues.dlang.org/show_bug.cgi?id=17624 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/180644a61436a8f3e64f1f8d8ea8ec1d2500c607 Fix Issue 17624 - typo in Fields documentation section of https://dlang.org/library/object/exception.html https://github.com/dlang/druntime/commit/08c1b885b83c0a1268e9aa34ece14fa61403573b Merge pull request #1871 from wilzbach/fix-17624 Fix Issue 17624 - typo in Fields documentation section of object/exception merged-on-behalf-of: David Nadlinger--
[Issue 17641] TypeInfo for two identical delegates (or functions) are not equal to each other
https://issues.dlang.org/show_bug.cgi?id=17641 --- Comment #4 from andron...@gmail.com --- Sorry, I misunderstood you. --
char e string em linguagem D
Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar?
Re: WTF is going on! Corrupt value that is never assigned
On 07/13/2017 08:22 PM, FoxyBrown wrote: res = EnumServicesStatusExW(schSCManager, SC_ENUM_TYPE.SC_ENUM_PROCESS_INFO, servicesType, SERVICE_STATE_ALL, cast(ubyte*)buf, 5, , , , cast(const(char)*)null); The cast to `char*` here looks odd. The 'W' suffix in the function name indicates that it's the UTF-16 variant. It should be taking a `wchar*`, not of a `char*`. This might hint at a wrong declaration which could lead to memory corruption. (The cast shouldn't be necessary anyway. `null` converts to all pointer types.)
Re: Hiring D programmers (with cryptography and blockchain knowledge are preferred)
On Wednesday, 12 July 2017 at 04:40:16 UTC, Vitor Rozsas wrote: So... basically, it's a Bitcoin, but instead of transactions, the blockchain should store posts and profiles. :) And it should have some additional features (the typical things of social media - profile picture, some optional information about the user, etc.). And obviously, it is supposed to be written in D, instead of C++ like the Bitcoin. I also think that this blockchain shouldn't be downloaded by the client like the Bitcoin does. Only the servers need it. Clients will download only the posts that it needs (and requests). why not use the actual bitcoin blockchain? there exists a process called "etching" whereby one may store indelible messages.
Re: Read from terminal when enter is pressed, but do other stuff in the mean time...
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? As Stefan mentions, the single threaded version is basically OS specific (and as others have said there are some wrappers available) the multithreaded solution is fairly simple (have one thread blocked on read(stdin), the other working, synchronize as necessary). If you are interested, on Linux one low level (single threaded) version would essentially consist of: - check on program startup whether the stdin file descriptor refers to something that (sanely) supports readiness events (tty, sockets, pipes, etc. - *not* regular files) using calls like `isatty`[1] and co. - if it's a tty, put it into "raw" mode - get yourself an epoll instance and register stdin with it - get a file descriptor, e.g. an eventfd, for "there's work to be done now" and register it with the epoll instance - have the thread wait for readiness events on the epoll instance and deal with stdin being readable and "there's work to be done now" events for their respective fd. - Queue work on the eventfd as necessary (e.g. from within the readiness handling of the previous step) [1] http://man7.org/linux/man-pages/man3/isatty.3.html
Re: version=D_16
On Monday, 10 July 2017 at 21:30:44 UTC, Walter Bright wrote: You can't use RTTI or Exceptions, for example. Those generate bloat even if they are not used - a compiler switch is typical to disable them. It's not true that C++ is "pay only for what you use". If the C++ usage is "C with member functions", then yes, it'll work and be useful. I use C++ for microcontrollers all the time and I prefer to use exceptions and RTTI for most of my applications. There is a small amount of bloat when using RTTI and exceptions, but the linker is able to strip a large amount of it out, so the cost is minimal and opt-in. I don't see why D couldn't do the same; it just needs to generate code in a way that allows the linker to identify dead code. The only binary size problems I've encountered using C++ is using iostream and formatted IO. Those seem to generate the most bloat. But if you avoid iostream and use a C library designed for microcontrollers (e.g. newlib) it's not a problem. It appear the bloat mostly comes from the standard library, not the language. A recent pull request to GDC (https://github.com/D-Programming-GDC/GDC/pull/505#event-1141470083) removed much of the TypeInfo bloat that was generated when using classes, which has reignited some interest in using D for microcontrollers. Perhaps there's something in that pull request for other compiler developers to learn from. Mike
Re: WTF is going on! Corrupt value that is never assigned
On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the strings, the buf location changes, screwing up the copying process. It shouldn't happen, buf never changes value anywhere except the first malloc(which is once). Somehow it is getting changed, but where? [...] The buf value changes when calling cstr2dstr but I've had it with other values to(any function call such as to!string, etc seems to trigger it). [...] - Does this happen every time, or only sometimes? - At which loop iteration does it occur? - Which compiler (+version) are you using (with what flags)? - What are the steps to reproduce (i.e. does this e.g. happen with a main that consist of one call to EnumServices) ?
Re: Compilation times and idiomatic D code
On 7/13/17 3:23 PM, H. S. Teoh via Digitalmars-d wrote: Today, I decided to sit down and refactor my code. I've heard tell that Voldemort types tend to cause an explosion in symbol size, and today I thought it'd be interesting to see just how big of a difference this actually makes. I could not believe my eyes. Before the refactoring, my executable sizes (I have 2 executables in this codebase) were 37.3MB and 60.0MB, respectively. After the refactoring, my executable sizes were, respectively, 8.2MB and 10.2MB. That's a 5x and 6x reduction in executable size, respectively. Whoa. Yep. http://www.schveiguy.com/blog/2016/05/have-your-voldemort-types-and-keep-your-disk-space-too/ I was surprised as well at the reduction. I only noticed the problem because when I was debugging my library, the program was taking an unreasonably long time to *print a stack trace* (like multiple seconds). -Steve
[Issue 17630] DMD treats imports as public imports when selectively imported
https://issues.dlang.org/show_bug.cgi?id=17630 Jack Stoufferchanged: What|Removed |Added Keywords||accepts-invalid --
Re: DWT is official ?
On 2017-07-12 14:36, Flaze07 wrote: I see... so...is it official ?? Not sure what you mean with "official". The forum or the library? -- /Jacob Carlborg
Re: Slides share: DMesos - Not only a re-implementation of Mesos
On Monday, 10 July 2017 at 17:29:01 UTC, 鲜卑拓跋枫 wrote: Dear all, I am a D-language amateur from China, and just want to share you with a slides from me that post on MesosCon Asia 2017(Beijing): https://mesosconasia2017.sched.com/event/AZc6/dmesos-not-only-a-re-implementation-of-mesos-ce-feng-li-emc# I do really wanna to implement the design or "dream" as described in this slides, your help and suggestion are very welcome! Thanks! GDC: - complete support armel, armhf - partial or bare-metal only support aarch64 Only bare-metal? As far as I'm concerned, all targets have full compiler support. The druntime and phobos libraries less so on that front. ;-) Iain.
Re: Silly struct behaviour
On Thu, Jul 13, 2017 at 06:48:27PM +, JN via Digitalmars-d-learn wrote: > On Thursday, 13 July 2017 at 18:09:46 UTC, H. S. Teoh wrote: > > > > It's not quite so simple. Consider for example: > > > > struct Foo { int bar; } > > struct Oof { int bar; } > > > > void process(Foo foo) { } > > void process(Oof oof) { formatDisk(); } > > > > void main() { > > process({bar : 5}); // which overload should get called? > > } > > > > in this case, I'd expect something like: > > error: ambiguous struct definition, could match process(Foo) or process(Oof) File an enhancement request: https://issues.dlang.org/enter_bug.cgi You never know, we may be able to convince Walter to add this at some point. :-P T -- English has the lovely word "defenestrate", meaning "to execute by throwing someone out a window", or more recently "to remove Windows from a computer and replace it with something useful". :-) -- John Cowan
Re: Compilation times and idiomatic D code
On Wed, Jul 05, 2017 at 09:45:55PM -0600, Jonathan M Davis via Digitalmars-d wrote: [...] > In this case, I think that it's more that Voldemort types are biting > us than that ranges are biting us (though the Voldemort types are > typically ranges, so in practice, using ranges ends up biting you). > > https://issues.dlang.org/show_bug.cgi?id=15831 > > I think that there's a good argument that Voldemort types aren't > actually a particularly good idea given these issues, but the work > that's being done to compress symbols should at least reduce the > problem. [...] Here's the latest update on this bit of drama: Today, I decided to sit down and refactor my code. I've heard tell that Voldemort types tend to cause an explosion in symbol size, and today I thought it'd be interesting to see just how big of a difference this actually makes. I could not believe my eyes. Before the refactoring, my executable sizes (I have 2 executables in this codebase) were 37.3MB and 60.0MB, respectively. After the refactoring, my executable sizes were, respectively, 8.2MB and 10.2MB. That's a 5x and 6x reduction in executable size, respectively. Whoa. And all I did was to move Voldemort structs out into module-level private structs. I.e., this: auto myFunc(Args...)(Args args) { static struct Result { ... } return Result(args); } became this: private MyFuncImpl(Args...) { ... } auto myFunc(Args...)(Args args) { return MyFuncImpl!Args(args); } And you get an instant 5x to 6x reduction in executable size. Now mind you, the ridiculous symbol size problem still exists; the executable still contains some huge symbols. The difference is that now the longest symbol is "only" 86KB, whereas before the refactoring, the longest symbol was 777KB (!). So the problem is less severe, but still present. So symbol compression is still a very important part of the eventual solution. T -- Windows: the ultimate triumph of marketing over technology. -- Adrian von Bidder
Re: Silly struct behaviour
On Thursday, 13 July 2017 at 18:09:46 UTC, H. S. Teoh wrote: It's not quite so simple. Consider for example: struct Foo { int bar; } struct Oof { int bar; } void process(Foo foo) { } void process(Oof oof) { formatDisk(); } void main() { process({bar : 5}); // which overload should get called? } in this case, I'd expect something like: error: ambiguous struct definition, could match process(Foo) or process(Oof)
Re: Silly struct behaviour
On Thursday, 13 July 2017 at 18:45:45 UTC, JN wrote: I know that's a wrong syntax, I was just showing an example. Yes, here it will work, but if you want to initialize only some fields (poor man's keyword arguments), you can't use the default constructor. easily fixable by using FunctionLiterals.
Re: proposed @noreturn attribute
On Thursday, 13 July 2017 at 17:25:18 UTC, Timon Gehr wrote: Anyway, my assertion that Bottom cannot be a subtype of all other types was actually incorrect: the compiler does not need to generate code for implicit conversion from Bottom to some other type, so it can be treated as a subtype. ... (Actually, there are some complications like the .sizeof property. Anyway, it is clear what the semantics of Bottom are, no matter whether it is subtyping or implicit conversion.)
WTF is going on! Corrupt value that is never assigned
The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the strings, the buf location changes, screwing up the copying process. It shouldn't happen, buf never changes value anywhere except the first malloc(which is once). Somehow it is getting changed, but where? The specific win32 or style is irrelevant, I am talking either about a bug or some subtle D thing because the code makes sense. (Fill Buf, iterate through buffer copying over to D values). I've ran in to this before, D does something fishy and it wastes hours upon hours trying to track done some stupid little thing it does. The buf value changes when calling cstr2dstr but I've had it with other values to(any function call such as to!string, etc seems to trigger it). struct ServiceData { wstring Name; wstring LongName; int Type; int State; int ControlsAccepted; int Win32ExitCode; int SpecificExitCode; int CheckPoint; int WaitHint; int ProcessId; int Flags; } auto cstr2dstr(wchar* cstr) { import std.array; auto str = appender!wstring; auto len = lstrlen(cstr); str.reserve(len); for(int i = 0; i < len; i++) str.put(cstr[i]); return str.data; } auto EnumServices() { import core.stdc.stdlib, std.traits; ServiceData[] servicesList; auto buf = malloc(5); // Gets changed later, even though never an assignment auto buf2 = buf; // does not change auto schSCManager = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS); if (NULL == schSCManager) { print("OpenSCManager failed (%d)\n", GetLastError()); return servicesList; } DWORD dwBytesNeeded, dwCount, lpResumeHandle, resume, totalCount; auto servicesType = (SERVICE_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_KERNEL_DRIVER | SERVICE_WIN32 | SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS); int cnt = 0; auto res = 0; do { // Manually copy over data, this is because EnumSErvicesStatus adds data at end of array for some odd ball reason making it difficult to build the correct array sequentially for(int i = 0; i < dwCount; i++) { ENUM_SERVICE_STATUS_PROCESSW x; ServiceData d; auto s = cast(ENUM_SERVICE_STATUS_PROCESSW*)(buf + i*ENUM_SERVICE_STATUS_PROCESSW.sizeof); //before buf is of correct value d.Name = cstr2dstr(s.lpServiceName); //after buf is invalid, yet buf is never assigned } res = EnumServicesStatusExW(schSCManager, SC_ENUM_TYPE.SC_ENUM_PROCESS_INFO, servicesType, SERVICE_STATE_ALL, cast(ubyte*)buf, 5, , , , cast(const(char)*)null); if (ERROR_MORE_DATA != GetLastError()) { print("Error enumerating services."); break; } } while (res == 0); for(int i = 0; i < totalCount; i++) { auto s = servicesList[i]; writeln(s.Name, " - ", s.LongName, " - ", s.Type, " = ", s.State); } return servicesList; }
Re: Silly struct behaviour
On Thu, Jul 13, 2017 at 06:07:31PM +, JN via Digitalmars-d-learn wrote: > Consider: > > struct Foo > { > int bar; > } > > void processFoo(Foo foo) > { > } > > void main() > { > Foo f = {bar: 5}; > processFoo(f);// ok > processFoo(Foo(5)); // ok > processFoo({bar: 5}); // fail > processFoo(Foo({bar: 5}));// fail > } > > > Wh D? It makes no sense, the compiler knows what is the type of > the first processFoo arg anyway... It's not quite so simple. Consider for example: struct Foo { int bar; } struct Oof { int bar; } void process(Foo foo) { } void process(Oof oof) { formatDisk(); } void main() { process({bar : 5}); // which overload should get called? } As for `Foo({bar : 5})`, that's just wrong syntax. Just write `Foo(5)` and it will work. T -- People demand freedom of speech to make up for the freedom of thought which they avoid. -- Soren Aabye Kierkegaard (1813-1855)
Silly struct behaviour
Consider: struct Foo { int bar; } void processFoo(Foo foo) { } void main() { Foo f = {bar: 5}; processFoo(f);// ok processFoo(Foo(5)); // ok processFoo({bar: 5}); // fail processFoo(Foo({bar: 5}));// fail } Wh D? It makes no sense, the compiler knows what is the type of the first processFoo arg anyway...
Re: [OT] .net is getting slices
On Thursday, 13 July 2017 at 17:08:38 UTC, jmh530 wrote: Huh? Take a look at the "Using Span" section. It's indeed stack-only for safety reasons. On heap can be stored a span promise, that can be resolved to a span on stack.
[Issue 17644] [Downloads] Bad link to changelog for DMD beta version.
https://issues.dlang.org/show_bug.cgi?id=17644 --- Comment #6 from Gerald Jansen--- (In reply to greenify from comment #5) > > How can I clone your branch/changes? > https://wiki.dlang.org/Guidelines_for_maintainers Thanks for the tips! --
Re: proposed @noreturn attribute
On Wednesday, 12 July 2017 at 14:23:15 UTC, Andrei Alexandrescu wrote: On 07/12/2017 05:32 AM, Timon Gehr wrote: On 09.07.2017 23:45, Meta wrote: ... Another case that we should probably just statically disallow: ... > This obviously doesn't make any sense anyway ... > I don't see a reason for us to ever need to do that Sorry, but this thinking has no place in type system design. This is precisely how you create a convoluted nonsensical mess. Timon, I think you're very well positioned to author a DIP on this. Getting through acceptance on your static foreach DIP seems to not require a lot of extra work. ... I might do that, however there are a couple of open questions (see below). Every type is peculiar. That's essentially the point of having types. There is not really a reason to invent a peculiarity ordering and then add additional special casing for types deemed more peculiar. (I.e., creating different types of types based on an informal judgment of peculiarity.) I seem to recall Haskell calls those "kinds". ... Indeed, but the separation of types and kinds has no point. See: https://ghc.haskell.org/trac/ghc/wiki/DependentHaskell It's perfectly fine to have a type of types which is its own type, especially if you allow non-termination. In D, subtyping is messy anyway, as you cannot have a subtyping relationship between values with different memory layout. Hence in D, Bottom would not actually be a subtype of all other types. It's a point, and it would make the implementation easier, but it would be a departure from theory. Also it makes user code a tad more awkward. I'm saying the D notion of subtyping is a bit messy because memory layout matters and subtyping and implicit conversion are not the same thing. Anyway, my assertion that Bottom cannot be a subtype of all other types was actually incorrect: the compiler does not need to generate code for implicit conversion from Bottom to some other type, so it can be treated as a subtype. (Also, a language does not have to support subtyping to have an empty type.) typeof(assert(0))* and typeof(assert(0))[] will hence be subtypes of all other pointer and array types respectively. An issue is that we already have typeof(null). typeof(null) and typeof(assert(0))* are two ways to specify almost the same thing. One question is whether typeof(assert(0))* and typeof(null) should be the same, or if the former should not implicitly convert to class references. I have also argued in the past that there should be a separate typeof([]). This role would now be filled by typeof(assert(0))[]. However, changing the type of '[]' may break code. Consider: typeof(assert(0)) abort(const(char)[] message); ... int fun() { int x; ... return x != 0 ? 1024 / x : abort("Error: calculation went awry."); } I guess such expressions can be rewritten into separate statements: if (x != 0) return 1024 / x; abort("Error: calculation went awry."); and then the compiler figures there's no need for a return following the call to abort. ... This code compiles and runs: int x; ... return x != 0 ? 1024 : (delegate int(){ assert(0,"Error: calculation went awry."); })(); Perhaps a solid plan is to start with a DIP that does not introduce conversion and then experiment with the result for a while. What do you think? ... I think the DIP should introduce conversion from the start, as conversion is easy to support. It is simple to support in the front end and the code gen for it is literally to emit nothing.
[Issue 17644] [Downloads] Bad link to changelog for DMD beta version.
https://issues.dlang.org/show_bug.cgi?id=17644 --- Comment #5 from greenify--- > How can I clone your branch/changes? Btw the guidelines for maintainers might answer a few of your questions and it contains a handy git shortcut if you happen to clone a PR more than once: https://wiki.dlang.org/Guidelines_for_maintainers --
Re: Read from terminal when enter is pressed, but do other stuff in the mean time...
On 07/13/2017 08:52 AM, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? If you're fine with buffered input, i.e. the user has to press Enter before the input is visible to the program, then std.concurrency works pretty well. Enter lines to the following program. It will exit when you send the line "done". import std.concurrency; import std.stdio; import core.thread; import std.range; struct Done { } struct Message { string line; } void worker() { bool done = false; while (!done) { receive( (Message message) { auto line = message.line; writefln("Received \"%s\"", line); while (!line.empty) { writeln(line.front); line.popFront(); Thread.sleep(500.msecs); } writefln("Done with \"%s\"", message); }, (Done message) { writefln("Bye..."); done = true; }); } } void main() { auto w = spawn(); foreach (line; stdin.byLineCopy) { if (line == "done") { w.send(Done()); break; } w.send(Message(line)); } thread_joinAll(); } Ali
[Issue 17644] [Downloads] Bad link to changelog for DMD beta version.
https://issues.dlang.org/show_bug.cgi?id=17644 --- Comment #4 from greenify--- > How can I see the effect of these changes on a copy of the site? The simplest way is clicking on DAutoTest at the PR status page. DAutoTest builds the entire website, shows the diff between the changes and allows to preview changes > How can I clone your branch/changes? There are many ways. One is: git remote add https://github.com/Wilzbach/dlang.org git fetch wilzbach git checkout wilzbach/download-version (I'm currently on my phone, so I hope there wasn't a typo. Don't hesitate to ask again if you have further questions) --
Re: [OT] .net is getting slices
On Thursday, 13 July 2017 at 14:34:56 UTC, Stefan Koch wrote: It's a stack-only type. Wow. It totally sucks! Huh? Take a look at the "Using Span" section.
[Issue 17644] [Downloads] Bad link to changelog for DMD beta version.
https://issues.dlang.org/show_bug.cgi?id=17644 --- Comment #3 from Gerald Jansen--- (In reply to Seb from comment #2) > PR: https://github.com/dlang/dlang.org/pull/1820 How can I see the effect of these changes on a copy of the site? I have cloned dlang.org and successfully built it. How can I clone your branch/changes? (sorry for the git/github newbie question) --
[Issue 17648] dmd segfault on overload set introspection
https://issues.dlang.org/show_bug.cgi?id=17648 uplink.co...@googlemail.com changed: What|Removed |Added CC||uplink.co...@googlemail.com --- Comment #1 from uplink.co...@googlemail.com --- resolve properties is needed to check if we have a such a member. I'll have a look into this later. --
Re: version=D_16
On Thursday, 13 July 2017 at 16:46:12 UTC, Luís Marques wrote: [ ... ] On D side the issue that remains is the ergonomics of having to type cast(short) more frequently. I suppose that if this proves too inconvenient we can just create a library type that avoids this issue, right? Yes. we could even make this type be recognized by the compiler such that it will perform the optimizations ;)
[Issue 17649] New: CONTRIBUTING.md instructions failed (no ../druntime dir)
https://issues.dlang.org/show_bug.cgi?id=17649 Issue ID: 17649 Summary: CONTRIBUTING.md instructions failed (no ../druntime dir) Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: minor Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: jansen.ger...@gmail.com Created attachment 1650 --> https://issues.dlang.org/attachment.cgi?id=1650=edit more detailed traceback Following the instructions on https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md, I got this error (more detail attached): fatal: Cannot change to '../druntime': No such file or directory object.Exception@../tools/changed.d(107): Failed to execute '"git" "-C" "../druntime" "fetch" "--tags" "https://github.com/dlang/druntime; "+refs/heads/*:refs/remotes/upstream/*"'. I had to 'git clone https://github.com/dlang/druntime' in addition to dlang.org and dmd, then 'cd dlang.org && make -f posix.make html' went smoothly. --
[Issue 17648] New: dmd segfault on overload set introspection
https://issues.dlang.org/show_bug.cgi?id=17648 Issue ID: 17648 Summary: dmd segfault on overload set introspection Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: john.loughran.col...@gmail.com $ cat blah.d alias BS = BSA; alias BS = BSB; template BSA(alias T) { } template BSB(T) { } void foo() { void bar(alias composite)() { foreach (member; __traits(allMembers, composite)) enum a = __traits(compiles, __traits(getMember, composite, member)); } bar!blah; } segfaults in resolvePropertiesOnly, no idea why it would end up there. I initially thought it was to do with recursing on the same module, but it turns out that it still happens if you take foo to another module. --
Re: Hiring D programmers (with cryptography and blockchain knowledge are preferred)
On Thursday, 13 July 2017 at 05:18:40 UTC, wigy wrote: On Wednesday, 12 July 2017 at 20:11:06 UTC, Vitor Rozsas wrote: [...] Hi! I do not think the debate you have with yourself is decentralized vs centralized. You are thinking about moderated vs unmoderated. One is a technical structure, the other is a social one. [...] Great explanation, perfectly done. A decentralized medium like this will one day put facebook, twitter, Uber, etc. out of business.
Re: version=D_16
On Monday, 10 July 2017 at 21:30:44 UTC, Walter Bright wrote: For example, ints in C are 16 bits. In D they are 32. This means that integer operations are expensive. I just realized something interesting. The same situation happens on AVR with C. AVR is 8 bit (but often competes with 16-bit microcontrollers), which means that (int8_t x = int8_t a + int8_t b) at the C level is computed as (int8_t x = int16_t a + int16_t b). This means that a lot of people (AVR is very popular, in part because of Arduino) have been relying on the optimizer. I haven't seen complaints or comments about this issue, so as far as I can tell this hasn't been a problem in the world at large, at least that people have noticed. BTW, do notice that the addition with carry is optimized away even at the -O0 level. On D side the issue that remains is the ergonomics of having to type cast(short) more frequently. I suppose that if this proves too inconvenient we can just create a library type that avoids this issue, right?
Re: Read from terminal when enter is pressed, but do other stuff in the mean time...
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? Might want to check Adam's Terminal.d https://code.dlang.org/packages/arsd-official%3Aterminal Docs at http://dpldocs.info/experimental-docs/arsd.terminal.html You can use a RealTimeConsoleInput with getch. You can use kbhit to check whether getch would block. However I found inconsistent behavior between platforms with kbhit, so might wanna test.
[Issue 14982] nogc inconsistency
https://issues.dlang.org/show_bug.cgi?id=14982 John Colvinchanged: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #2 from John Colvin --- Seems to have been fixed at some point --
[Issue 12283] Array literals of interface implementations do not resolve to interface
https://issues.dlang.org/show_bug.cgi?id=12283 hst...@quickfur.ath.cx changed: What|Removed |Added CC||hst...@quickfur.ath.cx --
Re: Read from terminal when enter is pressed, but do other stuff in the mean time...
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? You have to ask the OS for this. All of this is platform specific functionality. check your operating-system-api search terms are unbufferd i/o and event-loop
[Issue 17641] TypeInfo for two identical delegates (or functions) are not equal to each other
https://issues.dlang.org/show_bug.cgi?id=17641 --- Comment #3 from ag0ae...@gmail.com --- (In reply to andronkin from comment #2) > Thank you, I did not know about this feature. > > > void delegate(uint) > > Yeah, that looks wrong > Why is it wrong? This is the correct delegate type definition: > > void delegate(uint) f = delegate void(uint a) { ... }; "void delegate()" looks wrong. I was agreeing with you. --
[Issue 7177] $ should forward to length by default
https://issues.dlang.org/show_bug.cgi?id=7177 Jack Stoufferchanged: What|Removed |Added CC||j...@jackstouffer.com Hardware|Other |All OS|Linux |All --
[Issue 17646] dmd segfaults on missing foreach body in import
https://issues.dlang.org/show_bug.cgi?id=17646 uplink.co...@googlemail.com changed: What|Removed |Added Keywords||pull --- Comment #2 from uplink.co...@googlemail.com --- https://github.com/dlang/dmd/pull/6992 --
Read from terminal when enter is pressed, but do other stuff in the mean time...
How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things?
Re: Idiomatic FFT(W) Wrapper
On Thursday, 13 July 2017 at 12:49:40 UTC, Per Nordlöw wrote: Have anybody constructed an idiomatic D wrapper for FFTW? No, sorry, although I have used the library quite a bit in D. http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial I'm specifically concerned about - `RefCounted`-wrapping of the C structures `fftw_complex` and `fftw_plan` Sounds useful perhaps for fftw_plan. fftw_complex is just `typedef double fftw_complex[2];` so I'm not sure what you're getting at there. It's worth remembering that "wisdom" is separate from (and shared between) plans in fftw, so constructing and destroying plans can be very cheap and there's often no need to have multiple owners of a single plan. - range semantics, lazy evaluation and caching of result in stream-based architectures; `fftw_plan`, `fftw_execute` The discrete fourier transform is a global algorithm that can be lazy in input or output, but not both. I'm pretty sure the fast fourier transform algorithm for DFT cannot be lazy in either. Do you mean creating some sort of lazy short-time-fourier-transform (STFT or spectrogram or whatever other name people like)? Or are you thinking about 1-D transforms in multi-dimensional data (arguably the same thing actually)? - slicing and scope ?? - seamless interoperability with Mir (https://github.com/libmir/mir) This would definitely be nice to have For most common use-cases I find fftw is dead simple to use with the C API though. So simple that I never even bother making bindings, I just declare what I need as I need it (which in a single application has never been more than about 10 declarations).
[Issue 16564] KRRegion.empty sometimes returns Ternary.no
https://issues.dlang.org/show_bug.cgi?id=16564 --- Comment #7 from Temtaime--- Oh, sorry, my mistake import std.stdio, std.range, std.random, std.typecons, std.algorithm, std.experimental.allocator.building_blocks, core.memory; void main() { ubyte[128 * 1024] b; auto alloc = KRRegion!()(b); //alloc.switchToFreeList; auto k = alloc.allocate(128); assert(alloc.deallocate(k)); assert(alloc.empty == Ternary.yes); } I don't know why but this simplest example asserts. More complex tests are passed. Also it passes if the switch in uncommented --
Re: [OT] .net is getting slices
On Thursday, 13 July 2017 at 14:30:42 UTC, Kagamin wrote: http://adamsitnik.com/Span/ It's a stack-only type. Wow. It totally sucks!
Re: DIP 1010--Static foreach--Formal Review
On Monday, 10 July 2017 at 08:53:42 UTC, Mike Parker wrote: As promised, since there has been zero feedback on DIP 1010, "Static foreach", in either the Draft or Preliminary review rounds, I'm going to skip the normal two-week feedback cycle on the Formal review. If there are no major criticisms or objections raised in this thread, then sometime on Thursday of this week I'll send Walter & Andrei an email kicking off the decision process. Thanks for all the feedback. I don't see anything that is a blocker from moving forward, so I'll cut it off here and move along.
[OT] .net is getting slices
http://adamsitnik.com/Span/
[Issue 17641] TypeInfo for two identical delegates (or functions) are not equal to each other
https://issues.dlang.org/show_bug.cgi?id=17641 andron...@gmail.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #2 from andron...@gmail.com --- Thank you, I did not know about this feature. > void delegate(uint) > Yeah, that looks wrong Why is it wrong? This is the correct delegate type definition: void delegate(uint) f = delegate void(uint a) { ... }; --
[Issue 12736] @nogc std.algorithm.all
https://issues.dlang.org/show_bug.cgi?id=12736 Jon Degenhardtchanged: What|Removed |Added Status|RESOLVED|REOPENED Resolution|INVALID |--- --- Comment #3 from Jon Degenhardt --- Valid enhancement request, so reopening. If closed, should have a justification indicating the mechanism expected to eventually achieve the enhancement, or an explanation of why it the request is invalid at the API level. --
[Issue 11688] dlang packages should not depend on i686
https://issues.dlang.org/show_bug.cgi?id=11688 Gide Nwawuduchanged: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=17647 --
[Issue 17647] Fedora/CentOS RPM x86_64 depends on i686 libraries
https://issues.dlang.org/show_bug.cgi?id=17647 Gide Nwawuduchanged: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=11688 --
[Issue 17647] New: Fedora/CentOS RPM x86_64 depends on i686 libraries
https://issues.dlang.org/show_bug.cgi?id=17647 Issue ID: 17647 Summary: Fedora/CentOS RPM x86_64 depends on i686 libraries Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: installer Assignee: nob...@puremagic.com Reporter: g...@nwawudu.com The Fedora RPM downloaded from http://dlang.org/download.html, depends on i686 instead of x86_64 binaries. Bug 11688 seems similar. # uname -a Linux localhost 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux $ yum localinstall dmd-2.074.1-0.fedora.x86_64.rpm PackageArch Version RepositorySize Installing: dmdx86_64 2.074.1-0 /dmd-2.074.1-0.fedora.x86_64 201 M Installing for dependencies: cyrus-sasl-lib i686 2.1.26-20.el7_2 base 154 k glibc-develi686 2.17-157.el7_3.4 updates 1.1 M libcurli686 7.29.0-35.el7.centos base 221 k libdb i686 5.3.21-19.el7 base 730 k libidn i686 1.28-4.el7base 209 k libssh2i686 1.4.3-10.el7_2.1 base 133 k nspr i686 4.13.1-1.0.el7_3 updates 128 k nssi686 3.28.4-1.2.el7_3 updates 871 k nss-softokni686 3.16.2.3-14.4.el7 base 306 k nss-util i686 3.28.4-1.0.el7_3 updates 72 k openldap i686 2.4.40-13.el7 base 347 k readline i686 6.2-9.el7 base 189 k sqlite i686 3.7.17-8.el7 base 396 k $ rpm -qa | grep libcurl libcurl-7.29.0-35.el7.centos.i686 libcurl-7.29.0-35.el7.centos.x86_64 --
[Issue 17646] dmd segfaults on missing foreach body in import
https://issues.dlang.org/show_bug.cgi?id=17646 uplink.co...@googlemail.com changed: What|Removed |Added CC||uplink.co...@googlemail.com Assignee|nob...@puremagic.com|uplink.co...@googlemail.com --- Comment #1 from uplink.co...@googlemail.com --- That should be an easy fix. --
[Issue 17646] New: dmd segfaults on missing foreach body in import
https://issues.dlang.org/show_bug.cgi?id=17646 Issue ID: 17646 Summary: dmd segfaults on missing foreach body in import Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: john.loughran.col...@gmail.com $ cat ut.d int main() { runTests!""; } int runTests(Modules...)() { import reflection; allTestData!Modules; } $ cat reflection.d struct TestData {} const(TestData)[] allTestData(MOD_STRINGS...)() { foreach (i; MOD_STRINGS) } $ gdb -q dmd Reading symbols from dmd...done. (gdb) r -o- ut.d Starting program: dmd -o- ut.d DMD v2.075.0-b4-102-gf189b2d08-dirty DEBUG reflection.d(4): Error: found '}' instead of statement Program received signal SIGSEGV, Segmentation fault. 0x00637b63 in StatementSemanticVisitor::visit(ForeachStatement*) (this=0x7fff98d8, fs=0x76cb22d0) at ddmd/statementsem.d:742 742 st.push(fs._body.syntaxCopy()); (gdb) p fs._body $1 = (ddmd.statement.Statement *) 0x0 For some reason semantic is going ahead despite syntax having failed? --
Re: how old is dfl ??
On Thursday, 13 July 2017 at 13:08:37 UTC, Flaze07 wrote: hi the reason I ask how old dfl is because it is an abandoned project...but I want to use it... I am just afraid of some...incompability Your choice for a gui depends on your requirements and how you intend to use it. Here is a list of gui's for the D language: https://wiki.dlang.org/GUI_Libraries As you research, you will see that DFL was originally written for D1 and Tango, but there have been several ports to D2 and Phobos. The DFL port I checked out has been ported to D2 and Phobos, found here: https://code.dlang.org/packages/dguihub and here: https://github.com/o3o/dguihub I was able to download and the examples compiled the first try. This version does not have any docs, so you will have to read the D source code to figure out how all the widgets work. There are docs in the other DFL forks that look promising, I just haven't taken the time to check it out.
Re: DWT is official ?
On Wednesday, 12 July 2017 at 12:36:34 UTC, Flaze07 wrote: On Wednesday, 12 July 2017 at 11:18:21 UTC, Jacob Carlborg wrote: On 2017-07-12 12:10, Flaze07 wrote: hi...so is this group forum about the SWT D bindings ? (I am just surprised that it is...in the ecosystem if it is what I think it is) Technically DWT [1] is a port of SWT to D, not bindings. No Java code is involved. [1] http://github.com/d-widget-toolkit/dwt I see... so...is it official ?? The beauty of the D language is that there really isn't any "official" packages, other than the language and runtime library. The key advantages of DWT are; 1. Extensive API and examples from SWT that can be searched with your Browser 2. Statically linked (don't need an external DLL) 3. Easy to learn and use Here are the various GUIs for the D language: https://wiki.dlang.org/GUI_Libraries The choice of a GUI really depends on what your requirements are and how you intend to use it.
how old is dfl ??
hi the reason I ask how old dfl is because it is an abandoned project...but I want to use it... I am just afraid of some...incompability
[Issue 17634] variadic overload of std.algorithm.searching.countUntil should return which needle was found
https://issues.dlang.org/show_bug.cgi?id=17634 RazvanNchanged: What|Removed |Added Assignee|razvan.nitu1...@gmail.com |nob...@puremagic.com --
newCTFE Status July 2017
Hi Guys, It has been suggested that I open a new thread every month. I am happy to do that as it will make documenting the progress in newCTFE easier. Let me start with a funny error I just fixed :) The following code : static assert(() { return ulong(ushort.max | ulong(ushort.max) << 32); }() == 281470681808895LU); resulted in the following error: static assert (*function () => 281470681808895LU)() == 281470681808895LU is false Because the value was : 65535UL. Which is the value when truncated to 32bit. The reason for this was that the interpreter was initially built for 32bit. On the switch-over to 64bit support I added the ability to work with 64bit values. However since I did not want to bloat the instructions beyond 64bit; An 64bit Immediate Set (which is equivalent to a movq) is encoded in two instructions: Set(lhs, imm32(imm64Value & uint.max)); SetHigh(lhs, imm32(imm64Value >> 32)); However I did forget to issue the SetHigh. Which resulted in the observed behavior. Funnily enough I found this issue because I suspected an ABI in how ulong and long struct members are handeld. And sure enough on top of the above described bug there was an abi bug as well. which is now fixed as well. While theses bugs are lurking the development of the ctfe-debugger is impeded.
Idiomatic FFT(W) Wrapper
Have anybody constructed an idiomatic D wrapper for FFTW? http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial I'm specifically concerned about - `RefCounted`-wrapping of the C structures `fftw_complex` and `fftw_plan` - range semantics, lazy evaluation and caching of result in stream-based architectures; `fftw_plan`, `fftw_execute` - slicing and scope - seamless interoperability with Mir (https://github.com/libmir/mir)
Re: Gui in D: I miss this project
On Wednesday, 18 January 2017 at 09:24:09 UTC, aberba wrote: What about Photoshop? Is it native? No. No, by-and-large Photoshop does not use native controls. However, I would not hold up Photoshop as validation for not using native controls. Games have wide latitude for ignoring their platform's native control and rolling their own user interface. Productivity applications ignore their platform's native controls and native user-interface at their own peril. Photoshop is an example of a successful program that treads in those dangerous waters.
[Issue 17645] `pure` is transitively applied to all delegates inside a pure function
https://issues.dlang.org/show_bug.cgi?id=17645 Steven Schveighofferchanged: What|Removed |Added CC||schvei...@yahoo.com --- Comment #1 from Steven Schveighoffer --- Do you have a better use case? This works: void f() pure { void function() dg = {x++;}; } i.e. you don't need access to the pure function's stack frame, so you can have a function instead of a delegate. I'm kind of surprised the compiler inferred dg as a delegate and not a function in the first place. --
Re: Why do array literals default to object.Object[]?
On 7/12/17 1:24 AM, Brandon Buck wrote: On Wednesday, 12 July 2017 at 02:06:41 UTC, Steven Schveighoffer wrote: I'm sure there's a bug filed somewhere on this... Is this bug worthy? I can search for one and comment and/or create one if I can't find one. Found it. It was mistakenly closed: https://issues.dlang.org/show_bug.cgi?id=12283 -Steve
[Issue 12283] Array literals of interface implementations do not resolve to interface
https://issues.dlang.org/show_bug.cgi?id=12283 Steven Schveighofferchanged: What|Removed |Added Status|RESOLVED|REOPENED CC||schvei...@yahoo.com Resolution|DUPLICATE |--- --- Comment #3 from Steven Schveighoffer --- Turns out it's not the same. In the latest DMD (2.074.1): version(bad) interface A {} else class A {} class B : A {} class C : A {} void main() { A[] arr = [new B, new C]; } when compiled with version=bad: test12283.d(9): Error: cannot implicitly convert expression ([new B, new C]) of type Object[] to A[] Without the version, it works. My guess is the inference of the type only takes into account the expression, not the fact that it's an initializer. However this is surprising behavior, because in other cases, an initializer does use the type of the variable being initialized to work: auto x = [1, 2]; // int[] short[] y = x; // Error short[] z = [1, 2]; // But this is OK The only way to get it to work is to cast one element to an A. An ugly error-prone mechanism (which also happens to do a dynamic cast in some cases). I think this should work if the variable being declared has a type and isn't auto. If it's auto, then the behavior of making an Object[] is a valid answer. --
Re: Beta 2.075.0-b4
On Thursday, 13 July 2017 at 11:52:13 UTC, Martin Nowak wrote: On Thursday, 13 July 2017 at 07:22:00 UTC, Eugene Wissner wrote: The ChangeLog link is: http://dlang.org/changelog/2.075.0_pre.html Works for now, but it shouldn't be under that URL. Will check what broke with dlang.org's Makefile. FYI: https://github.com/dlang/dlang.org/pull/1820
[Issue 17645] `pure` is transitively applied to all delegates inside a pure function
https://issues.dlang.org/show_bug.cgi?id=17645 Tomer Filiba (weka)changed: What|Removed |Added Keywords||industry --
[Issue 17645] New: `pure` is transitively applied to all delegates inside a pure function
https://issues.dlang.org/show_bug.cgi?id=17645 Issue ID: 17645 Summary: `pure` is transitively applied to all delegates inside a pure function Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: to...@weka.io DMD64 D Compiler v2.074.0. Consider the following: static int x; void f() pure { auto dg = (){x++;}; } src/dtest.d(45,19): Error: pure delegate 'dtest.f.__lambda1' cannot access mutable static data 'x' Had I invoked dg() inside f(), this error would be correct. But I'm only creating a delegate, which I will pass to some external, non-pure entity, which is allowed to call it. The use-case here is that sometimes we need the compiler to "just trust us" and assume something is pure. It's used in exception cases which would soon after reach an abort() so we don't consider this impure. And this restriction is too broad for us --
[Issue 17645] `pure` is transitively applied to all delegates inside a pure function
https://issues.dlang.org/show_bug.cgi?id=17645 Tomer Filiba (weka)changed: What|Removed |Added CC||to...@weka.io --
Re: CTFE Status 2
On 7/12/17 9:20 PM, H. S. Teoh via Digitalmars-d wrote: On Thu, Jul 13, 2017 at 01:23:53AM +, Stefan Koch via Digitalmars-d wrote: On Wednesday, 12 July 2017 at 21:05:28 UTC, watcher wrote: stop advertising yourself and polluting this thread. seek help - no down-payments in Germany!! I am not sure what you mean ... I assume it's a joke ? Or a troll. Just ignore it. I kind of like Stefan's response though :) Carry on, Stefan! Though here is a suggestion -- start a new thread every month. Every time you post a response on this thread that's not in response to something, it jumps the entire history back up to the top of the list. -Steve
[Issue 17634] variadic overload of std.algorithm.searching.countUntil should return which needle was found
https://issues.dlang.org/show_bug.cgi?id=17634 RazvanNchanged: What|Removed |Added CC||razvan.nitu1...@gmail.com Assignee|nob...@puremagic.com|razvan.nitu1...@gmail.com --
Re: Error on negating unsigned types
On 7/12/17 5:24 PM, Johan Engelen wrote: On Wednesday, 12 July 2017 at 20:12:03 UTC, Steven Schveighoffer wrote: ... Which means this may cause a bunch of nuisance errors. It's a trade-off between nuisance in some cases (the Phobos ones can be solved with val = abs(val), or with static if), and possibly catching bugs in other cases. We can compare this with negation of a bool and subtracting a bool: ``` bool b; auto x = 1 - b; // allowed auto y = -b; // not allowed ``` My only point is with Andrei's assertion that it "exposed two bugs in Phobos". In terms of the trade-off, it looks like this is just a straight bug that should be fixed. If the behavior goes back to being like C, is it still so bad that it needs an error? My testing: import std.stdio; void main() { ubyte x = 5; int y = -x; writeln(y); uint t = 0; t += x; writeln(t); t += y; writeln(t); } outputs: 251 5 256 In C: #include int main() { unsigned char x = 5; int y = -x; printf("%d\n", y); unsigned int t = 0; t += x; printf("%u\n", t); t += y; printf("%u\n", t); return 0; } outputs: -5 5 0 The C behavior seems fine to me. -Steve
Re: Bad file descriptor in File destructor
On Thursday, 13 July 2017 at 10:56:20 UTC, unDEFER wrote: Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; } Well, yes, you can also encompass your entire function body in a try catch, though that makes your code somewhat hard to read[1]. With these many try/catches you may want to take a look at std.exception.collectException[2]. [1] https://en.wikipedia.org/wiki/Spaghetti_code [2] https://dlang.org/phobos/std_exception.html#.collectException
Re: Bad file descriptor in File destructor
Thank you. I will write if will find the reason of description corruption.
Re: 2D game physics, macOS
On Thursday, 13 July 2017 at 09:53:05 UTC, Jacob Carlborg wrote: On 2017-07-13 02:34, Joel wrote: It doesn't look like there's any thing I can use. I've come across: dbox, dchip, and blaze. Blaze is dsource. dbox is alpha and hasn't been updated for 3 years. dchip [1] hasn't been updated for 2 years and doesn't compile (that's with out using any thing, just import and dub dependency). You can try creating your own bindings. DStep [1] is a tool that can help with that. Make sure you build DStep from master. [1] http://github.com/jacob-carlborg/dstep I don't know about trying to do that.
Re: Bad file descriptor in File destructor
On Thursday, 13 July 2017 at 11:15:56 UTC, Moritz Maxeiner wrote: --- ubyte[File.sizeof] _file; ref File file() { return *(cast(File*) &_file[0]); } [create File instance and assign to file] scope (exit) destroy(file); --- Forgot to add the try catch: --- ubyte[File.sizeof] _file; ref File file() { return *(cast(File*) &_file[0]); } [create File instance and assign to file] scope (exit) try destroy(file) catch (ErrnoException) {}; --- or just --- scope (exit) destroy(file).collectException ---
Re: Bad file descriptor in File destructor
On Thursday, 13 July 2017 at 10:28:30 UTC, unDEFER wrote: On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a minimal working (in this case crashing) example? Yes File is std.stdio.File. And I can't provide a minimal crashing example because this code crashes very rarely. I just want to put try/catch and don't know where to do it. Well, if you get an ErrnoException on std.stdio.File.~this you are AFAIK either encountering an OS bug, or you have previously corrupted the file descriptor that File instance wraps around. To be specific, it sounds to me like you're trying to close a file descriptor that's already been closed, i.e. you should fix that instead of trying to work around the consequences of it. Under the assumption, though, that it's an OS bug you're encountering, you can't deal with it with just a try catch in that function, because a (stack allocated) struct's destructor is always called when it goes out of scope. I see essentially two workarounds: - Use two functions foo and bar, where bar has `file` on it's stack, and `foo` calls `bar` and catches the destructor exception via try catch block around the call to `bar` - Hide the `file` from the automatic out-of-scope destruction by using another type for storage Personally I'd prefer the second variant, it could look like this: --- ubyte[File.sizeof] _file; ref File file() { return *(cast(File*) &_file[0]); } [create File instance and assign to file] scope (exit) destroy(file); ---
Re: Bad file descriptor in File destructor
Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; }
[Issue 6718] "nWayUnion" => "nWayMerge", plus true nWayUnion
https://issues.dlang.org/show_bug.cgi?id=6718 RazvanNchanged: What|Removed |Added CC||razvan.nitu1...@gmail.com --- Comment #8 from RazvanN --- So, how should we proceed here? Rename nWayUnion to nWayMerge and alias nWayUnion to it? If we do that we should probably deprecate nWayUnion. --
Re: Bad file descriptor in File destructor
On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a minimal working (in this case crashing) example? Yes File is std.stdio.File. And I can't provide a minimal crashing example because this code crashes very rarely. I just want to put try/catch and don't know where to do it.
Re: 2D game physics, macOS
On 2017-07-13 02:34, Joel wrote: It doesn't look like there's any thing I can use. I've come across: dbox, dchip, and blaze. Blaze is dsource. dbox is alpha and hasn't been updated for 3 years. dchip [1] hasn't been updated for 2 years and doesn't compile (that's with out using any thing, just import and dub dependency). You can try creating your own bindings. DStep [1] is a tool that can help with that. Make sure you build DStep from master. [1] http://github.com/jacob-carlborg/dstep -- /Jacob Carlborg
[Issue 17624] typo in Fields documentation section of https://dlang.org/library/object/exception.html
https://issues.dlang.org/show_bug.cgi?id=17624 Sebchanged: What|Removed |Added Keywords||pull CC||greensunn...@gmail.com Component|dlang.org |druntime --- Comment #1 from Seb --- Pull https://github.com/dlang/druntime/pull/1871 --
[Issue 17644] [Downloads] Bad link to changelog for DMD beta version.
https://issues.dlang.org/show_bug.cgi?id=17644 Sebchanged: What|Removed |Added Keywords||pull CC||greensunn...@gmail.com --- Comment #2 from Seb --- PR: https://github.com/dlang/dlang.org/pull/1820 --
Re: Bad file descriptor in File destructor
On Thursday, 13 July 2017 at 08:38:52 UTC, unDEFER wrote: Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { } Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a minimal working (in this case crashing) example? If the `File` above is not std.stdio.File, but some custom type: Be aware that structs have deterministic lifetimes, so `file`'s destructor will be called even when you return in the catch clause (on the default constructed `file`), so `File`'s destructor must check the field carrying the file descriptor for being valid; I advise setting such fields to be default constructed to some invalid value (e.g. `-1` in case of file descriptors).