Re: dmd/ldc failed with exit code -11
On 21/11/2017 12:15 AM, Anonymouse wrote: I have a large named enum (currently 645 members) of IRC event types. It's big by neccessity[1]. I'm using dub, and both dmd and ldc successfully build it in test and debug modes, but choke and die on plain and release. I bisected it down to when I did a big addition to the enum to encompass virtually all event types there are. dmd -v: [...] code common function kameloso.common.Separator.__xopEquals function kameloso.common.Separator.__xtoHash function kameloso.common.Settings.__xopEquals function kameloso.common.Settings.__xtoHash function kameloso.common.scopeguard function kameloso.common.scopeguard.scopeString function kameloso.common.scopeguard.entryString function kameloso.common.KamelosoLogger.this function kameloso.common.KamelosoLogger.writeLogMsg function kameloso.common.KamelosoLogger.beginLogMsg function kameloso.common.KamelosoLogger.logMsgPart function kameloso.common.KamelosoLogger.finishLogMsg zsh: segmentation fault (core dumped) dmd -c -v -w -d -version=Have_kameloso -Isource/ source/arsd/dom.d Where it stops here varies if I comment stuff out, so I don't think the Logger is at fault. ldc -v: [...] code irc code constants code connection code config code common /usr/lib/libLLVM-5.0.so(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2b)[0x7f09953839bb] /usr/lib/libLLVM-5.0.so(_ZN4llvm3sys17RunSignalHandlersEv+0x56)[0x7f0995381806] /usr/lib/libLLVM-5.0.so(+0x808953)[0x7f0995381953] /usr/lib/libpthread.so.0(+0x11da0)[0x7f099496cda0] ldc(_ZN16TemplateInstance12needsCodegenEv+0x8)[0x561fe42fc128] ldc(_ZN16TemplateInstance12needsCodegenEv+0x103)[0x561fe42fc223] ldc(_ZN16TemplateInstance12needsCodegenEv+0x103)[0x561fe42fc223] ldc(_ZN16TemplateInstance12needsCodegenEv+0x103)[0x561fe42fc223] ldc(_ZN16TemplateInstance12needsCodegenEv+0x103)[0x561fe42fc223] ldc(_ZN16TemplateInstance12needsCodegenEv+0x103)[0x561fe42fc223] ldc(_ZN16TemplateInstance12needsCodegenEv+0x103)[0x561fe42fc223] [...] zsh: segmentation fault (core dumped) ldc -v -w -d -oq -od=.dub/obj -d-version=Have_kameloso -Isource/ What can I do? Merely copying the enum into a test file and compiling with an empty main does nothing, it doesn't seem to be enough to replicate the bug. (Arch/Manjaro 64-bit, dmd 2.077.0, ldc 1.5.0 based on 2.075.1) [1] http://defs.ircdocs.horse/defs/numerics.html Source code please.
Re: ESR on post-C landscape
On 16/11/2017 6:35 AM, Ola Fosheim Grostad wrote: On Thursday, 16 November 2017 at 02:12:10 UTC, codephantom wrote: Perhaps the mistake C++ made, was concluding that 'classes' were the "proper primary focus of program design" (chp1. The Design and Evolution of C++). No, classes is a powerful modelling primitive. C++ got that right. C++ is also fairly uniform because of it. Not as uniform as Self and Beta, but more so than D. People who harp about how OO is a failure don't know how to do real world modelling... Thing is, it is a failure, the way most people use it. When used correctly it is a very nice additive to any code base. It just can't be the only one.
Re: Best practices for multithread global flags
On 15/11/2017 11:57 AM, Vladimirs Nordholm wrote: Hello people from D-land. To summarise my problem: I have a program in the terminal (Posix) with two threads: one which my main program is run on, and a second one which polls input via `poll(...)` and `read(...)`. Let's call main thread T1, and a semi-blocking input-thread T2. Every second T2 checks if T1 is terminated by checking if the a global flag is set to true. This is done with a `while(global_flag)`. This feels to me like iffy code. So my question becomes: what is the best way to do this check with? You're fine, a __gshared variable will do this nicely.
Re: [OT] mobile rising
On 15/11/2017 3:15 AM, solidstate1991 wrote: After all this flaming about Windows, mobile devices (I personally prefer my desktop PC thanks to its "power", or at least what it used to left, thanks to long unemployment time and lack of income, have a Nokia Lumia which I cannot upgrade to W10 due to BS reasons, and I think open-source architectures will kill off the proprietary ARM and x86 in the long run, not the mobile platform the desktops/laptops(funny story is that my mother tried to ditch desktop multiple times for the mobile, then got back, same happened with one of my cousin after he realized that pay-to-win games suck)), can we get back on rails? While its true that Windows and desktop is losing its place, we need to support Windows on a much higher level as long as there's a large number of PCs out there. Game development would highly benefit from D thanks to its all-in-one approach, probably could cut a few millions off from AAA game development. Also audio-engineers are switching to Windows, thanks to Apple scrapping the IO on their products (I'm also a digital artist, have to stay with Windows due to drivers, software, and ease of use). Walter Bright: What's the licensing state of DMC and OPTLINK? Can it made open-source? If yes, we should patch in a COFF32/64 support, maybe even port it to D for easier development. I can spend some of my time working on the DLL support if needed. https://github.com/DigitalMars/optlink/pull/19
Re: string version of array
On 14/11/2017 8:16 AM, Andrea Fontana wrote: On Tuesday, 14 November 2017 at 07:56:06 UTC, rikki cattermole wrote: On 14/11/2017 7:54 AM, Tony wrote: Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string? struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)] Why not import std.conv : to; writeln(data.to!string); ? .text is essentially short hand, that's all. I use it as it is more descriptive as to my intention.
Re: string version of array
On 14/11/2017 7:54 AM, Tony wrote: Is there an easy way to get the string representation of an array, as would be printed by writeln(), but captured in a string? struct Foo { int x; } void main() { Foo[] data = [Foo(1), Foo(2), Foo(3)]; import std.conv : text; import std.stdio; writeln(data.text); } --- [Foo(1), Foo(2), Foo(3)]
Re: Project Elvis
On 11/11/2017 11:18 AM, codephantom wrote: On Saturday, 11 November 2017 at 09:47:32 UTC, Patrick Schluter wrote: Indeed, the strength of D is that it is portable among the big platforms remaining. One of its drawbacks can be seen somehow as an asset. Its lack of preferred GUI kit means that it is not intimately bound to the user interface of that platform. Swift and Objective-C are glued to Apple and outside of it are niche. Same for C# on Windows. Java is portable but is a bitch to distribute, especially on Windows where more often than not it poses security risks that IT departments do not like. Yeah, integrating gui's into a programming language is complexthere are some gui kits for D in github, but none I find compelling at this stage - even though they're authors are doing a great job. It's not that it's too complex technically, but the corporates I've done work for would never allow you to bring in your own gui anyway. Everything has to be standardised, and look familiar to users. GUI toolkits are definitely complex. Everything from rendering of fonts correctly (bidi layouts) to accessibility (which is basically impossible to do right too) and that's with ignoring more obvious things like how to render a widget.
Re: Synchronize Class fields between different threads
On 10/11/2017 2:13 PM, DrCataclysm wrote: On Friday, 10 November 2017 at 13:50:56 UTC, rikki cattermole wrote: Remember this bit: Everything on the heap, is not thread-local, it is global. This includes everything inside a class. When you synchronize (statement) it is locking and then unlocking a mutex. A class has a mutex, simple! It only prevent multiple threads modifying a single thing at specific times, thats all. this is my implementation of Accept private void Accept(){ // start accepting in a different thread try{ _client = _server.accept(); emit(ClientConnected(_client.remoteAddress.toAddrString)); auto _acceptTask = task(); _acceptTask.executeInNewThread(); Receive(); } catch (SocketAcceptException e){ writeln("Error while accepting connection: " ~ e.msg); } } Is _client on the Heap or the Stack? If it is on the Stack, how would i get in on the Heap? Assuming _client is in a class, heap.
Re: Synchronize Class fields between different threads
Remember this bit: Everything on the heap, is not thread-local, it is global. This includes everything inside a class. When you synchronize (statement) it is locking and then unlocking a mutex. A class has a mutex, simple! It only prevent multiple threads modifying a single thing at specific times, thats all.
Re: [OT] mobile rising
On 10/11/2017 10:42 AM, Tony wrote: If people ever get so cost-conscious that they decide to buy a $150 companion for their phone, instead of a $400 laptop, it's unlikely they will be using iPhones. You can get a nice Android phone with plenty of RAM/ROM for half the price of an iPhone. You can do pretty decently for $60-80usd if you know where to look with Android. But the reality is for developers, desktops are going no where. If anything, we'll see more server workstations becoming standard for developers. I know, I have one. Well worth it if you do anything decent.
Re: How you guys go about -BetterC Multithreading?
On 09/11/2017 4:00 PM, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 13:00:15 UTC, ParticlePeter wrote: On Thursday, 9 November 2017 at 12:19:00 UTC, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports or general suggestions? I've used only D threads so far. It would be far easier if you use druntime + @nogc and/or de-register latency-sensitive threads from druntime [1], so they're not interrupted even if some other thread calls the GC. Probably the path of least resistance is to call [2] and queue @nogc tasks on [3]. If you really want to pursue the version(D_BetterC) route, then you're essentially on your own to use the threading facilities provided by your target OS, e.g.: https://linux.die.net/man/3/pthread_create https://msdn.microsoft.com/en-us/library/windows/desktop/ms682516(v=vs.85).aspx Though you need to be extra careful not to use thread-local storage (e.g. only shared static and __gshared) and not to rely on (shared) static {con|de}structors, dynamic arrays, associative arrays, exceptions, classes, RAII, etc., which is really not worth it, unless you're writing very low-level code (e.g. OS kernels and drivers). [1]: https://dlang.org/phobos/core_thread#.thread_detachThis [2]: https://dlang.org/phobos/core_memory#.GC.disable [3]: https://dlang.org/phobos/std_parallelism#.taskPool Forgot to mention, I'll try this first, I think its a good first step towards -BetterC usage. But in the end I want to see how far I can get with the -BetterC feature. In short, the cost / benefit of going all the way version(D_BetterC) is incredibly poor for regular applications, as you end up a bit more limited than with modern C++ (> 11) for prototyping. For example, even writers of D real-time audio plugins don't go as far. I just did some work for Guillaume Piolat (p0nce author of dplug), guess what is going to be used again, druntime!
Re: How you guys go about -BetterC Multithreading?
On 09/11/2017 12:19 PM, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports or general suggestions? I've used only D threads so far. It would be far easier if you use druntime + @nogc and/or de-register latency-sensitive threads from druntime [1], so they're not interrupted even if some other thread calls the GC. Probably the path of least resistance is to call [2] and queue @nogc tasks on [3]. If you really want to pursue the version(D_BetterC) route, then you're essentially on your own to use the threading facilities provided by your target OS, e.g.: https://linux.die.net/man/3/pthread_create https://msdn.microsoft.com/en-us/library/windows/desktop/ms682516(v=vs.85).aspx You can use a library like libuv to handle threads (non-language based TLS too, not sure that it can be tied in unfortunately).
Re: [OT] Windows dying
On 07/11/2017 1:48 PM, Ola Fosheim Grøstad wrote: On Tuesday, 7 November 2017 at 13:29:19 UTC, rikki cattermole wrote: On 07/11/2017 12:58 PM, Ola Fosheim Grøstad wrote: On Tuesday, 7 November 2017 at 11:31:03 UTC, rikki cattermole wrote: I am quite surprised that Intel even created i9 actually, it just wasn't required. AMD Ryzen Threadripper: https://www.cpubenchmark.net/high_end_cpus.html I do not trust that benchmark. Well, this is another one with a comparison of two products with similar price: http://cpu.userbenchmark.com/Compare/Intel-Core-i9-7900X-vs-AMD-Ryzen-TR-1950X/3936vs3932 I think the Xeons might be for overcommited server situations. Larger caches and many threads. Sometimes people are more interested in responsiveness (prevent starvation) and not necessarily max speed. So if you do a lot of I/O system calls you might want the ability to run many threads at the same time and focus less on number crunching, perhaps? That sounds an awful like the average user too ;) But after looking at those numbers, I have a strange feeling that Intel is pushing those i9's past 'safe' limits. I think they just turn off cores that does not work and put those chips into the lower end, and the high end is very expensive at $2000 (so maybe low yield or just greed :-)… The way I think of it is that Xeon's get all the newest and greatest features, with them slowly trickling down to the i-series. Invest in the Xeon production line one generation and in next use it for i7's ext. Basically R cost go all on the Xeon's and then eventually once its paid off it goes straight to the consumers. But i9 is looking like its a completely different beast to the rest of the i-series with Intel actively adding new unique features to it. Quite scary that this doesn't sound like a good move especially when those features could very well make those cpu's last not very long. Looks like they are changing tactic after the last 10 years or so. I do wonder if you're on the right track and turning a Xeon into an i9 is just a firmware upgrade...
Re: [OT] Windows dying
On 07/11/2017 12:58 PM, Ola Fosheim Grøstad wrote: On Tuesday, 7 November 2017 at 11:31:03 UTC, rikki cattermole wrote: I am quite surprised that Intel even created i9 actually, it just wasn't required. AMD Ryzen Threadripper: https://www.cpubenchmark.net/high_end_cpus.html I do not trust that benchmark. https://www.intel.com/content/www/us/en/products/compare-products.html?productIds=126699,120496,125056 But after looking at those numbers, I have a strange feeling that Intel is pushing those i9's past 'safe' limits. Ah huh they are messing with threading and cpu clock speeds via Intel Turbo Boost Max Technology 3.0. Nasty.
Re: [OT] Windows dying
On 07/11/2017 11:12 AM, codephantom wrote: On Tuesday, 7 November 2017 at 08:53:46 UTC, Joakim wrote: No, the reason they don't improve is consumers don't need the performance. I don't agree. Consumers would welcome more performance - and many of us 'need' it too. But cpu's have hit the heat barrier, and so manufacturers tend to focus on more cores, better caching algorithms, and such... but I am sure that consumers would find a 10GHz quad core processor far more useful than a 4Ghz 24 core one. Then you have the challenges of redesigning programming languages and software development methodologies to take better advantage of the multi-core thing... There is also the problem of no real competition against Intel, so real innovation is not occuring as rapidly as it once did. What we really need, is to get rid of that heat barrier - which means lots and lots of money (potentially billions) into new research... and without competition, why should Intel bother? They can just do a few minor tweaks here and there, increment a number, and call the tweaked i7 ..the i9. Not quite, but along the right line of thinking IMO. Speed wise we have well and truly hit the limit of what we can do with silicon. The speed improvements today are not the same kind done 20 years ago. Today's speed improvements come from changing and making what instructions run cheaper. Consumers most definitely would benefit from higher number of cores even if they are slower. Why? Two reasons. First of all common programs like web browsers tend to use a LOT of threads. Which would mean less context switching over all (quite expensive and slow). Second most people do not max out their RAM both speed and quantity wise. RAM that matches the CPU clock speed is very expensive when comparing against high end CPU's and RAM is the real bottle neck today. Most people never get close to using up a CPU to its maximum capacity, its sitting idle a good bit of the time. Intel has competition, every heard of AMD and ARM? Intel has made a lot of changes to their strategy in the last 10-30 years e.g. being more energy efficient because of ARM and AMD64 (with micro ops to implement it). I am quite surprised that Intel even created i9 actually, it just wasn't required. Its like as if they took their Xeon lines, removed a bunch of features and only based it on the higher end ones. Remember Xeon = non-consumer (so you get e.g. reliability and performance along with all the new features) and i-series = cheap consumer products.
Re: Reorganization and list of D libraries (300+)
On 07/11/2017 5:54 AM, Fra Mecca wrote: On Tuesday, 7 November 2017 at 04:27:13 UTC, rikki cattermole wrote: On 07/11/2017 12:35 AM, Fra Mecca wrote: On Monday, 6 November 2017 at 16:12:14 UTC, Martin Tschierschke wrote: [...] Can we make a proposal for a change? Sure ya can. Especially if it comes with a PR ;) If I only had some front-end experience Perfect time to learn. Its a very useful skill to have, even if you don't use it every day.
Re: fputs, stdout
On 07/11/2017 4:34 AM, Tony wrote: There is a fputs/stdout in core.stdc.stdio. std.stdio "public imports" that: "public import core.stdc.stdio;" Wondering why: import core.stdc.stdio : fputs; import core.stdc.stdio : stdout; void main() { fputs( cast(const char *)"hello world\n",stdout); } compiles and runs, but if I change the imports to: import std.stdio : fputs; import std.stdio : stdout; I get this compile error: fputs_test.d(11): Error: function core.stdc.stdio.fputs (scope const(char*) s, shared(_IO_FILE)* stream) is not callable using argument types (const(char*), File) core.stdc.stdio : stdout https://github.com/dlang/druntime/blob/master/src/core/stdc/stdio.d#L710 std.stdio : stdout https://github.com/dlang/phobos/blob/master/std/stdio.d#L4662 Answer: not the same thing.
Re: Reorganization and list of D libraries (300+)
On 06/11/2017 4:59 PM, jmh530 wrote: On Monday, 6 November 2017 at 16:12:14 UTC, Martin Tschierschke wrote: Even being the wrong Martin :-) I think the DUB registry really needs more and better filters, so that the gems inside can be found easily. (like: Number of Github stars, number of downloads, number of developers and in the future: money donated to this project ...). There has been several attempts but I would like to encourage the D Foundation to put more focus on this. Better ecosystem around third party software means less work for improvement of standard lib. Regards mt. Agreed. (IMO more important than Elvis operator) +[something] If the DIP is too complex or big, it will be getting a no from me. I just don't see any of those extra syntaxes being discussed as useful.
Re: Reorganization and list of D libraries (300+)
On 07/11/2017 12:35 AM, Fra Mecca wrote: On Monday, 6 November 2017 at 16:12:14 UTC, Martin Tschierschke wrote: On Saturday, 4 November 2017 at 00:16:35 UTC, Ali Çehreli wrote: [...] Even being the wrong Martin :-) I think the DUB registry really needs more and better filters, so that the gems inside can be found easily. (like: Number of Github stars, number of downloads, number of developers and in the future: money donated to this project ...). There has been several attempts but I would like to encourage the D Foundation to put more focus on this. Better ecosystem around third party software means less work for improvement of standard lib. Regards mt. Can we make a proposal for a change? Sure ya can. Especially if it comes with a PR ;)
Re: What are the unused but useful feature you know in D?
On 04/11/2017 6:13 PM, bauss wrote: On Saturday, 4 November 2017 at 13:27:29 UTC, rikki cattermole wrote: On 04/11/2017 2:14 PM, jmh530 wrote: [...] Okay so: A signature when it is initiated is aware of the implementation it is referencing. Allowing it to change how it behaves for compatibility reasons. An interface is designed so that a class/interface must know of the interface to inherit from. While signatures can and probably will inherit from others, this is not how it is used unlike with interfaces. Because this is a massive change in how we view them and their usage, extending interfaces is not appropriate. Luckily an already existing concept exists in the literature which does solve most of the goals and that is signatures from the ML family. I will make a mental note to rewrite that section. It reminds a lot of traits in Rust. https://doc.rust-lang.org/1.8.0/book/traits.html Rust traits are a variant of ML's signature. Only they decided to add a whole new concept which is 'impl' to it. While it is a nice idea, it would be a pain to use in real life and defeat the purpose of a signature. Which is to act as more of a 'concept' abstraction to other items. Because we have such powerful meta-programming features I see no reason to separate out the two. We can do it all in one which makes it nice and consistent between all the different implementations for a signature type. So far its starting to feel right at home against our structs and class support, I think.
Re: What are the unused but useful feature you know in D?
On 04/11/2017 2:14 PM, jmh530 wrote: On Saturday, 4 November 2017 at 12:20:37 UTC, rikki cattermole wrote: Like signatures which I'm working on! https://github.com/rikkimax/DIPs/blob/master/DIPs/DIP1xxx-RC.md The first example kind of reminds me of what I was trying to do with isSubTypeOf [1]. If you know that any function you can call on T can also be called on U, then it has the same effect. That being said, I'm not sure I really understand what you mean in the whole "Why not extend interfaces" part. [1] https://github.com/dlang/phobos/pull/5700 Okay so: A signature when it is initiated is aware of the implementation it is referencing. Allowing it to change how it behaves for compatibility reasons. An interface is designed so that a class/interface must know of the interface to inherit from. While signatures can and probably will inherit from others, this is not how it is used unlike with interfaces. Because this is a massive change in how we view them and their usage, extending interfaces is not appropriate. Luckily an already existing concept exists in the literature which does solve most of the goals and that is signatures from the ML family. I will make a mental note to rewrite that section.
Re: What are the unused but useful feature you know in D?
On 04/11/2017 1:16 PM, Eljay wrote: On Monday, 26 June 2017 at 00:38:21 UTC, Mike wrote: IMO, part of the problem is that D has the wrong defaults (e.g. `immutable` by default, `@safe` by default, `final` by default, etc...), so users have to opt in to these things when they should really only be opting out of them. Unfortunately, changing this would be disruptive and will probably never happen without a fork. If/when D 3.0 happens, as a breaking change, hopefully the defaults can be made to be better right defaults. (D 1.x to D 2.x had *cough* some breaking changes.) I also hope that for D 3.0, both Walter and Andrei play with F# or OCaml for a while. There's a lot of Good Things in F# and OCaml that perhaps could be considered for D 3.0. Like signatures which I'm working on! https://github.com/rikkimax/DIPs/blob/master/DIPs/DIP1xxx-RC.md
Re: private keyword dont appear to do anything
Visibility modifiers like private, and public are to the module not the scope. "Symbols with private visibility can only be accessed from within the same module." This is how module based languages work, a bit more useful then to the scope approach IMO. An easy mistake to make. https://dlang.org/spec/attribute.html#visibility_attributes
Re: New version of JavacTo available.
On 03/11/2017 12:17 AM, Patrick wrote: Please to announce: A new version of JavacTo available for download. Version 1.1 https://sourceforge.net/projects/javacto/ Features: * Updated JavacToD visitor. Almost 100% parsing success with dscanner and JDK package subset (see results below). * Updated JavacToJava visitor. * Source and Target Text pane mouse click integration with List and Tree views. Click in a text pane and the list and tree view will update with the related visitor node. Very cool. * New search capabilities. Text and Tree.Kind search. * Support for command line translation (non-UI, very fast). * Target highlighting is now automatic (matches java source highlighting). No need to add code to highlight. In fact, manually highlighting code is discouraged. * Process dialog when reading large .zip/.jar files. * Other UI enhancements. Results with dscanner: Package Total files Failed java.util 362 15 java.math 8 1 java.net 78 0 java.nio 126 1 java.io 83 0 java.lang 219 4 Success is attributed to dscanner providing no output when parsing a file. Failures are all attributed error output from: * Java’s hybrid enum definition. (Which I believe will take a D enum and custom class to implement.) * Java’s lambda method definition. Successful parsing with dscanner I believe is a major milestone for JavacTo. This suggests a good percentage of java code can be automatically translated to D. Clearly this is not a definitive statement just yet, but an encouraging move in the right direction. Dscanner can now be used to format the JavacToD generated code for code review. Andcritique the quality of the code generated (or worse, the quality of the java code :). It’s clear the next step is to successfully compile the code. With effort working towards a successful compile, there's no doubt more changes are in store for the JavacToD visitor code. In addition, I’m anticipating some hand editing of the generated code will be required while other code will be thrown out. Perhaps helper code will be warranted as well. In any case, we'll see where the compiler takes us as we work towards a weighted balance of auto-generated code to hand editing. Anyway, to be clear, the current objective (hope) is to create a D library based on java JDK subset listed above (or something close to it). This library can then be used as the bases for translating other open source java projects to D. So… more work to be done. Patrick Could you instead side-track and create JNI bindings instead? This would be a massive help for Android.
Re: Issue with sc.ini within XMake build infrastructure
On 02/11/2017 1:56 PM, Andre Pany wrote: On Thursday, 2 November 2017 at 12:21:50 UTC, rikki cattermole wrote: Override the shipped sc.ini file with your own. Simple and effective solution. What I just found out, by calling the batch file "vcvars64.bat" from the visual studio folder it seems everything is already pre configured (LIB environment variable needed for the linker contains paths to lib\x64, ucrt\x64 and um\x64) and also the path environment variable has already the right value in first place: Path=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64; I have to ship an almost empty sc.ini. Everything else is set by the vcvars64.bat file. It would be great if the default sc.ini would anticipate the usage of vcvars*.bat. Just call the batch and everything works out of the box. Kind regards André Guess what all "just works" with the installer? :p
Re: Issue with sc.ini within XMake build infrastructure
On 02/11/2017 12:42 PM, Andre Pany wrote: Hi, I have a windows slave on which the dmd archive is extracted and dub is executed using build scripts. The windows slave has Visual Studio 2017 installed. I would like to switch from OMF to COFF executables to also allow 64 bit compilations. My issue is, there is no way to install DMD using the executable setup but only extracting the DMD archive. Also editing the sc.ini (by a build script) I dislike. I tried to begin with an easy example. I set the environment variables: SET UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10 SET UCRTVersion=10.0.16299.0 SET VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503 SET LINKCMD=%VCINSTALLDIR%\bin\HostX64\x64\link.exe SET LIB=%LIB%;"%VCINSTALLDIR%\lib\x64" SET LIB=%LIB%;"%UniversalCRTSdkDir%\Lib\%UCRTVersion%\um\x64" SET LIB=%LIB%;"%UniversalCRTSdkDir%\Lib\%UCRTVersion%\ucrt\x64" and after that I called dmd to compile a test application using the -m64 switch. From the error I can see, that my LINKCMD environment variable is overwritten by the sc.ini line: LINKCMD=%VCINSTALLDIR%\bin\link.exe Error: can't run 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\link.exe', check PATH. How can I solve this issue? Kind regards André Override the shipped sc.ini file with your own. Simple and effective solution.
Re: Any book recommendation for writing a compiler?
On 01/11/2017 11:13 PM, Jonathan M Davis wrote: On Wednesday, November 01, 2017 20:53:44 Dr. Assembly via Digitalmars-d- learn wrote: Hey guys, if I were to get into dmd's source code to play a little bit (just for fun, no commercial use at all), which books/resources do you recommend to start out? Well, if you're looking to actually buy a book, this is the one that I used in college and it was good: https://www.amazon.com/Compiler-Construction-Principles-Kenneth-Louden/dp/0534939724/ref=sr_1_1?ie=UTF8=1509574006=8-1=louden+compiler Out of stock: https://www.thriftbooks.com/w/compiler-construction-principles-and-practice_kenneth-c-louden/263600/#isbn=0534939724 However, the one that folks generally mention is the "dragon book:" https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811 https://www.thriftbooks.com/w/compiladores-principios-tecnicas-y-herramientas_alfred-v-aho/248872/#isbn=0201100886 I haven't read it though, so I can't comment on its contents, just that it's commonly recommended. Neither book is exactly cheap though. There may be some good online resources for learning about compilers, but I don't know them. However, if you're really serious about it, you'll probably want to read a textbook, since it's the sort of area where a good theoretical background to things can be quite useful. Certainly, at minimum, you're going to want to know the differences between things like a lexer and parser and what an abstract syntax tree is. - Jonathan M Davis I'd call it cheap ;) It isn't too bad grounding in everything, but doesn't branch out much (which is fine) and yeah invest in the hard cover version, its well worth it.
Re: Note from a donor
On 26/10/2017 10:38 PM, MrSmith wrote: On Thursday, 26 October 2017 at 17:02:40 UTC, Mike Parker wrote: That's exactly the kind of developer background I'm thinking of. Getting permission to redistribute from MS would be the ideal solution. If not, I'm sure someone will find a way to make it work with the LLVM or MinGW tools eventually. Would it be possible to create import libs that for all winapi/crt libs, and redistribute them? Will such libs be legal to redist? We have the tools (DMD/LLD), but the dependency on winsdk and VS libs is still there, unfortunatelly. Those files should be included with the request to Microsoft.
Re: D for microservices
On 26/10/2017 11:25 AM, Adam Wilson wrote: On 10/25/17 23:57, Jacob Carlborg wrote: On 2017-10-26 00:53, Adam Wilson wrote: This of course makes the assumption that we clean-room our own protocol implementations which I am entirely against. Better to use what already exists. I'm entirely against anything that is not compatible with vibe.d ;) My apologies, something rather the other direction. Instead of forcing compat with vibe.d, going to vibe.d and say: "here is our standard event-loop, it has everything you need, you'll need to use it for all the other goodness to work". I know others can make good arguments about why the vibe event-loop is insufficient, and I'll let them make them. (Something about not supporting GUI loops, paging Mr. Cattermole). If that is really the case I don't see how being entirely vibe.d compatible and meeting the universal standard requirements of Phobos is possible. There would need to be a requirements gathering phase so that the community as a whole can bring their use-cases before we dove into code. The problem isn't the event loop design. Its a fairly solved problem. The way vibe.d's works is very specific to their use case (which isn't wrong if you only consider them). You can't 'hook' into it. Which makes it very undesirable for Phobos. Since it won't cover most use cases. Even if the source they are using is compatible with an external GUI event loop (which it should be for Windows from what I've read). So I wouldn't be starting with vibe.d's event loop model. Quite to the contrary, kill it. Build something that will last throughout the ages for everyone and put this problem to rest.
Re: Required Reading: "How Non-Member Functions Improve Encapsulation"
On 25/10/2017 11:19 PM, Walter Bright wrote: for core D devs. "How Non-Member Functions Improve Encapsulation" by Scott Meyers http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197 Note that I'm as guilty as anyone for not understanding or following these guidelines. I expect we can do much better. UFCS kills off a good part of those arguments, but point still stands. ```D struct Point { private int[2] d; this(int x, int y) { d[0] = x; d[1] = y; } @property { ref int x() { return d[0]; } ref int y() { return d[1]; } } } void main() { Point p = Point(1, 3); p.y = 2; } ``` Hehe ;)
Re: Note from a donor
On 25/10/2017 11:46 PM, Adam Wilson wrote: On 10/25/17 11:23, H. S. Teoh wrote: On Wed, Oct 25, 2017 at 08:17:21AM -0600, Jonathan M Davis via Digitalmars-d wrote: On Wednesday, October 25, 2017 13:22:46 Kagamin via Digitalmars-d wrote: On Tuesday, 24 October 2017 at 16:37:10 UTC, H. S. Teoh wrote: (Having said all that, though, D is probably a far better language for implementing crypto algorithms -- built-in bounds checking would have prevented some of the worst security holes that have come to light recently, like Heartbleed and Cloudbleed. Those were buffer overflows in parsers, not in cryptographic algorithms. The point still stands though that you have to be _very_ careful when implementing anything security related, and it's shockingly easy to do something that actually leaks information even if it's not outright buggy (e.g. the timing of the code indicates something about success or failure to an observer), and someone who isn't an expert in the area is bound to screw something up - and since this is a security issue, it matters that much more than it would with other code. [...] Yeah. There have been timing attacks against otherwise-secure crypto algorithms that allow extraction of the decryption key. And other side-channel attacks along the lines of CRIME or BREACH. Even CPU instruction timing attacks have been discovered that can leak which path a branch in a crypto algorithm took, which in turn can reveal information about the decryption key. And voltage variations to deduce which bit(s) are 1's and which are 0's. Many of these remain theoretical attacks, but the point is that these weaknesses can come from things you wouldn't even know existed in your code. Crypto code must be subject to a LOT of scrutiny before it can be trusted. And not just cursory scrutiny like we do with the PR queue on github; we're talking about possibly instruction-by-instruction scrutiny of the kind that can discover vulnerabilities to timing or voltage. I would not be comfortable entrusting any important data to D crypto algorithms if they have not been thoroughly reviewed. T I am one-hundred-ten percent in agreement with Mr. Teoh here. Even .NET Framework and Core forward to the highly vetted system crypto API's (SChannel on Windows and OpenSSL on Linux/macOS). If you need RSA crypto in D, pull in OpenSSL. Period. Everything else is a good way to run afoul of a security audit, and potentially expose yourself. Phobos could forward to these system provided API's like .NET does and provide an idiomatic D interface, but Phobos itself should absolutely and 110% stay out of the crypto implementation business. Or mbedtls who has also been audited (but much better and nicer code!). Either way, you write it, you pay for auditing or no users. Hence I won't use our port of Botan.
Re: Note from a donor
On 24/10/2017 2:25 PM, Mike Parker wrote: On Tuesday, 24 October 2017 at 13:20:10 UTC, Andrei Alexandrescu wrote: * better dll support for Windows. This one is on a lot of wish lists. It definitely needs to be a target for 2018H1, I'll be making sure its added! Too big a blocker and comes up a little too often...
Re: My two cents
On 24/10/2017 10:31 AM, Kagamin wrote: On Tuesday, 24 October 2017 at 07:29:08 UTC, Satoshi wrote: If we want to use D for GUI development we will need this feature anyway. To not block UI you need non-blocking IO, and async/await is not required for it: vibe provides non-blocking IO with synchronous interface. And here we also have another shortcoming of async/await: it doesn't interact well with GUI that traditionally uses synchronous event handlers (mostly because it predates async/await). Just a random idea, something to think about: ``` struct Task { void delegate() del; void* stack; Status status = Status.finished; void continue() { del(); } } () { size_t lastJump; if (lastJump == J1) { lastJump=J2; jmp J2; } else lastJump = J1; J1: ubyte[] gotRead = doRead(__task, "..."); yield; J2: gotRead /= 2; doWrite(__task, "...", gotRead); complete; // yield if wasn't done } ``` From: ``` ubyte[] doRead(string name) async { ... } void doWrite(string name, ubyte[] data) async { ... } void callback(...) { ubyte[] gotRead = doRead("..."); gotRead /= 2; doWrite("...", gotRead); } ``` scope+ref+out as arguments would be a no-no. Now if we could ditch registers usage crossing before/after yield, we wouldn't need to do 'patching' like fibers do.
Re: D for microservices
On 23/10/2017 11:02 PM, Adam Wilson wrote: On 10/23/17 05:08, Jacob Carlborg wrote: * Database drivers for the common databases (PostgreSQL, MySQL, SQLite) compatible with vibe.d * Database driver abstraction on top of the above drivers, perhaps some lightweight ORM library I've been looking pretty extensively at these two items recently. If the database drivers are compatible with Vibe.d AND we wish to provide a common abstraction layer for them (presumably via Phobos) then order for the abstraction layer to aware of the whether the driver is making a blocking or non-blocking call we must include Vibe.D in the abstraction layer. Ergo, we must include at least the vibe-core package in Phobos, or more preferably, DRT. I had heard noises about that a few months ago. Anything happening on that front? An event loop is a key piece of a project (Async/Await) that I want to work on, and having it in DRuntime would make that project fantastically simpler. IMHO, the bulk of the time required is in getting an event loop into DRT, the rest is a LOT of relatively straightforward compiler lowering. IMHO, DRT is in significant need of an event loop system. This would allow us to simplify a large number of problems (Async/Await, GUI's, IO, etc). As near as I can tell, the problem isn't so much doing the work, but getting the required sign-off's for inclusion into DRT. Another problem that I've been made aware of is that vibe-core may not be ideal in certain situations. As this would be landed in DRT itself this would obviously need to be addressed. What would the appetite be for working together to come up with a reasonably generic event loop for DRT that vibe and other systems could then leverage? *whispers* heyyy, heard about SPEW[0]? [0] https://github.com/Devisualization/spew/blob/master/src/base/cf/spew/event_loop/defs.d
Re: Dynamically import() files
Don't be afraid to write a small script that is run before a build to generate a list of files which than can be imported.
Re: My two cents
On 23/10/2017 10:58 AM, bauss wrote: On Monday, 23 October 2017 at 06:05:50 UTC, drug wrote: 20.10.2017 17:46, Martin Nowak пишет: On Thursday, 19 October 2017 at 06:50:12 UTC, Fra Mecca wrote: We miss a build system that is tailored towards enterprises Anything more specific on that? My 2 cent: 1. dub needs ability to work with other repository than standard ones. You can use "preGenerateCommands", "postGenerateCommands", "preBuildCommands" or "postBuildCommands", then simply have some shell script to invoke that performs what you need with other eco systems. "other repositories" here probably means other than github, bitbucket and gitlab. Which isn't actually part of dub in the first place!
Re: Static if on release build
On 20/10/2017 3:36 AM, Fra Mecca wrote: I can't find any documentation regarding conditional compilation in release and debug mode. I have read the page regarding the topicon dlang.org but adding the snippet below makes no difference when compiling with dub -b release { version(full) { //do something } else { //do something else } How can I produce a release version with different parameters from debug using dub and static if's? Well yeah... full doesn't exist[0]. If debug is turned on: debug { } else { } That else isn't for 'release'. Release turns on optimizations in the compiler and disables a few other things like asserts. If you want to specify a version at the command line use ``-version=MyVersion``. For a debug identifier use ``--debug=MyDebug`` and yes, debug conditions can have identifiers like versions require. For dub you can specify it via ``versions`` and ``debugVersions``. [0] https://dlang.org/spec/version.html [1] http://code.dlang.org/package-format?lang=json
Re: Back to SDL question
On 19/10/2017 2:34 PM, Suliman wrote: First of all I would like to say sorry for Ludwig, that 2 years ago I was initiator to making JSON back by default for dub config. It was really my mistake. Only some time later I understand that it was big error. So I would like to ask community about if all agree to make .sdl format to dub by default? My mind hasn't wavered. I am still against SDL.
Re: My first experience as a D Newbie
On 16/10/2017 9:56 AM, Rion wrote: On Sunday, 15 October 2017 at 20:27:35 UTC, Laeeth Isharc wrote: D is much less gratifying than other languages for most people. Just like Windows was more gratifying than Linux for most people in 2000. And I suppose that's likely to change slowly, but continue to be the case for a while so long as people working on Windows don't notice when something isn't working and fix things at root cause. It's usually not that much more difficult to do so than work around it, and it usually pays off even considered selfishly. I can appreciate your frustration, but considering how many years knowing a programming language can pay off for, a few hundred hours spent to learn something new isn't that much. That's like a couple of months full-time and if it works out the payback period should easily be a year. Viewed rationally, that's a pretty good return on investment compared to most other opportunities available. In a world where there are lots of smart people and knowledge is widely available, the barriers to opportunity (there must be barriers, otherwise the opportunity would be competed away) are often emotional ones. So I like things where the difficulty is front-loaded, because they tend to be neglected by modern people who are used to quick gratification. And whilst it surely can be frustrating, the situation is already better both on Windows and as regards documentation and tooling than it was in 2014. It's not difficult to make little changes towards what one would like to see oneself. When you invest this time into a language, you have expectations. A person expects for a language this old, that every puzzle fits together without issue. Call me spoiled if you want but quick gratification it is not. The time wasted on dealing with issue on D, is time you can have spend in a different language actually writing code/testing. Its a barrier to the language its own success when its not as user friendly as the other languages. If a person needs to do a action in Windows and it takes him 5 mouse clicks. But hey, under Linux you can do it with one command line arg, ... the Linux approach sound more easy right? Until you add the time needed to learn the command and assuming there are no issues. What is more rewarding or punishing? There is a reason that Windows is still so popular. Windows does not get in the way. It just keep working. Can it be improved, yes! MS puts a massive amount of time and money in there testing. And it shows in there platform. Its the same reason why Linux as a desktop OS will never work out. Too much puzzle pieces that do not fit, too much assumed that people need ( and have the time ) to learn the complicated way. A lack of inter-testing beyond just the basic compile tests ( i mean really usage ). And yet my elderly-ish mother uses Linux Mint and she hates technology. It isn't as clear cut as it may appear, these issues.
Re: How do I use WINAPI's ITaskbarList3?
On 13/10/2017 4:01 PM, Nieto wrote: How do I use other than Windows.h with D? For Windows.h I know it's core.sys.windows.windows but what's the module for Shobjidl.h for example? is this supported natively? (i tried core.sys.windows.shobjidl actually) but not so, what alternative are there? All: https://github.com/dlang/druntime/tree/master/src/core/sys/windows Pretty much nothing regarding COM is in there. https://github.com/dlang/druntime/search?p=1=IUnknown==%E2%9C%93 You will need to create the bindings yourself. More importantly learn COM.
Re: Implicit Constructors
On 13/10/2017 2:07 PM, Steven Schveighoffer wrote: On 10/13/17 9:04 AM, rikki cattermole wrote: Lets just kill it. It's an ugly unexpected piece of syntax. It may be used somewhere, and then what is the migration path for those people? I don't see that it's harming anything having it there, most of us didn't even know about it. 1) Warning, then actual removal. It'll still be available for a few releases for people to update their code 2) Fairly simple replacement: new Foo(0) It's also not necessary to remove the feature in order to build a library that does similar things, and the syntax isn't needed elsewhere. It is bizarre, though, that it works only for classes and builtins, and not for structs. I have experienced with Swift the team killing "ugly" features, and it's painful. And yet I expected the 0 there to be null. It would make a whole lot more sense then allocating a new instance which is considerably more expensive operation and not even used anywhere else!
Re: Implicit Constructors
Lets just kill it. It's an ugly unexpected piece of syntax.
Re: Temporary objects as function parameters or when-is-this-shit-going-to-end?
On 13/10/2017 11:40 AM, Jack Applegame wrote: Sorry, I mistakenly placed my post in the wrong section. Consider, please: https://forum.dlang.org/thread/oxucajbsjbsuraqtn...@forum.dlang.org Please create an issue for this (I couldn't find one that matched[0]). Your first example was quite a good reduced test case. To anybody else, the poster is willing to pay a token to have this fixed. [0] https://issues.dlang.org/buglist.cgi?quicksearch=postblit%20not%20called
Re: CSV crash: "Quote located in unquoted token"
On 13/10/2017 11:05 AM, Dmitry wrote: On Friday, 13 October 2017 at 09:00:52 UTC, rikki cattermole wrote: Write a purpose built csv parser using ranges. It should take only about half an hour. I know, I know not very helpful. But a custom built parser will work better for you I think. Yep, I can parse it myself, but I want to try to avoid this (reduce amount of source code). Maybe there is posiible something like this: foreach(record; file.byLine.fixQuotes.joiner("\n").csvReader!... ? What types should get/return the function (fixQuotes) if I want change the line after .byLine? When compiler says: "candidates are: src\phobos\std\array.d(2534,5): std.array.replaceFirst(E, R1, R2)(E[] subject, R1 from, R2 to) if (isDynamicArray!(E[]) && isForwardRange!R1 && is(typeof(appender!(E[])().put(from[0..1]))) && isForwardRange!R2 && is(typeof(appender!(E[])().put(to[0..1]" it's scares me and I hiding under the table. I thought about something like auto fixQuotes(string text) { if (text.canFind("\"\"")) { // some magic } return text; } but obviously, it won't compiled Something along the lines of: .byLine.map!(a => a.fixQuotes).joiner("\n").csvReader!... Either way, you're using ranges! Its even the same amount of code, if not less.
Re: CSV crash: "Quote located in unquoted token"
Write a purpose built csv parser using ranges. It should take only about half an hour. I know, I know not very helpful. But a custom built parser will work better for you I think. This should help get you started: https://gist.github.com/rikkimax/42c3dfa6500155c5e441cbb1437142ea#file-reports-d-L126
Re: std.concurrency.setMaxMailboxSize
On 11/10/2017 12:43 PM, RazvanN wrote: On Wednesday, 11 October 2017 at 11:26:11 UTC, rikki cattermole wrote: On 11/10/2017 12:09 PM, RazvanN wrote: Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other threads doesn't seem to be a good idea and I can't think of any real use case. Best regards, RazvanN [1] https://dlang.org/phobos/std_concurrency.html#.setMaxMailboxSize Main controlling thread setting child threads? Otherwise I don't remember the last time it was mentioned, so I'd say leave it be :) Shouldn't the thread be in charge of its mailbox size? Otherwise, main can pass the max size in the constructor. Callee, versus caller. Just depends how you're thinking of the responsibility. You can make arguments either way.
Re: struct/class generation
On 11/10/2017 12:37 PM, ANtlord wrote: Hello dear community! I've met a little issue. How can I generate struct or class copying some fields and methods from another struct or class? I've found methods to get fields. They are std.traits.FieldNameTuple and std.traits.FieldTypeTuple but I can't find a method allows getting methods from struct or class. Other words I want to get fields and methods by string values and copy them to my struct. Is it possible? Or do I want something strange? Thanks in advance. Sorry if my English is not clear. There is no way to get string versions of function bodies.
Re: std.concurrency.setMaxMailboxSize
On 11/10/2017 12:09 PM, RazvanN wrote: Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other threads doesn't seem to be a good idea and I can't think of any real use case. Best regards, RazvanN [1] https://dlang.org/phobos/std_concurrency.html#.setMaxMailboxSize Main controlling thread setting child threads? Otherwise I don't remember the last time it was mentioned, so I'd say leave it be :)
Re: Assert and undefined behavior
On 11/10/2017 10:27 AM, John Burton wrote: The spec says this :- "As a contract, an assert represents a guarantee that the code must uphold. Any failure of this expression represents a logic error in the code that must be fixed in the source code. A program for which the assert contract is false is, by definition, invalid, and therefore has undefined behaviour." Now I worry about the words "undefined behavior" because in C++ compiler writers seem to have decided that these words mean that it's ok for the compiler to generate code to do whatever it feels like even in unconnected code and even before the undefined behavior is invoked because some subsequent code has undefined behavior. From my C++ experience this paragraph tells me that if I use "assert" to check my assumptions, and the assertion is false, then this could lead to my program failing in unpredictable ways unconnected with the actual assertion. I therefore feel like I ought to not use assert and should instead validate my assumptions with an if statement and a throw or exit or something. I feel like a failing assertion should not cause "undefined behavior" in the sense it is commonly used in C++ programming these days but should have exactly defined behavior that it will do nothing if the assert passes and throw the specified exception if it fails. Can I safely assume this despite the wording? I know this might seem like a small or pedantic point, but C++ compilers can and do use invoking undefined behavior as an excuse to do all kinds of unexpected things in generated code these days and I want to write safe code :) I feel that if D is specified in the same way then assert is not safe for me to use in a real program. You misinterpreted it. The program /could/ be in an invalid state because an internal state check (assert) says that it isn't. What the compiler generates for the assert, depends upon the platform and if its building with optimizations. But all of them will end in the process crashing unless you go out of your way to handle it. By default it throws and Error in debug mode, which you shouldn't be catching since it is an Error and not an Exception anyway.
Re: My first experience as a D Newbie
On 11/10/2017 8:23 AM, Peter R wrote: snip 4. it took a while to see that the DMD builds come with x86 windows libraries, but no x64 windows libraries. That seems strange in this day and age We should document this on the download page making it obvious why you also need VS.
Re: DLL hell :S
On 07/10/2017 4:29 PM, Ian Hatch wrote: On Saturday, 7 October 2017 at 15:14:01 UTC, rikki cattermole wrote: Email Walter directly. I intend to campaign for next years (basically a soft TODO list) plan for what we want done. But until then, he and Andrei need to hear that this is the biggest limitation that D faces currently, not memory management. Hm, are you saying "if you email Walter he can tell you how to sort it" or "please make sure Walter knows this problem is important" (or both)? Definitely happy to give my feedback. A little from column a, a little from column b, but most because he might be able to do something for you. "not memory management" gives me an idea actually - if I ditch the GC, which I may want to do eventually anyway, I guess I won't have this issue.
Re: DLL hell :S
Email Walter directly. I intend to campaign for next years (basically a soft TODO list) plan for what we want done. But until then, he and Andrei need to hear that this is the biggest limitation that D faces currently, not memory management.
Re: Default allocator of container plus element type
On 05/10/2017 12:35 PM, Nordlöw wrote: Would it be possible to set up a mapping (either formal or informal) of each typical container (such as array, linked-list etc) plus element type to a suitable default allocator? And perhaps add this to the documentation of `std.experimental.allocator`? I currently get the feeling that most programmers have no idea at all what allocator to choose for each given combination of container and element type they want to use. Most developers should never need to touch or swap out allocators. It can be a performance optimization for the more advanced users. Let container makers decide a good default for /their/ implementation. Allocators solve a problem that very few developers actually have. Contrary to popular belief. The default GC allocator is probably ok for most people. I'm happy with it for SPEW[0] and it heavily uses allocators. [0] https://github.com/Devisualization/spew
Re: Vibe.d using Windows Certificate binding, possible?
On 04/10/2017 3:54 AM, Jesse Phillips wrote: On Tuesday, 3 October 2017 at 23:29:49 UTC, rikki cattermole wrote: On 03/10/2017 4:52 PM, Jesse Phillips wrote: I'm pretty sure this isn't possible, but maybe someone understands Windows better. Windows provides a means no bind a certificate to a port using netsh.exe. This means (at least for standard Windows networking calls) connections to that port will be given the bound cert. The Vibe.d documents state that a Certificate chain and key needs to be provided. I'm pretty sure that the port binding requires very specific Network API calls, possible .NET only. Can any confirm or deny? Perhaps you could reference the command (aka the args with an example)? Otherwise, its a lot harder to figure out what it is doing under the hood. Here is the command docs https://msdn.microsoft.com/en-us/library/windows/desktop/cc307220(v=vs.85).aspx "Application program source files include the Http.h header file to access function prototypes and structure definitions for the HTTP Server API. Developers can use the Httpapi.lib library file to build applications that use the HTTP Server API. At runtime, applications link to the Httpapi.dll." So no, vibe.d can't work with it. This a special snow flake feature from 2k3 server days.
Re: Vibe.d using Windows Certificate binding, possible?
On 03/10/2017 4:52 PM, Jesse Phillips wrote: I'm pretty sure this isn't possible, but maybe someone understands Windows better. Windows provides a means no bind a certificate to a port using netsh.exe. This means (at least for standard Windows networking calls) connections to that port will be given the bound cert. The Vibe.d documents state that a Certificate chain and key needs to be provided. I'm pretty sure that the port binding requires very specific Network API calls, possible .NET only. Can any confirm or deny? Perhaps you could reference the command (aka the args with an example)? Otherwise, its a lot harder to figure out what it is doing under the hood.
Re: Just playing with compiler explorer to see assembly line count.
Be warned, x86 cpu's today are not like they were 10 years ago. A good portion of a symbol could be full of nop's and it could end up being faster than the one without them. Next, compare against ldc, not gdc primarily. Its better maintained and ugh more inline with dmd (its a bit of a mess, lets not go there). Of course nothing wrong with doing both. std.container.* is basically dead. We need to replace it. We are currently waiting on std.experimental.allocators before going much more further (also a lot of other no-gc stuff). Compare (on https://d.godbolt.org/ with "ldc -O3" and "gdc -O3"): --- auto test1(int[] arr, int cmp) { int[] r; foreach(v ; arr) if(v == cmp)r~=v; return r; } import std.container.array; auto test2(ref Array!int arr, int cmp) { Array!int r; foreach(v ; arr) if(v == cmp)r.insert(v); return r; } ---
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On 03/10/2017 1:05 PM, sighoya wrote: Especially, I mean something like T foo(S,T)(T i) { ... } struct Foo(T) { T value; } T!S foo(S, alias T)(T!S v) { return v; } void main() { import std.stdio; writeln(foo!(int, Foo)(Foo!int(1))); }
Re: Meet our new scholarship recipient, Alexandru Jercaianu
On 02/10/2017 6:04 PM, Andrei Alexandrescu wrote: Hello everyone, it is my pleasure to announce that Alexandru Jercaianu, a starting MSc student at University "Politehnica" Bucharest, is recipient of our scholarship. Alex is up and running working on his bootcamp tasks. Currently he is attempting unsuccessfully to post in our general group :o). Please join me in welcoming Alexandru! Andrei Welcome Alex, don't forget to pop on to IRC (Freenode #D) and have a chat to us regulars!
Re: Using dates to get days count
On 29/09/2017 7:29 AM, Joel wrote: How do I count the days between to dates? https://dlang.org/phobos/std_datetime_date.html#.Date.opBinary.2 https://dlang.org/phobos/core_time.html#.Duration.total
Re: Day of week from date
On 29/09/2017 4:25 AM, Joel wrote: With a given date, I want to know what day it is (like Sunday, Monday, etc). I had a look up on std.datetime, and core.time, but they don't seem to have a function for it. https://dlang.org/phobos/std_datetime_date.html#.DateTime.dayOfWeek
Re: What does ! mean?
There are two types of arguments in D. The runtime one (which you are well aware of) and the compile time one. A compile time argument is a constant passed in during construction of a symbol. But here is the thing, it isn't just limited to functions, you can have it on classes as well. --- class Foo(bool b) { bool get() { return b; } } void main() { Foo!true v = new Foo!true; assert(v.get); } --- Same logic going on. --- bool get(bool b)() { return b; } void main() { assert(get!true == true); } --- It can do more than a simple boolean being passed in, but that is the gist. Templates are wonderful (also read the spec!).
Re: Real beginner traits question
On 25/09/2017 6:28 AM, WhatMeForget wrote: This is taken exactly from the traits documentation. 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. There are no examples. My naive brain keeps thinking that a symbol and an identifier are the same things. Can someone give me good definitions of "symbol" and "identifier". And maybe an example if it is not too much trouble. ```D void main() {} pragma(msg, __traits(identifier, main)); pragma(msg, __traits(identifier, Foo)); pragma(msg, __traits(identifier, Foo.func)); struct Foo { void func(); } ``` ``` main Foo func ```
Re: Dub use local fork
On 23/09/2017 10:34 AM, Guillaume Piolat wrote: On Saturday, 23 September 2017 at 03:16:30 UTC, rikki cattermole wrote: Alternatively you can alter the package that dub already knows about. Does the trick more easily ;) +1 That's the dirty trick I'm using too You can also do the same for Phobos+druntime when it comes to templated symbols. Of course it won't redownload if you delete the file, so gotta be a bit more careful. But a wonderful way to confirm that your fix actually fixes it before a PR.
Re: Dub use local fork
On 23/09/2017 4:13 AM, Nicholas Wilson wrote: I want to use a fork of one of my dub dependencies so I can make sure that it works before I merge the fork into upstream. http://code.dlang.org/advanced_usage says Path-based dependencies Package descriptions in the dub.json/dub.sdl can specify a path instead of a version; this can be used with Git submodules or subtrees, or with a known directory layout, to use arbitrarily defined versions of a dependency. Note that this should only be used for non-public packages. Path-based selections You can specify arbitrary versions, branches, and paths in the dub.selections.json file, even if they contradict the dependency specification of the packages involved (note that DUB will output a warning in that case). but doesn't give any examples. my dub.selections.json is currently: { "fileVersion": 1, "versions": { "derelict-cl": "2.0.0", "derelict-cuda": "2.0.1", "derelict-util": "2.1.0", "taggedalgebraic": "0.10.7" } } I want derelict-cl to use C:\Users\me\Documents\GitHub\DerelictCL How do I do that? Thanks Nic Alternatively you can alter the package that dub already knows about. Does the trick more easily ;)
Re: Connecting python to D on socket of localhost : target machine actively refuses connection
On 23/09/2017 3:26 AM, Sergei Degtiarev wrote: On Friday, 22 September 2017 at 04:06:08 UTC, Enjoys Math wrote: Here's my minimal D code (server.d): public: this(ushort port, string address="") { super(& run); if (address == "") address = "DESKTOP-T49RGUJ"; this.port = port; this.address = address; . listener.bind(new InternetAddress(address, port)); It seems to me, you pass invalid address to bind(). InternetAddress takes ipv4 dot notation string x.x.x.x, and for bind you are to supply INADDR_ANY For DNS resolution: https://dlang.org/phobos/std_socket.html#.getAddress
Re: Godbolt.org: mir-algorithm was added
On 22/09/2017 5:36 AM, Arun Chandrasekaran wrote: On Friday, 22 September 2017 at 03:51:36 UTC, Ilya Yaroshenko wrote: Mir Algorithm and Mir GLAS (glas is experimental) was added to https://d.godbolt.org by Johan Engelen. Thanks you, Johan! [...] Honestly, how do you guys understand these assembly instructions that's further optimized by the complier? Am I alone here? By reading the damn manual! (It can take a while to understand x86, it is a right royal mess with layers on top of layers in it). If you do intend on reading the manual, I recommend AMD's. They created x86_64, not Intel. They you can actually learn from. http://developer.amd.com/resources/developer-guides-manuals/ You want: http://support.amd.com/TechDocs/24594.pdf
Re: What the hell is wrong with D?
On 19/09/2017 9:22 PM, Neia Neutuladh wrote: On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote: writeln(x + ((_win[0] == '@') ? w/2 : 0)); writeln(x + (_win[0] == '@') ? w/2 : 0); The first returns x + w/2 and the second returns w/2! Yeah, it sucks to have bugs like this crop up. I have enough trouble remembering operator precedence, so I end up using parentheses everywhere and pretending the ternary operator doesn't exist. I also tend to break up complex expressions a lot. It's just safer, and usually clearer. Agreed, no surprises is the best surprise!
Re: D std.regex is so slow
On 19/09/2017 8:53 AM, Daniel Kozak wrote: https://github.com/mariomka/regex-benchmark#performance Do you know why? Here is a code: https://github.com/mariomka/regex-benchmark/blob/master/d/benchmark.d I have try it with ldc too, but is still much slower (10x) than PHP Most likely everything below D is being JIT'd.
Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D
On 17/09/2017 6:30 AM, Enjoys Math wrote: Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And using the command line has no effect - it repeats the above. He got into this situation by accidentally installing Visual Studio and / or Visual D to C:\D where I told him to install D to. At one point I told him to delete everything in C:\D and start over. *That* was a mistake... He's used a trial version of Revo-Uninstaller to remove contents of registry. The issue remains. How can we repair his system so that we can install D on it again? Thanks. Skip Revo-Uninstaller, no idea why you'd ever use such trial software. Anyway what you want is CCleaner, standard software that all Windows installs should have on hand. That should remove all references to VS quite happily. It does a lot more than just modify the registry too :)
Re: D still has some work with publicity
On 15/09/2017 1:19 PM, Wulfklaue wrote: A recent posting comparing programming languages and there energy efficiency: https://sites.google.com/view/energy-efficiency-languages/results What language that can be in the top is missing? Only one guess needed. Its not hard to figure out without going to the description, that the author used benchmarksgame.alioth.debian.org for all the code. A benchmark test where D is missing for years. And it being referred into other projects for there tests. Those same projects that draw publicity. D missing in that benchmark is a clear issue because its free publicity that keeps getting lost. Author of said benchmarks here: http://forum.dlang.org/post/djpatdgdyhscgtvii...@forum.dlang.org Can we please kill this line of thinking already?
Re: extern(C) enum
On 15/09/2017 5:15 AM, bitwise wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D, is it guaranteed to have the same underlying type and size as it would for a C compiler on the same platform? No need for extern(C). Be as specific as you need, but most likely you won't need to (e.g. first is automatically 0). enum Foo : int { Start = 0, StuffHere End }
Re: Known reasons why D crashes without any message?
1) You really need to switch to ldc, even for small neural networks, it makes a MASSIVE difference! 2) In release mode, who knows what'll happen. Add some logging in maybe (versioned/debug of course) to help figure out where things are going on. 3) Wrap it up with try catch and write out the message yourself. You want Error not Exception FYI. Not terribly helpful, but a good place to begin anyway. Of course if somebody is calling the c exit function, it may very well bypass D's exception handling all together.
Re: database 0.0.8 released
Add on allocator support and many more comments, aka if public facing then document it. Then we'd be in business!
Re: Deimos X11 bindings license question
On 11/09/2017 2:58 PM, Vadim Lopatin wrote: On Monday, 11 September 2017 at 13:41:39 UTC, rikki cattermole wrote: Needs more work but... https://github.com/Devisualization/spew/tree/master/src/utils/cf/spew/bindings/x11 yeah. Have you created this binding yourself w/o using of Deimos code? Indeed. Some of the files might be a bit mixed up and some others missing. But steal if you wish. I have no claim to it as far as I'm concerned. Its also a bit untested without a loader.
Re: Deimos X11 bindings license question
On 11/09/2017 1:36 PM, Vadim Lopatin wrote: On Monday, 4 September 2017 at 17:54:36 UTC, Vadim Lopatin wrote: Contributors to DUB package nomad-software/x11 nomad-software weltensturm Geod24 MartinNowak BBasile rikkimax Additionally, contributors to Deimos/libX11 growlercab bioinfornatics skilion CyberShadow Faianca Flamaros PhilipWitte edmccard arukuka IanWizard WalterBright Looks like recreating of binding from scratch based on C headers could be faster than getting confirmation from all of contributors. Needs more work but... https://github.com/Devisualization/spew/tree/master/src/utils/cf/spew/bindings/x11 yeah.
Re: -betterC and extern(C++) classes
On 10/09/2017 2:19 PM, Moritz Maxeiner wrote: If TypeInfo for extern(C++) classes is removed, couldn't final extern(C++) classes without base class and which don't implement any interfaces omit the vtable so that the following assert holds: --- final extern(C++) class Foo {} static assert (__traits(classInstanceSize, Foo) == 0LU); --- The reason I ask is that fairly often I have an abstraction that's better suited as a reference type than a value type, but doesn't need any runtime polymorphy (or the monitor standard classes have). Structs + pointers are the only way I know of to avoid the (in this special case) unneeded vtable overhead, but it always ends up looking worse to read. We can do it for any class if its final. The problem isn't generating the vtable's. But the information required for casting.
Re: -betterC and extern(C++) classes
On 10/09/2017 10:03 AM, 9il wrote: On Sunday, 10 September 2017 at 08:56:11 UTC, rikki cattermole wrote: On 10/09/2017 9:40 AM, Yuxuan Shui wrote: I was experimenting with -betterC and found out that C++ classes doesn't work. Because the resulting object file needs a symbol "_D14TypeInfo_Class6__vtblZ" which is in druntime. I suppose this is to support T.classinfo? Nope. Could we remove T.classinfo and make classes work under -betterC? Or is there some other reason preventing this from happening? Thanks. Definitely not. Classes require vtable's to work. Vtables are generated as part of TypeInfo. No TypeInfo, no classes, simple to understand. No. vtables can be generated without RTTI and we can have both D and C++ classes in betterC mode. It may not be ready now, but it is definitely possible and should be supported. Best reagards, Ilya Agreed, but that is a bigger change and would require a bit more of a rethink than just a simple 'remove reference to symbol'.
Re: -betterC and extern(C++) classes
On 10/09/2017 9:40 AM, Yuxuan Shui wrote: I was experimenting with -betterC and found out that C++ classes doesn't work. Because the resulting object file needs a symbol "_D14TypeInfo_Class6__vtblZ" which is in druntime. I suppose this is to support T.classinfo? Nope. Could we remove T.classinfo and make classes work under -betterC? Or is there some other reason preventing this from happening? Thanks. Definitely not. Classes require vtable's to work. Vtables are generated as part of TypeInfo. No TypeInfo, no classes, simple to understand. Same reason why you can't use classes and cross the dll boundary on Windows. But if you prefer not having any methods to call, then I'm sure we can remove the requirement on the vtable ;) (Not a solution)
Re: D is Multiplatform[DUVIDA]
On 08/09/2017 3:08 AM, dark777 wrote: On Friday, 8 September 2017 at 00:09:08 UTC, solidstate1991 wrote: On Thursday, 7 September 2017 at 23:58:05 UTC, dark777 wrote: Good night, did you want to know this? Is the DE language cross-platform or cross-compile like C ++? GDC and LDC has multi-platform support, I'm currently working on an ARM backend for DMD. so does it mean that if I develop a program using the D language in BSD creating generic resources for example and compiling on windows, linux and darwin it would work fine? Each platform has its own unique behavior and related code. Gotta try it to know for certain. But that is unrelated to D in the most part :)
Re: Call to Runtime.unloadLibrary corrupts stdout and stderr
On 02/09/2017 10:38 PM, Markus Pursche wrote: Hi, I'm trying to hot reload a DLL while the program is running to allow for rapid iteration in a game engine I am working on. I started reading up on how DLLs work between D code here: https://wiki.dlang.org/Win32_DLLs_in_D#D_code_calling_D_code_in_DLLs I followed that example, however when I try to do the following I crash: 1. Load DLL 2. Unload DLL 3. Load DLL again The problem I am getting is a Bad File Descriptor exception right after step 2, on my very next writeln to be exact. Here is the exception I am getting: http://imgur.com/a/b9XBm I spent a couple of hours trying to debug it, googling all sorts of combinations of "dlang unloadlibrary bad file descriptor", until I got the idea to try "dlang freelibrary bad file descriptor" and found this old bug report from 2004: http://forum.dlang.org/post/cg5hpf$kpv$1...@digitaldaemon.com This sounds absolutely spot on to the problems I am having. I tried to save stdout and reset it after unloading my library but I still crashed on the next writeln, does anyone have an idea for a workaround on this? I'm hoping that someone like Walter or Andrei will see this and decide that it's time for this 2004 issue to finally die. :P *sigh* 2018H1 plan I am listing shared library support. Even better still, I will argue it as the ONLY language/druntime feature we need in it! Seriously, this is the biggest thing holding back D atm.
Re: SIMD GC
On 02/09/2017 1:42 PM, Márcio Martins wrote: I was curious if anyone has tried implementing the GC mark phase with SIMD instrs? If so, what were the results, and why didn't it get accepted? At first thought, it seems like a simple project that could improve performance of big-memory programs by a significant margin, right? I'm not so sure it can be. https://github.com/dlang/druntime/blob/master/src/gc/impl/conservative/gc.d#L1955
Re: Open Methods: From C++ to D
On 30/08/2017 4:10 PM, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 14:37:14 UTC, Arun Chandrasekaran wrote: On Wednesday, 30 August 2017 at 13:35:22 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 04:48:11 UTC, Arun What was your rationale for `openmethod` instead of just `method`? Just that `openmethod` precisely expresses it's intent and `method` is too generic. I sort of agree, and somewhat regret not picking 'openmethod'. I considered both. Also @specialize. If anyone had pushed for @openmethod before the article, I would almost certainly have given in. My reasoning was, I hope to promote the term 'method' as the standard name for polymorphism from outside, as opposed to vfunc. We usually say "virtual functions", rarely "virtual member functions". Membership is implicit. Rename, alias to old and have it deprecated. Keep around for a couple of releases, done!
Re: Cpu instructions exposed
On 29/08/2017 2:49 AM, Cecil Ward wrote: I have written a few zero-overhead (fully inlining) D wrappers around certain new x64 instructions as an exercise to help me learn D and get used to GDC asm. I've also written D replacements for older processors. They are templated functions with customised variants supporting a variety of different word-widths. 1. Would anyone find these useful? Bet I'm inventing the wheel? (But still a good learning task for me.) Sure, why not? 2. How best to get them reviewed for correct D-style and Lets talk about 3. 3. how to package them up, expose them? They need to be usable by the caller in such a was as they get fully directly inlined with no subroutine calls or arg passing adaptation overhead so as to get the desired full 100% performance. For example a call with a literal constant argument should continue to mean an immediate operand in the generated code, which happens nicely currently in my testbeds. So I don't know, the user needs to see the lib fn _source_ or some equivalent GDC cleverness. (Like entire thing in a .h file. Yes, I know, I know. :-) ) Dub + force -inline. Also you will need to support ldc and dmd. 4. I would like to do the same for LDC, unfortunately the asm system is rather different from GDC. I don't know if there is anything clever I can do to try to avoid duplication of effort / totally split sources and double maintenance? (Desperation? Preprocess the D sources with an external tool if all else fails! Yuck. Don't have one at hand right now anyway.) Duplicate. Nothing wrong with that for such little code. Its already abstracted nicely out. As long as you are using function arguments as part of you iasm, push/pop registers you use, it should be inlined correctly as per the arguments. But I'd like to see some code before making any other remarks. I highly suggest you hang out on IRC (#d Freenode) to help get interactive reviews+suggestions.
Re: General performance tip about possibly using the GC or not
D's GC is stop the world (aka all threads) and does not run on its own (requires being asked to collect). It is only given the opportunity to collect when you allocate (new/more) memory. It can decide not to, or to do so at any point making it very unpredictable. This is why we keep saying that it is not a magic bullet. It isn't. It just does a simple set of logic and nothing more.
Re: Open Methods: From C++ to D
On 28/08/2017 9:06 PM, Jean-Louis Leroy wrote: On Monday, 28 August 2017 at 12:31:20 UTC, rikki cattermole wrote: On 28/08/2017 1:19 PM, Mike Parker wrote: Jean-Louis Leroy posted about his open methods library here in the forums some time ago. Now, he's written a blog post that explains what open methods are, and describes the D implementation and how it compares to his C++ library. The blog: https://dlang.org/blog/2017/08/28/open-methods-from-c-to-d/ Reddit: https://www.reddit.com/r/programming/comments/6wj0ev/open_methods_from_c_to_d/ Neat. Good to see articles in support of TypeInfo/ClassInfo! I do wish we extended it for full reflection capabilities though... Agreed. Andrei suggested using rtlInfo but AFAICT this requires building a custom druntime. It would be easy to support this method in addition to 'deallocator' and 'hash' but I suspect it would not be a very popular option. Maybe we could have a void*[] in TypeInfo and a global integer index that extensions could use to allocate entries? Instead of hacking new features in, we should work on a full redesign. Clearly its needed between TypeInfo not cross the dll boundary on Windows (yay no classes!), -betterC and of course full reflection that we can do significantly better in this department.
Re: Open Methods: From C++ to D
On 28/08/2017 1:19 PM, Mike Parker wrote: Jean-Louis Leroy posted about his open methods library here in the forums some time ago. Now, he's written a blog post that explains what open methods are, and describes the D implementation and how it compares to his C++ library. The blog: https://dlang.org/blog/2017/08/28/open-methods-from-c-to-d/ Reddit: https://www.reddit.com/r/programming/comments/6wj0ev/open_methods_from_c_to_d/ Neat. Good to see articles in support of TypeInfo/ClassInfo! I do wish we extended it for full reflection capabilities though...
Re: Quora
On 19/08/2017 4:02 PM, Ecstatic Coder wrote: That is 6 years old. It would not help anybody to comment. Have you noticed that when you "google" something related to programming, the first results are often pages which are several years old ? If I understand you well, you are telling me to let these pages unchanged. We shouldn't tell people about alternatives like D, because Java/C#/PHP/etc is better suited to get the job done anyway. Surprising, but interesting point of view, I admit... Its called necro-posting. I'm surprised that post isn't read-only.
Re: Quora
On 19/08/2017 3:54 PM, Ecstatic Coder wrote: Or more likely some community members who have the privileges to remove answers, think that hype and "proof" of usage is more important than actual technical reasons. I suggest that you try to talk about D here : https://softwareengineering.stackexchange.com/questions/35890/best-programming-language-for-web-development Good luck... That is 6 years old. It would not help anybody to comment.
Re: Quora
On 19/08/2017 3:38 PM, Ecstatic Coder wrote: On Saturday, 19 August 2017 at 11:33:13 UTC, Joakim wrote: On Saturday, 19 August 2017 at 11:00:25 UTC, Rico Decho wrote: Here is another one : https://www.quora.com/Which-language-is-best-for-a-beginner-programmer I don't think many people here go to Quora, I know I don't. You answers were decent though. You should go on Quora more often, because it is one of the rare places where we can freely suggest D if somebody asks "what is the best...". On Stackoverflow almost all my answers have been removed at once, because they found my D suggestions were "promotional content". But I see that they have left all the other answers based on C++/Go/Dart/Java/C#/PHP/etc. Completely stupid and unfair... Obviously they don't want people to have the best solution to their problem, but only the solutions that closely match Stackoverflow's marketing business... Or more likely some community members who have the privileges to remove answers, think that hype and "proof" of usage is more important than actual technical reasons.
Re: If structures places data to stack why we do not getting stackoverflow on array of structures?
On 16/08/2017 8:14 AM, Suliman wrote: On Wednesday, 16 August 2017 at 07:09:02 UTC, rikki cattermole wrote: On 16/08/2017 8:06 AM, Suliman wrote: If structures placing data on the stack why we do not getting stackoveflow while we creating array of structures? Or for example big structure. Am I right understand that structures placing data _only_ on stack? But the stack size is very limited (on Widnows it's just 1MB). So how it's work? Struct's by themselves go on the stack. If they are allocated via new/malloc its on the heap (and hence are pointers). Same situation with arrays or inside a class. But for example if I am getting array of structs and getting data to it, where it's locating? On the heap, unless you are allocating it via e.g. alloca.
Re: If structures places data to stack why we do not getting stackoverflow on array of structures?
On 16/08/2017 8:06 AM, Suliman wrote: If structures placing data on the stack why we do not getting stackoveflow while we creating array of structures? Or for example big structure. Am I right understand that structures placing data _only_ on stack? But the stack size is very limited (on Widnows it's just 1MB). So how it's work? Struct's by themselves go on the stack. If they are allocated via new/malloc its on the heap (and hence are pointers). Same situation with arrays or inside a class.
Re: Named multi-imports
On 15/08/2017 2:59 AM, Johnson wrote: Not only that, but it requires adding more files to the command line. I currently have 3 import files to separate the gtk from gdk that and the only reason they exist is to combine them in to one named import ;/ Doesn't seem like much but that's 3 extra files that don't really need to exist. Hopefully D already implements a way to do what I'm asking. Or instead of a new language feature, the gtk-d guys could have package files ;)
Re: D outperformed by C++, what am I doing wrong?
On 13/08/2017 7:09 AM, amfvcg wrote: Hi all, I'm solving below task: given container T and value R return sum of R-ranges over T. An example: input : T=[1,1,1] R=2 output : [2, 1] input : T=[1,2,3] R=1 output : [1,2,3] (see dlang unittests for more examples) Below c++ code compiled with g++-5.4.0 -O2 -std=c++14 runs on my machine in 656 836 us. Below D code compiled with dmd v2.067.1 -O runs on my machine in ~ 14.5 sec. Each language has it's own "way of programming", and as I'm a beginner in D - probably I'm running through bushes instead of highway. Therefore I'd like to ask you, experienced dlang devs, to shed some light on "how to do it dlang-way". C++ code: #include #include #include #include #include #include #include #include #include #include template std::vector sum_elements(const T& beg, const T& end, std::size_t k, K def) { if (k == 0) { return std::vector{}; } return sum_elements(beg, end, k, def, [](auto , auto ){ return r+l;}); } template std::vector sum_elements( const T& beg, const T& end, std::size_t k, K def, BinaryOp op) { std::vector out; out.reserve((std::distance(beg, end) - 1)/k + 1); for (auto it = beg; it!=end; std::advance(it, std::min(static_cast(std::distance(it, end)), k))) { out.push_back(std::accumulate(it, std::next(it, std::min(static_cast(std::distance(it, end)), k)), def, op)); } return out; } int main() { std::vector vec; auto size = 100; vec.reserve(size); for (int i=0; i < size; ++i) vec.push_back(i); auto beg = std::chrono::system_clock::now(); auto sum = 0; for (int i=0; i < 100; i++) sum += sum_elements(vec.begin(), vec.end(), 2, 0).size(); auto end = std::chrono::system_clock::now(); std::cout << std::chrono::duration_cast(end-beg).count() << std::endl; std::cout << sum << std::endl; return sum; } D code: import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime, Duration; T[] sum_subranges(T)(T[] input, uint range) { T[] result; if (range == 0) { return result; } for (uint i; i < input.length; i=min(i+range, input.length)) { result ~= sum(input[i..min(i+range, input.length)]); } return result; } unittest { assert(sum_subranges([1,1,1], 2) == [2, 1]); assert(sum_subranges([1,1,1,2,3,3], 2) == [2, 3, 6]); assert(sum_subranges([], 2) == []); assert(sum_subranges([1], 2) == [1]); assert(sum_subranges([1], 0) == []); } int main() { int[100] v; for (int i=0; i < 100; ++i) v[i] = i; int sum; MonoTime beg = MonoTime.currTime; for (int i=0; i < 100; i++) sum += cast(int)sum_subranges(v,2).length; MonoTime end = MonoTime.currTime; writeln(end-beg); writeln(sum); return sum; } Dmd compiles quickly, but doesn't create all that optimized code. Try ldc or gdc and get back to us about it ;)
Re: Bug in -J
On 12/08/2017 3:34 AM, Mr. Pib wrote: I have -J added to the command line like -JC:\Temp I then use import(r"C:\Temp\a.dat"); and I get an error about the file not existing in the main.d: Error: file "C:\\Temp\\a.dat" cannot be found or not in a path specified with -J It seems dmd does internally compare the paths to see if they are identical. Of course, removing the C:\Temp\ part of import works fine. The problem with that approach is it then is not consistent with other code. I need to specify the full path because sometimes it is used. essentially version(X) import(path) else load(path); while I could do something like import(baseName(path)) it seems kinda clunky, in any case. It's pretty obvious that one excepts the same behavior so it could create bugs in code that except the behavior to work correctly. Most likely related or is the issue[0]. [0] https://issues.dlang.org/show_bug.cgi?id=3420
Re: Jetbrains announce support for rust plugin, show them we want one too!
On 11/08/2017 12:46 PM, HyperParrow wrote: On Friday, 11 August 2017 at 08:13:07 UTC, SC wrote: [...] having great tooling might increase popularity, but for me it'll improve my productivity, and that's all i care about, popularity is next, quality is already nice for me The language itself should improve your productivity: meta programming, embedded unittests, static assertions. Good tooling won't subtract from a good language, it will only improve upon it. Its the icing on the already delicious cake.
Re: DLL loading behaviors and pragma(lib)
On 11/08/2017 12:18 AM, David Zhang wrote: I've been working on getting OpenGL to load on windows without a library, and encountered something curious; Context creation fails when I try to use the function pointer retrieved through GetProcAddress, but works just fine with the statically linked version provided through core.sys.windows.wingdi.d. This may be a stupid question, but why is this? Thanks. Odd. Just to confirm your wglGetProcAddress, is extern(Windows/System)? And it is non-null after being loaded?
Re: sharedLog between dll
On 01/08/2017 11:27 AM, Domain wrote: On Tuesday, 1 August 2017 at 09:06:39 UTC, rikki cattermole wrote: On 01/08/2017 9:28 AM, Domain wrote: I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll You said the magic phrase, DLL. Can't share e.g. classes between dll/host[0]. [0] https://issues.dlang.org/show_bug.cgi?id=4071 That issue is reported 7 years ago! I think DLL support should be a basic feature. And I think the core team spend too little time on those features which will block the usage of D in the real world. I have to reconsider using C++ instead. Please email Walter about this. It works everywhere else.
Re: sharedLog between dll
On 01/08/2017 9:28 AM, Domain wrote: I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll You said the magic phrase, DLL. Can't share e.g. classes between dll/host[0]. [0] https://issues.dlang.org/show_bug.cgi?id=4071
Re: The progress of D since 2013
On 31/07/2017 8:22 AM, Maxim Fomin wrote: Hi! Good to see D is progressing! I was active forum and bugzilla participant in 2011-2013. Since then I have not touched D. What is the progress of D (2014-2017) in following dimensions: 1) Support of linking in win64? AFAIK Walter introduced win64 support in circa 2012 which was the big progress. However, support for win64 linking was limited because dmd defaulted on old dmc linker, and Walter didn't plan to do anything with this. Optlink is still the default. MSVC link can be used for both 32bit and 64bit. 2) What is the support of other platforms? AFAIK there was progress on Android. From my memory recollections, the full support of Android was expected at that time. 3) What is the state of GC? AFAIK there were some improvements for GC sent as GSOC projects but they were not added in 2013. I see in the changelog that there are some improvements in speed and configuration support was added. 4) What is the state of GDC/LDC? GDC team was actively working on including gdc in gcc project. Do gdc and ldc still pull D frontend, so there is essentially 1 frontend (where gdc and ldc frontends lag several versions behind) + 3 backends? I see in the changelog some dmd backend improvements. How the dmd backend is compared with C++/GDC/LDC? AFAIK in 2013 there was a tradeoff: either you use dmd with brand-new frontend or gdc/ldc where performance is comparable to gcc, but frontend lags behind. Is it still true? 5) What is the progress with CTFE? I see a lot of discussions in forum archive devoted to the development of CTFE. What is the summary of CTFE development in recent years? New implementation by Stefan for the purposes of making it faster and cheaper. 6) I don't see any significant changes in D core from dlang documentation (except those mentioned in changelog for 2014-2017). Is is true or is the official spec as usual delayed :)? Is dlang spec fully and frequently updated or is it sparse as in the past? Is TDPL book still relevant? 7) Is UDA still compile-time? Are there plans to make it also runtime? No runtime reflection has been added during this period (unfortunately). 8) What is the progress with shared and immutable? AFAIK the compiler support for shared was not complete and Phobos library itself was not 'immutable-' and 'shared-correct'. 9) Does D gains popularity? Considerably. Downloads for dmd per day. http://erdani.com/d/downloads.daily.png 10) Anything else 2013 D user must know? :) I don't ask about Phobos because according to the changelog the progress is enormous, incremential and targets several directions - I doubt it can be easily summarised... Thanks!
Re: GC
On 30/07/2017 10:12 AM, piotrekg2 wrote: I would like to learn more about GC in D. For example can anyone explain why do we need memset(0) here: https://github.com/dlang/phobos/blob/master/std/container/array.d#L356 , doesn't it assume a certain type of GC? What if there is a need to change the GC algorithm in the future? It would be great if you could point me out to articles on this subject. Basically instead of having possibly random data in the array, it forces it to be all 0. What its protecting against is false pointers and stopping the GC seeing a reference to a block of memory that doesn't exist. It's just general protection against GC's thinking that memory is alive when it isn't. More of a problem for 32bit than 64bit. Hasn't got much to do with the algorithm :)