Re: Passing $ as a function argument
On Wednesday, 10 October 2018 at 23:04:46 UTC, James Japherson wrote: The whole point is not to use $ as an identifier but to specify to the compiler of that it can rewrite it. It's called 'alias'. // compile time int foo(alias index)(int[] a) { return a[index(a.length)]; } // run time int barr(int[] a, size_t function(size_t) index) { return a[index(a.length)]; } int main() { import std.range: iota; import std.array: array; import std.stdio: writeln; int[100] a = iota(0,100).array; a.foo!(l => l-3).writeln; a.barr(l => l-3).writeln; return 0; }
Re: Sutter's ISO C++ Trip Report - The best compliment is when someone else steals your ideas....
On Wednesday, 11 July 2018 at 13:19:01 UTC, Joakim wrote: ... Sounds like you're describing the "Let it crash" philosophy of Erlang: https://ferd.ca/the-zen-of-erlang.html I never program Erlang, but I think yes, something like this. The people who developed Erlang definitely have a lot of experience developing services. The crucial point is whether you can depend on the error being isolated, as in Erlang's lightweight processes. I guess D assumes it isn't. I think if we have a task with safe code only, and communication with message passing, it's isolated good enough to make error kill this task only. In any case, I still can drop the whole application myself if I think it will be the more safe way to deal with errors. So paranoids do not lose anything in the case of this approach.
Re: Sutter's ISO C++ Trip Report - The best compliment is when someone else steals your ideas....
On Wednesday, 11 July 2018 at 18:27:33 UTC, Brad Roberts wrote: ... application exiting asserts in production. Yes, you kill the app. You exit as fast and often as the errors occur. You know what happens? You find the bugs faster, you fix them even faster, and the result is solid software. You mean that the serious consequences of errors better motivate programmers? Then I have an idea. If you connect the current to the chairs of the developers, and with each failed assert the programmer responsible for this part will receive an electrical discharge, the code will surely become even more reliable. But I want the error found in the production not to lead to a drop in the service, affecting all the users who are currently on the site, and this is a slightly different aspect. When you're afraid of your software and afraid to make changes to it, you make bad choices. Embrace every strategy you can find to help you find problems as quickly as possible. Sorry, but I'm not sure I understand how this relates to the topic. Still, I do not think that a failed assert message in the log allows you to find an error faster than a similar message, but about an exception.
Re: Sutter's ISO C++ Trip Report - The best compliment is when someone else steals your ideas....
On Tuesday, 10 July 2018 at 22:59:08 UTC, Jonathan M Davis wrote: Or aside from that strawman that RangeError shouldn't be an Error even... I suspect that we're going to have to agree to disagree on that one. ... ... continuing to execute the program is risky by definition. ... This error handling policy makes D not applicable for creating WEB applications and generally long-running services. I think anyone who has worked in the enterprise sector will confirm that any complex WEB service contains some number of errors that were not detected during the tests. These errors are detected randomly during operation. And the greatest probability of their detection - during the peak traffic of the site. Do you kill the whole application even in the case of undisturbed memory, with one suspicion of a logical error? At the peak of attendance? To prevent a potential catastrophe, which could theoretically arise as a result of this error? Congratulations! The catastrophe is already here. And in the case of services, the strategy for responding to errors must be exactly the opposite. The error should be maximally localized, and the programmer should be able to respond to any type of errors. The very nature of the work of WEB applications contributes to this. As a rule, queries are handled by short-lived tasks that work with thread-local memory, and killing only the task that caused the error, with the transfer of the exception to the calling task, would radically improve the situation. And yes, RangeError shouldn't be an Error.
Re: what's the correct way to handle unicode? - trying to print out graphemes here.
On Tuesday, 3 July 2018 at 14:39:34 UTC, ag0aep6g wrote: Looks like forum.dlang.org has a problem when they appear side by-side. Works (in the preview): ️ Doesn't work: ️ For me, it looks as the used font has ligatures for these faces. Mozilla under Linux, I guess it's 'EmojiOne Mozilla' font.
Re: High memory usage in vibe.d application
On Sunday, 1 July 2018 at 13:44:23 UTC, Anton Fediushin wrote: I reduced the test case to _one_ line: ``` 1.seconds.setTimer(() => "http://google.com".requestHTTP((scope req) {}, (scope res) {res.disconnect;}), true); ``` What happens is `res.disconnect` doesn't free all of the internal buffers, causing leakage. One way to avoid that is to call `res.dropBody`, but it isn't always wanted (just like in my example). The problem is known and mentioned in the documentation: http://vibed.org/api/vibe.http.client/requestHTTP Note that it is highly recommended to use one of the overloads that take a responder callback, as they can avoid some memory allocations and are safe against accidentally leaving stale response objects (objects whose response body wasn't fully read). For the returning overloads of the function it is recommended to put a scope(exit) right after the call in which HTTPClientResponse.dropBody is called to avoid this. As I understand the situation, request object will reside in memory until you fully read or do something with response body.
Re: Compilation is taking a ton of memory
On Thursday, 28 June 2018 at 16:24:07 UTC, H. S. Teoh wrote: On Thu, Jun 28, 2018 at 04:11:57PM +, crimaniak via Digitalmars-d wrote: [...] The problem is aggravated by the fact that DUB compiles all the sources in one DMD launch. Doesn't dub have an option to compile packages (i.e. subdirs) separately? Or does that only apply to dub packages, not to subdirs within a single project? Yes, it's about dub packages, not about subdirs. And yes, it's possible to split project to subpackages, it gives its benefits and structure code, but I hate the idea of doing this forcibly, just to fix compilation time. In addition, a typical large site is a large number of pages with diet templates, and even if you separate the pages from business logic, but this part itself is still very large and slow in compilation. I had to refuse diet rendering on the server and go to Vue+pug, which allowed to accelerate the development cycle when changes on the frontend from 2 minutes to instantly. [...] This is one of the reasons I was not impressed by dub (sorry, Sonke). I continue to use SCons for my D projects... I believe that this situation is bad for D as a whole. The problem with large projects can be solved by splitting into subpackages, or with Scons, or with reggae, or manually writing the makefile, etc., etc., but the person who just started writing on D does not know all this. He simply does the project and with his growth discovers this problem. I think the modern programmer has the right to expect that the official build system will work well enough with a project of several thousand files.
Re: Compilation is taking a ton of memory
On Wednesday, 27 June 2018 at 16:00:37 UTC, Mario Silva wrote: Hello, Our code base has been growing steadily and it's currently at a point where my 16GB machine just freezes when we're compiling our code. This happens because DMD just consumes all my memory for a while. Also, it's taking a long time to compile it. Less than an year ago our project was taking around 17 seconds to compile - no libs requiring compilation - and maybe around 50 seconds for full compilation, and it now takes around 50 seconds for an incremental compilations and around 1.5 minutes for a full one. The same problem. Freeze because of active swap usage and about 2 minutes to compile after every small change. In fact, when it comes to template code, DMD is neither particularly fast nor memory-efficient. Given that there are no things such as precompiled headers, on a large project, the D experience is much worse than C++. The problem is aggravated by the fact that DUB compiles all the sources in one DMD launch. I tried to solve this problem some time ago, and Sönke advised using reggae (https://code.dlang.org/packages/reggae). I'm still experimenting with different approaches and even wrote my own utility helper (https://code.dlang.org/packages/ifupdated). But at the moment I can state the following: * It is necessary to incorporate into the DUB reggae (== classic make) approach to compile sources. * Like the 'debug' and 'release' modes of the compiler, the build system should also have two modes, for example, 'deploy' and 'development', the first minimizes the time it takes for a full compilation, and the second minimizes the recompilation time after minor changes. * It needs to think seriously about 'compiler as a service' approach and caching intermediate compilation results. Any tips on how to code in a way that minimizes both compilation times and memory consumption when compiling? For the current moment just try reggae. You can find some forgotten imports because of separate compilation, but it is easily fixable.
Re: Parenthesis around if/for/while condition is not necessary
On Saturday, 23 June 2018 at 09:19:45 UTC, user1234 wrote: ...Forcing Curly braces is nice, logic and natural imo. The operator brackets themselves are a separate construction. In addition, the more structured the code, the less they are needed. In my code, most of the loops and branches contain one operator, so forcing the сurly braces would simply add a large amount of syntactic noise.
Re: Can't start application on heroku
On Saturday, 16 June 2018 at 09:00:21 UTC, Jacob Shtokolov wrote: On Saturday, 16 June 2018 at 01:24:04 UTC, crimaniak wrote: Hi all! The first try to host application on Heroku provider. The application is started and starts to listen in 3 seconds on the port, provided by heroku-buildpack-d. But the server doesn't detect listening and stops the application. On the local machine, the application works as expected. What can be the problem here? [...] Probably you could try to change your listening address from 127.0.0.1 to 0.0.0.0 Thanks! It is. Initially, I did not pay attention to the default interface address, because I expected the 'bind-address' parameter according to the documentation.
Can't start application on heroku
Hi all! The first try to host application on Heroku provider. The application is started and starts to listen in 3 seconds on the port, provided by heroku-buildpack-d. But the server doesn't detect listening and stops the application. On the local machine, the application works as expected. What can be the problem here? ... 2018-06-16T00:34:33.00+00:00 app[api]: Build succeeded 2018-06-16T00:34:35.078239+00:00 heroku[web.1]: Starting process with command `./virtual-cm --port 9254` ... 2018-06-16T00:34:38.199381+00:00 app[web.1]: [main() INF] Listening for requests on http://127.0.0.1:9254/ 2018-06-16T00:35:35.416464+00:00 heroku[web.1]: Stopping process with SIGKILL 2018-06-16T00:35:35.416377+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2018-06-16T00:35:35.537505+00:00 heroku[web.1]: State changed from starting to crashed ...
Re: How to task pool in vibe.d?
On Saturday, 9 June 2018 at 15:11:02 UTC, Computermatronic wrote: I'd like to create a bunch of tasks in vibe.d, then wait for them all to complete. Using std.concurrency and std.parallelism this is trivial. I could just spawn a bunch of vibe.d tasks and then iteratively join them, but I would think vibe.d would provide some primitives for task-pooling. Yes. https://vibed.org/api/vibe.core.taskpool/TaskPool
Re: GDC on Travis-CI
On Saturday, 2 June 2018 at 19:48:36 UTC, Matthias Klumpp wrote: @crimaniak: If you really want to build with all compilers, there is a workaround for this issue that does not involve you supporting ancient D versions, and that is to actually use Debian's GDC on Travis. I use this excessively for my own projects, mostly though because I need newer system libraries and because I explicitly want to build with the packaged compilers as well. You can use a similar approach and limit it to GDC only, I created a PR for that: https://github.com/crimaniak/json-patch/pull/1 As you can see on https://travis-ci.org/crimaniak/json-patch/jobs/387197216 , your code builds fine with the latest GDC. Wow! It works! Thanks! So, if you want that workaround, please take it, if not it may serve as a reference for others facing the same problem. Yes, pull request is approved. This is exactly what I was hoping to find. I also recommend this to others who have this problem. It takes some time to install required packages so build was much longer than dmd and lcd builds but I think it's not a problem for most cases. Thanks to everyone who answered!
GDC on Travis-CI
I started to work with Travis-CI, building packages using all three main compilers, and noticed that I have problems with gdc every time and need to tweak code because of many things missing. For example: https://travis-ci.org/crimaniak/json-patch/jobs/386963340 Why this situation with gdc and how best to deal with it?
Re: Any way to override base type with dervived in derived type
On Thursday, 24 May 2018 at 20:24:32 UTC, IntegratedDimensions wrote: I'm pretty much guaranteed that in C, t will be type TT due to the design(C goes with TT like bread with butter). ... 1) Your architecture is wrong, I recommend to rethink it. 2) You still can deal with it using template mixins https://dlang.org/spec/template-mixin.html
Re: A pattern I'd like to see more of - Parsing template parameter tuples
On Monday, 21 May 2018 at 07:10:34 UTC, rikki cattermole wrote: alias DocumentType = SomeDocument!( ObjectVersion._1_0, ObjectEncoding.PlainASCII ); alias DocumentType2 = SomeDocument!( ObjectEncoding.UTF8, ObjectVersion._2_0 ); typedef basic_stringstring; typedef basic_string wstring; So, as I understand, basic idea can be reduced to "Let's use traits for options!", isn't it?
Re: Reactive data
On Saturday, 31 March 2018 at 16:08:36 UTC, lempiji wrote: --- import rx; auto firstWord = new BehaviorSubject!string("Change"); auto secondWord = new BehaviorSubject!string("me!"); auto bothWords = new BehaviorSubject!string(""); combineLatest!((a, b) => a ~ " " ~ b)(firstWord, secondWord).doSubscribe(bothWords); writeln(bothWords.value); // Change me! firstWord.value = "TEST"; writeln(bothWords.value); // TEST me! --- Thanks! I will play with it.
Re: D mentioned in Infoworld
On Monday, 26 March 2018 at 15:52:11 UTC, Jean-Louis Leroy wrote: https://www.infoworld.com/article/3263395/application-development/the-programming-languages-you-should-learn-now.html Looks like R advertising.
Reactive data
I want to have reactive variables like in this example: ``` USING_REACTIVE_DOMAIN(D) // The two words VarSignalT firstWord = MakeVar(string( "Change" )); VarSignalT secondWord = MakeVar(string( "me!" )); // ... SignalT bothWords = firstWord + string( " " ) + secondWord; ``` from this page: http://schlangster.github.io/cpp.react/tutorials/BasicSignals.html Is this possible to make it in D with https://github.com/lempiji/rx ? Is there other libraries exists for this topic?
Re: Forwarding arguments through a std.algorithm.map
On Saturday, 10 March 2018 at 20:48:06 UTC, Nordlöw wrote: If I have a function bool f(Rs...)(Rs rs) is it somehow possible to map and forward all its arguments `rs` to another function bool g(Rs...)(Rs rs); docs: https://dlang.org/phobos/std_traits.html#.Parameters usage example: https://github.com/crimaniak/d-vision/blob/master/src/vision/eventbus.d#L173
Re: What's the proper way to add a local file dependence to dub?
On Sunday, 4 March 2018 at 16:46:56 UTC, Marc wrote: then copy it to sources folder? ... Also, symlinks are power tool for organizing your files without copying.
Re: need help with vibe.d receive()
On Tuesday, 16 January 2018 at 08:54:58 UTC, Sönke Ludwig wrote: ... The problem is with the `immutable struct StopEvent {}` Thanks! ... So, removing the `immutable` from the declaration solved the issue for me, but if possible I'd rather remove the `cast(shared Unqual!EventType)` from `emit`, and pass `shared`/`immutable` events to it from the outside (or plain events with no unshared indirections). No, I can't remove casting here, because some other services can't work with immutable or shared, so I just fix StopEvent type.
need help with vibe.d receive()
Hi! I make multi-task event bus, but there is a problem with the task stops. Please see end of file https://github.com/crimaniak/d-vision/blob/master/src/vision/eventbus.d Expected behavior: After sending the StopEvent message in line 244 it is must be detected in listeners (line 147), so all listeners must set exit flag to 'true' and quit immediately. De-facto behavior: StopEvent() message is not detected by the first delegate in line 147 (logger task logs this message by the handler in line 185), so subscribed tasks never exit and test stops on line 248. I tried to play with yield() and sleep(), with 'shared' attributes and so on, but without result. Can you say please what I am doing wrong here? 'dub test' can be used to play with tests.
Re: vibe.d Error only with Firefox
On Friday, 5 January 2018 at 16:30:07 UTC, Martin Tschierschke wrote: ... Failed to listen on 127.0.0.1:8030 Failed to listen on 10.0.0.1:8030 ... The strange thing is now, that when using Chromium http://10.0.0.1:8030 works! But with Firefox http://10.0.0.1:8030 gives the long Error: 400 - Bad Request I would first figure out what happens to the port 8030. Run this command before and after starting the application to see who is really listening: sudo netstat -nlp | grep 8030
Re: why ushort alias casted to int?
On Friday, 22 December 2017 at 10:18:52 UTC, ketmar wrote: crimaniak wrote: Both operands are the same type, so as I understand casting to longest type is not needed at all, and longest type here is ushort in any case. What am I doing wrong? it is hidden in specs: all types shorter than int are promoted to int before doing any math. Hm, really. ok, I will use the explicit cast, but I don't like it.
why ushort alias casted to int?
My code: alias MemSize = ushort; struct MemRegion { MemSize start; MemSize length; @property MemSize end() const { return start+length; } } Error: cannot implicitly convert expression `cast(int)this.start + cast(int)this.length` of type `int` to `ushort` Both operands are the same type, so as I understand casting to longest type is not needed at all, and longest type here is ushort in any case. What am I doing wrong?
Re: dip1000 info web address
On Friday, 22 December 2017 at 04:15:14 UTC, Mike Franklin wrote: https://github.com/dlang/dmd/pull/7489 It was fast :)
dip1000 info web address
Hi all! There is a string in DMD help message: -dip1000 implement http://wiki.dlang.org/DIP1000 (experimental) But in fact page http://wiki.dlang.org/DIP1000 is empty, and DIP100 information resides at the address https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md Wrote it here because not sure if this is site problem (need to create DIP100 page in Wiki) or DMD problem (need to fix address)
Re: Answers needed from those using D for Web Development, Web APIs and Services
On Thursday, 21 December 2017 at 19:58:44 UTC, WebFreak001 wrote: yes, I can see each response and export them to csv. I wanted I think if you can make csv with only answers related to WEB development it will be data relevant to what aberba wants. to make a summary of the results but I don't really know where to start As for me, the main summary of results already is on the /viewanalytics page: D User Survey 167 answers D even much more marginal than I expected. -- Узок их круг, страшно далеки они от народа
Re: Answers needed from those using D for Web Development, Web APIs and Services
On Friday, 15 December 2017 at 08:13:25 UTC, aberba wrote: I'm going to do a writeup on the state of D in Web Development, APIs and Services for 2017. I need the perspective of the community too along with my personal experience. Please help out. More details the better. I think some questions already answered in this survey https://forum.dlang.org/thread/hrtakvaqrhvayeidq...@forum.dlang.org I wonder, it is possible to filter Google Forms result to see only results with relevant items in 'primary and secondary area of development' questions?
Re: git workflow for D
On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: How does one keep their fork up to date? For example, if I fork https://help.github.com/articles/syncing-a-fork/
Re: Basic questions about D lang?
On Wednesday, 29 November 2017 at 11:32:51 UTC, Jayam wrote: In D lang, 1. Is there any feature async/ await like "c#" ? I can't find feature like async. As for me, async/await feature is a half-baked solution. With vibe-d you can write asynchronous code without thinking about it at all. Details: http://vibed.org/features 2. Is Garbage Collector work default without any code to force like in c# or do we need to manually trigger it ? It starts automatically when you try to allocate memory and there is no space in heap. In fact, it leads to architecture restriction: destructors must be @nogc. Also, you can run it with GC.collect() 3. Can we make library file and use that in any project like 'Util class' ? Yes.
Problems with ctRegex
First problem: it doesn't understand enums, it seems to be a bug: ``` enum TopicMask : string { divider = "/", oneLevelMask = "+", multiLevelMask = "#", system = "$", level = "[^"~divider~oneLevelMask~multiLevelMask~"]*", publishMask = "^("~divider~"|"~level~")+$" } bool topicIsValid(string topic) pure { import std.regex; auto mask = ctRegex!(TopicMask.publishMask); return !topic.matchFirst(mask).empty; } ``` result: /usr/include/dmd/phobos/std/regex/package.d(376,20): Error: template std.array.Appender!(TopicMask).Appender.put cannot deduce function from argument types !()(TopicMask), candidates are: /usr/include/dmd/phobos/std/array.d(2983,10): std.array.Appender!(TopicMask).Appender.put(U)(U item) if (canPutItem!U) /usr/include/dmd/phobos/std/array.d(3011,10): std.array.Appender!(TopicMask).Appender.put(Range)(Range items) if (canPutConstRange!Range) /usr/include/dmd/phobos/std/array.d(3020,10): std.array.Appender!(TopicMask).Appender.put(Range)(Range items) if (canPutRange!Range) /usr/include/dmd/phobos/std/regex/package.d(387,15): Error: cannot implicitly convert expression `app.data()` of type `string` to `TopicMask` /usr/include/dmd/phobos/std/regex/package.d(422,19): Error: template instance std.regex.internal.parser.Parser!(TopicMask, CodeGen) does not match template declaration Parser(R, Generator) if (isForwardRange!R && is(ElementType!R : dchar)) /usr/include/dmd/phobos/std/regex/package.d(393,25): Error: template instance std.regex.regexImpl!(TopicMask) error instantiating /usr/include/dmd/phobos/std/regex/package.d(401,17): instantiated from here: regex!(TopicMask) /usr/include/dmd/phobos/std/regex/package.d(431,19): instantiated from here: regex!(TopicMask) /usr/include/dmd/phobos/std/regex/package.d(453,54): instantiated from here: ctRegexImpl!("^(/|[^/+#]*)+$", []) source/mqttd/topic.d(48,14):instantiated from here: ctRegex!("^(/|[^/+#]*)+$", []) If I change ctRegex!(TopicMask.publishMask) to ctRegex!("^(/|[^/+#]*)+$") I run into next error: source/mqttd/topic.d(48,26): Error: pure function 'mqttd.topic.topicIsValid' cannot call impure function 'std.regex.matchFirst!(string, StaticRegex!char).matchFirst' source/mqttd/topic.d(48,26): Error: pure function 'mqttd.topic.topicIsValid' cannot call impure destructor 'std.regex.Captures!(string, ulong).Captures.~this' Is there any change to use regex inside or pure function? I just need some pure bool test() method to test string against the mask.
Re: Is variable void?
On Saturday, 25 November 2017 at 15:34:21 UTC, John Chapman wrote: Is there any way of determining whether a variable has been initialized or not? For example, if something is declared like this: int x = void; can I check if it's void before I use it, say, in a function it's been passed to? You can use Nullable!int
deep copy thread local to shared or how to send() struct with indirections
Hi! I need to send Publish struct from https://github.com/tchaloupka/vibe-mqtt to another vibe.d task. And there is the problem. First of all, I can't make it immutable because send() wants to mutate it. I can't send local copy because of "Aliases to mutable thread-local data not allowed.". And I can't convert it to shared because of "cannot implicitly convert expression `packet` of type `Publish` to `shared(FixedHeader)`". I don't understand error message about FixedHeader. Why it tries to convert struct to its field? As I understand the real problem here is `ubyte[] payload` dynamic array field in Publish which is allocated separately, so to make a shared copy of Publish it need the deep copy of this struct. How to do it right? I don't want to copy all fields manually, is there a standard way to accomplish it? ``` struct MqttOnPublish { Publish packet; } override void onPublish(Publish packet) { super.onPublish(packet); // source/vcm/mqtt/bridge.d(69,41): Error: cannot implicitly convert expression `packet` of type `Publish` to `shared(FixedHeader)` shared Publish sp = shared Publish(packet); /* /usr/include/dmd/phobos/std/concurrency.d(575,5): Error: static assert "Aliases to mutable thread-local data not allowed." ../../.dub/packages/vibe-d-0.8.1/vibe-d/core/vibe/core/concurrency.d(1243,64): instantiated from here: send!(MqttOnPublish) source/vision/eventbus.d(72,27):instantiated from here: send!(MqttOnPublish) source/vision/eventbus.d(42,13):instantiated from here: emit!(MqttOnPublish) source/vcm/mqtt/bridge.d(70,14):instantiated from here: emit!(MqttOnPublish) */ bus.emit(MqttOnPublish(packet)); } ```
Re: String import an entire directory
On Saturday, 11 November 2017 at 14:11:50 UTC, Neia Neutuladh wrote: I can make a prebuild script to generate code for this, but I'm wondering: do other people find themselves needing this periodically? If so, I can write a DIP for it, or at least publish a codegen tool that other people can use. Yes, sometimes it's good to have more extended imports and compile-time possibilities to avoid tweaking dub build process, but I think, for current time language has a lot of more actual issues so it's better to leave this task for external tools.
Re: Synchronize Class fields between different threads
On Friday, 10 November 2017 at 14:36:03 UTC, DrCataclysm wrote: It is working now. The problem was that the debugger in eclipse ddt seems to completely broken. If i run it directly from bash it is working. Be careful with such statements. Typically, this situation means that there are Heisenbugs in the code that appear in certain conditions.
Re: How to use containers in lock based concurrency
On Friday, 3 November 2017 at 12:42:29 UTC, ANtlord wrote: Hello! I can't get how to use double linked list in concurrency. Please help. ... I get a compile error onlineapp.d(8): Error: template std.container.dlist.DList!string.DList.insertFront cannot deduce function from argument types !()(string) shared, One Does Not Simply get the non-shared object and use in the shared code. (/Boromir mode) For me, it was useful to read this: http://www.informit.com/articles/article.aspx?p=1609144=11
Re: Release D 2.077.0
On Friday, 3 November 2017 at 14:41:06 UTC, Gerald wrote: On Thursday, 2 November 2017 at 22:35:03 UTC, Martin Nowak wrote: Glad to announce D 2.077.0. ... The new version is much better with only a 6 MB difference between the stripped and non-stripped versions. My vibe-d application debug build reduced from 56Mb to 44Mb (release = 19Mb).
Re: Project Elvis
On Monday, 30 October 2017 at 15:04:32 UTC, Steven Schveighoffer wrote: https://issues.dlang.org/show_bug.cgi?id=13489 ... I'm in the camp that nan should be evaluated as false. I don't think I like the idea that !nan is also false, because this makes !!nan true! The problem of converting NaN to binary is that NaN introduces a ternary logic. There is no way to convert the ternary value to binary without loss. If we want to be consistent we have to convert it to Nullable!bool, but not to bool. So, to introduce Elvis operator for floats in language and to stay consistent it needs also Nullable/Not-Nullable as part of language type system, IMHO.
Re: Why Physicists Still Use Fortran
On Sunday, 15 October 2017 at 22:09:21 UTC, Walter Bright wrote: http://moreisdifferent.com/2015/07/16/why-physicsts-still-use-fortran/ Some good information there! Especially comments: George Michaelson • a day ago One of the saddest moments of my career in computer centre helpdesk was talking to a chemical engineering student whose PhD basically evaporated in smoke, as I showed them the 'interesting' experimental results of their model were the outcome of using un-initialized global common in a huge fortran program they'd written.
Re: Tango + D2 + Mac
On Tuesday, 17 October 2017 at 04:01:54 UTC, Fat_Umpalumpa wrote: Do you by any chance know anything that replaced std.xml? Everything I look up on it suggests not to use it. Is this really a problem? In this case, I can help: I recommend to use it. And only if you really will have performance problems, try something else. https://code.dlang.org/search?q=xml
Re: Templates, D way
On Tuesday, 5 September 2017 at 22:51:45 UTC, Void-995 wrote: The whole thing is that I don't know either padding nor elements count. Those values are read from file. ... Sorry, I was not attentive enough. Yes, you can't use unions in this case.
Re: Templates, D way
On Tuesday, 5 September 2017 at 14:55:21 UTC, Void-995 wrote: Using unions? Count and Offset are different depending on input data, so the address where they are is varying depending on which file I've loaded. Or I didn't get what you meant. Yes, so you need separate union type for every type of input data. But these values are known in compile time, so you can do mixin, creating the union for each type like this: union MyBinaryStructA { ubyte[...] asBytes; struct asStruct { align(1): ubyte[...] dummy1; // padding before firstList MyBinarySubStructAForA[...] firstList; ubyte[...] dummy2; // padding between lists MyBinarySubStructBForA[...] secondList; ... } } unittest { MyBinaryStructA a; a.asBytes = someBinarySourceForA; // fill from unstructured source auto item = a.asStruct.firstList[1]; // access to structure element }
Re: Templates, D way
On Tuesday, 5 September 2017 at 14:43:19 UTC, John Colvin wrote: On Tuesday, 5 September 2017 at 12:41:45 UTC, Computermatronic wrote: On Tuesday, 5 September 2017 at 12:20:14 UTC, crimaniak wrote: [...] I find it very strange that this works, as a non-mixin template should not be able to capture the context of where it was instantiated. If you take the alias template parameters out it behaves how it should (that is an error message saying this is not accessible). https://issues.dlang.org/show_bug.cgi?id=17809 What kind of harm can this be? Can this be considered a feature?
Re: vibed services stop response after several days of work
On Tuesday, 5 September 2017 at 13:51:40 UTC, Sönke Ludwig wrote: The error is most likely caused by issuing two requests to the MySQL server from two different tasks on the same connection. Usually, mysql-native uses a connection pool to avoid this, but that could have been circumvented by accident. In this case, you have `Data is pending on the connection. Any existing ResultRange must be consumed or purged before performing any other communication with the server.` usually.
Re: Templates, D way
On Tuesday, 5 September 2017 at 12:54:20 UTC, Void-995 wrote: Thanks, that definitely working and doesn't require mixin with strings. But while waiting for response I've tried another thing, and I doubt I would able do to that without string now: ... int %sCount; int %sOffset; Yes, you can make such custom names only with string mixin, as I know. Computermatronic gives a good example how to do it simple way. I can give two additional advises: as I understand offsets as sizes are fixed so think about using unions to access sub structures instead of these auto-generated methods; I have a long history of using tricks like this starting from CHAIN MERGE usage in GW-BASIC to add some functions and for now such things are definitely code smell for me. There is always a way to do the same, but better.
Re: Templates, D way
On Tuesday, 5 September 2017 at 12:41:45 UTC, Computermatronic wrote: I find it very strange that this works, ... I'm too. :) In any case, it's not a big deal. It's possible to modify this template to transfer `this` as the first parameter and modify its usage accordingly.
Re: Templates, D way
On Tuesday, 5 September 2017 at 11:08:57 UTC, Void-995 wrote: @property mixin(DataList!("firstSublist", MyBinarySubStructAForA, firstSublistMembersCount, firstSublistMembersOffset)); I don't think string mixins are required here. It seems just template is more simple. T[] getBytesAs(T, alias length, alias offset)() { return (cast(T *)(cast(byte *)() + offset))[0 .. length]; } struct MyBinaryStructA { ... alias firstList = getBytesAs!(MyBinarySubStructAForA, firstSublistMembersCount, firstSublistMembersOffset); alias secondList = getBytesAs!(MyBinarySubStructBForA, secondSublistMembersCount, secondSublistMembersOffset); } unittest { ... MyBinaryStructA *binaryData = cast(MyBinaryStructA *)fileData.ptr; auto a = binaryData.firstList; }
Re: Returning multiple values from a function
On Monday, 4 September 2017 at 09:22:25 UTC, Vino.B wrote: Thank you very much, i have used your idea and was able to resolve, and i need one more favor. the below code outputs the value but i need the name of the variable + value as below. Output : 1 2 ["C:\\Temp\\TEAM1\\BACKUP", "C:\\Temp\\TEAM2\\ARCHIVE"] Required Output: Test1 = 1 Test2 = 2 Path = ["C:\\Temp\\TEAM1\\BACKUP", "C:\\Temp\\TEAM2\\ARCHIVE"] For fixed names case you can hardcode it: writeln("Test1 = ", Params[0]); writeln("Test2 = ", Params[1]); writeln("Path = ", Params[2]); You can't print the actual name of the variable used in tuple constructing because tuple doesn't store it. More of this, the tuple can be constructed from expression without a name, so it's impossible in common case.
Re: Bug in D!!!
On Wednesday, 30 August 2017 at 20:47:12 UTC, EntangledQuanta wrote: interface I { void Go(T)(S!T s); static final I New() { return new C(); } } abstract class A : I { } class C : A { void Go(T)(S!T s) { } } This is a blocker for me! Can someone open a ticket? Judging by the length of the thread that I did not read, the real problem was not spotted, otherwise, it would be shorter. The problem is called "virtual method in the interface" anti-pattern. Just never do that, and life will be easier. In this case, I recommend to move Go to A and make it just dispatcher for specialized private non-templated virtual functions. You don't need all this mess with string templates for it.
Re: Returning multiple values from a function
On Monday, 4 September 2017 at 07:27:12 UTC, Vino.B wrote: Hi, Can you help me in how to return multiple values from a function, the below code is throwing an error as below import std.stdio: writeln; import std.typecons: tuple, Tuple; Tuple!(int, string[]) Params () { return tuple(1, ["C:\\Temp\\TEAM1\\BACKUP", "C:\\Temp\\TEAM2\\ARCHIVE"]); } void main (){ Params.writeln; }
Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?
On Monday, 21 August 2017 at 02:17:57 UTC, crimaniak wrote: ... shared A a; ... Sorry, accidental delete, read this as shared A a = new shared(A);
Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?
On Monday, 14 August 2017 at 03:59:48 UTC, Jonathan M Davis wrote: And no, this isn't ideal, but the only semi-decent solution that's been proposed that safely casts away shared for you is synchronized classes, which Andrei describes in TDPL but have never been implemented. After reading this I did some experiment to understand the situation better. I make a simple class and unittest: // dmd sync1.d -unittest -main unittest { import std.stdio; synchronized class A { private int a; void inc() { ++a; } int get(){ return a;} } shared A a; for(int i=0; i<100; ++i) a.inc(); writeln(a.get); } Oops! Deprecation: read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(this.a, 1) instead. Why use atomic operations if the class already synchronized? Well.. ... import core.atomic: atomicOp; ... // ++a; // Deprecation: read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(this.a, 1) instead. atomicOp!"+="(this.a, 1); ... ok, works. But it works by the way as if synchronized just makes all methods shared, but does not provide the object methods with a mutex lock, as Java does. Am I right here? And what preventing to implement it right, lack of manpower or some ideologic problems?
Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?
On Thursday, 17 August 2017 at 13:09:29 UTC, Kagamin wrote: On Wednesday, 16 August 2017 at 23:15:10 UTC, crimaniak wrote: I wonder if it possible and usable to make some template to support this pattern, where we give mutex(es), shared object(s) and delegate to operate with objects as non-shared. https://dpaste.dzfl.pl/8b3b05c8ec0a like this? Not sure if it helps, don't forget that it's a casted shared object. Yes, something like this. In general, I thought about the possibility of using several shared objects in this block but then realized that everything can be reduced to the case of one object.
Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?
On Monday, 14 August 2017 at 03:59:48 UTC, Jonathan M Davis wrote: The way to handle shared is to protect the section of code that's using the shared object with either a mutex or synchronized block, and then you cast away shared from the object within that section and operate on it as thread-local. When you're done, you make sure that you don't have any thread-local references to the data, and you release the mutex or exit the synchronized block. e.g. something like shared T sharedObj = getSharedObj(); synchronized(mutex) { T nonSharedObj = cast(T)sharedObject // do stuff... // make sure that no references to nonSharedObj have escaped } Casting objects just to work with it every time is so bad style for me that I even didn't consider such possibility. In fact, I did make something like this but with __gshared both object and mutex. I think I need to review this part of site engine and my programming habits too. I wonder if it possible and usable to make some template to support this pattern, where we give mutex(es), shared object(s) and delegate to operate with objects as non-shared.
Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?
On Sunday, 13 August 2017 at 11:35:05 UTC, Arek wrote: Yeah, I've read this. But conurrency.send cannot pass immutable object. The same story with Unique. Sorry, read this as 'efficient immutable'. More over, "shared" looks rather like unfinished concept. Yes, exactly. Anyway, _gshared looks very promising, so I will try to work out any approach. More of this, I think, you can't avoid __gshared for any complex work. Even mutexes from Phobos doesn't support shared, so I had to 'cowboy with __gshared' when implementing my site engine.
Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?
On Saturday, 12 August 2017 at 18:57:44 UTC, Arek wrote: I have the folowing problem: I like to envelope the class object in struct to control the destruction moment and then send this object to another thread/fiber (or task, cause I use vibe-d). I can't find any method to make it working. Any ideas? I tried it too some time ago. Then I read Alexandrescu book and realized that the authors of the language do not want anyone to do this. Long story short, just plan your application so that each complex object is monitored by only one thread/task, and pass not objects, but messages (immutable structs) about what to do with them.
Re: Need some vibe.d hosting advice
On Friday, 11 August 2017 at 13:06:54 UTC, aberba wrote: So I'm into this platform with a vibe.d api server + back-end and I'm confused/curious to know the hosting package to use. I will have a lot of images uploaded by users. 2. Get an EC2 instance from Amazon or Vultr and install everything yourself and save images on disc (potentially problematic). This can not be scaled easily Why do you think it can't be scaled? We have vibe.d on EC2 hosting. Common advice: get the same distribution as on the working machine where you are producing binaries to avoid problems with .so. First, we get default centos-based VM, and after some wasted time, it was easier to change it to Ubuntu VM to run the application, compiled on my working Ubuntu machine.
Re: d_to_html.d
On Sunday, 6 August 2017 at 00:22:32 UTC, David Gileadi wrote: On 8/5/17 12:07 PM, WebFreak001 wrote: Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc. [snip] That is amazing! I can't decide whether it's the best thing I've ever seen or a horrible hack, The best thing for Olympic programming, horrible hack for production code. :)
Re: stacktrace for InvalidMemoryOperationError
On Saturday, 15 July 2017 at 18:14:13 UTC, Joakim wrote: core.exception.InvalidMemoryOperationError@src/core/exception.d(696): Invalid memory operation ... See the wiki page about this: https://wiki.dlang.org/InvalidMemoryOperationError If you can't do all that, look for places you might be allocating in a destructor. The recent GC allocation flag -vgc might help: https://dlang.org/blog/2017/06/16/life-in-the-fast-lane/ Yes, I found it already and make documentation proposition about https://issues.dlang.org/show_bug.cgi?id=17642 Then it turned out that it was more difficult to avoid this problem than to find the cause. Yes, I have a heavy cleanup in the destructor and I can't definitely make this cleanup @nogc. So first I tried to make problematic object instances RefCounted. In my case, it means change ClientController[string] to RefCounted!ClientController[string] and create an object by lib interface, not by new. I have to change ClientController from object to struct because automem can't work with the object. I hunted all extra copies of these objects and kill them all, so now I sure there are no copies except the main container. I tried different libraries from std.typecons.RefCounted to automem. And I fail to make it _really_ reference counted. It's not deleted when I delete it from the container. Every time it's collected by GC and application is dropped. So I decided that in the container itself. Obviously, the associative array does not delete the elements themselves on demand, but loses them and gives them to the garbage collector. I didn't find any map or multimap @nogc container so I make the ugly solution: I move all destruction to method destructMe() and in ~this() now is just assert(destructMeIsCalled). And now I have to call manually destructMe() before object removing. It seems it works. I'm wondering if there is a less ugly way to have the map of reference counted objects.
Re: char e string em linguagem D
On Thursday, 13 July 2017 at 22:36:47 UTC, Basile B. wrote: return cast(char[])` ... Never cast a literal to char[]. modifying the resulting char[] will lead to AV, at least under linux. `.dup` the literal if you really needs char[]. Hmm, yes, my bad. Probably, it was necessary even for this simple example to write const char[].
Re: char e string em linguagem D
On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar? Se acepta utilizar intervalos en lugar de punteros desnudos. (Hola, soy traductor de google) import std.stdio, std.string; //https://www.vivaolinux.com.br/script/GNU-que-bacana class GnuQueBacana { this(){} char[] stalman() { return cast(char[])` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } char[] torvald() { return cast(char[])` # ### ##O#O## ### ##\#/## #lll## #l## #l### ##### OOO#ll#OOO OO#ll#OO OOO#ll#OOO OOO##OOO https://www.kernel.org `; } string stallman() { return ` ((__-^^-,-^^-__)) *---***---* *--|o o|--* \ / ): :( (o_o) - https://www.gnu.org `; } string torvalds() { return ` # ### ##O#O## ### ##\#/## #lll## #l## #l### ##### OOO#ll#OOO OO#ll#OO OOO#ll#OOO OOO##OOO https://www.kernel.org `; } }; void main() { GnuQueBacana gnu = new GnuQueBacana(); writeln(gnu.stalman(), gnu.torvald(), gnu.stallman(), gnu.torvalds()); }
Re: Having a strange issue with std.net.curl.HTTP as a struct dependency
On Wednesday, 12 July 2017 at 13:47:06 UTC, Adam D. Ruppe wrote: This tells me the problem is in the collection order at the end of the program. ... So I'd say the answer is prolly to keep HTTP away from the GC. Manually free its arrays, or keep them outside arrays in the first place. I'd try also calling GC.collect() manually before the exit.
Re: mysql-native ResultRange + map
On Tuesday, 11 July 2017 at 22:46:00 UTC, Steven Schveighoffer wrote: On 7/5/17 12:04 PM, crimaniak wrote: ... Because of the temporary copy likely inside map closes the connection. See the bug I reported: https://github.com/mysql-d/mysql-native/issues/117 Yes, it seems to be the same issue. (BTW, then I tried filter() just for curiosity and have the same problem). I work around this in my code by moving the temporary copy. But I'm sorry to say you likely will not be able to fix map. I have WEB application (no big recordsets to transfer), so, for now, I "fix" it inside of my sql wrapper: just load recordset to an array and give it instead of ResultRange. I don't like it, but it works and all shit is localized in one place. I think Nick's comment is interesting, "Seems that using struct dtors without refcounting should in general be regarded as a code smell?" It's a good question. I've also always added ref counting when wanting to "auto close" a struct's resources. In fact, I can't really think of a good use of destructors for structs that isn't for reference counting itself. I don't think so. There is architecture problem: non-copyable by nature resource represented by copyable struct. We need non-copyable class/object semantics here or have to emulate it if using the struct to have the correct behavior. It's fully o.k. to get some resources required by _this exact copy_ of struct in the constructor and then release it in the destructor. For example of good use of destructors: position in some game, requires non-fixed space to store itself. We want to make copies of positions, apply some movies to them and then make copies again to search in positions tree. Copy constructor will malloc some space and copy source position data, the destructor will free this space, and we don't need reference counting here.
stacktrace for InvalidMemoryOperationError
Hi! I have vibe.d application and long-standing error in it. For the current moment, I have logs for stdout, stderr, and additional log to write exceptions I catch. This error gives me only the short line in stderr log: core.exception.InvalidMemoryOperationError@src/core/exception.d(696): Invalid memory operation Also, I use registerMemoryErrorHandler(); (see http://vibed.org/docs#handling-segmentation-faults ) What else can I do to have the stack trace for this error? I can't debug it because I don't have it on my developer's machine.
Re: proposed @noreturn attribute
On Sunday, 9 July 2017 at 00:16:50 UTC, Walter Bright wrote: I assume there is a standard jargon for this - does anyone know Type Theory? I'm afraid it's perpendicular to type theory - every type including Nothing can be returned. Most simple solution - just to remove '@' and call this type 'noreturn'. noreturn functionFoo(bla-bla-bla);
Re: Checked vs unchecked exceptions
On Thursday, 6 July 2017 at 01:31:44 UTC, Moritz Maxeiner wrote: --- void foo() throws AException throws BException { ... } vod bar() { foo(); } --- works and bar's exception is inferred by the compiler to contain AException and BException. But to be clear (and the title and description of any DIP addressing this should reflect this): These are not checked exceptions, because checked exceptions would require bar to declare its exception set manually. Not checked in sense of Java, but Java has no deductible exceptions. If compiler will fail on `void bar() { foo(); } throws AException;` we still can call it 'checked', I think. In sense of D.
mysql-native ResultRange + map
Hi all! After some hard time with debugging, I found ResultRange returned by query() and Prepared::query() of mysql-native package can't be combined with map() because after map() it becomes empty resultset. Code (conn.queryRows just a wrapper for query(Connections, sql) ): immutable sql = "SELECT id FROM "~tableName~" ORDER BY id"; conn.queryRows(sql).each!(row => writeln("each:", row[0].to!string)); string[] applied = conn.queryRows(sql).map!(row => row[0].to!string).array; writeln("applied:", applied); foreach(row; conn.queryRows(sql)) writeln("foreach: ", row[0].to!string); conn.queryRows(sql).map!(row => row[0].to!string).each!(row => writeln("map-each:", row)); foreach(row; conn.queryRows(sql).map!(row => row[0].to!string)) writeln("foreach-map: ", row); stdout.flush; Result: SELECT id FROM versionupdate ORDER BY id each:.Script20161013_create_database each:.Script20161221_sites_table each:.Script20161227_update_users_devices each:.Script20170121_ownerid each:.Script20170124_create_clients each:.Script20170213_no_unique_site_name each:.Script20170215_remove_site_sn each:.Script20170228_remove_site_index each:.Script20170301_add_linkNo each:.Script20170301_fix_sites_indexes each:.Script20170310_demo_client each:.Script20170513_max_dev_number SELECT id FROM versionupdate ORDER BY id applied:[] SELECT id FROM versionupdate ORDER BY id foreach: .Script20161013_create_database foreach: .Script20161221_sites_table foreach: .Script20161227_update_users_devices foreach: .Script20170121_ownerid foreach: .Script20170124_create_clients foreach: .Script20170213_no_unique_site_name foreach: .Script20170215_remove_site_sn foreach: .Script20170228_remove_site_index foreach: .Script20170301_add_linkNo foreach: .Script20170301_fix_sites_indexes foreach: .Script20170310_demo_client foreach: .Script20170513_max_dev_number SELECT id FROM versionupdate ORDER BY id SELECT id FROM versionupdate ORDER BY id As you see simple each() and foreach() works, but all examples with map() involved always empty. Can anybody explain such strange behavior?
Re: weird error message
On Sunday, 2 July 2017 at 01:06:29 UTC, Ali Çehreli wrote: On 07/01/2017 04:56 PM, crimaniak wrote: > about very long error messages generated in some > cases. Please submit a bug report. The compiler may be able to abbreviate certain types. For example, in this case most of the error message text is values of a static array elements. Done: https://issues.dlang.org/show_bug.cgi?id=17599
Re: weird error message
On Saturday, 1 July 2017 at 22:46:06 UTC, Adam D. Ruppe wrote: On Saturday, 1 July 2017 at 22:44:33 UTC, crimaniak wrote: enum moduleMask = ctRegex!`module\s+([^;]+)`; That should be `static`, not `enum`. I betcha that will at least change the error. Works both variants, and reason really in line with Captures c = ..., as mentioned Ali Çehreli. But my message not about this mistake (I fix it immediately), but about very long error messages generated in some cases. Maybe it will be good to have some compiler switch or special treatment for messages with so very long types.
weird error message
Just for fun (may be): code: auto findModule = execute(["dscanner", "--etags", entry.name]); enum moduleMask = ctRegex!`module\s+([^;]+)`; Captures c = findModule.output.matchFirst!(moduleMask); result (even C++ guys will be impressed): phobos_imports.d(43): Error: struct std.regex.Captures(R, DIndex = size_t) if (isSomeString!R) is used as a type phobos_imports.d(43): Error: template std.regex.matchFirst cannot deduce function from argument types !(StaticRegex(& func, Regex([InversionList(CowArray([9u, 14u, 32u, 33u, 133u, 134u, 160u, 161u, 5760u, 5761u, 8192u, 8203u, 8232u, 8234u, 8239u, 8240u, 8287u, 8288u, 12288u, 12289u, 3u])), InversionList(CowArray([0u, 59u, 60u, 1114112u, 3u]))], [Bytecode(2147483757u), Bytecode(2147483759u), Bytecode(2147483748u), Bytecode(2147483765u), Bytecode(2147483756u), Bytecode(2147483749u), Bytecode(2348810240u), Bytecode(2231369729u), Bytecode(2348810240u), Bytecode(2248146945u), Bytecode(0u), Bytecode(2952790017u), Bytecode(2281701377u), Bytecode(2231369729u), Bytecode(2281701377u), Bytecode(2248146945u), Bytecode(1u), Bytecode(3019898881u), Bytecode(2550136833u)], null, 2u, 0u, 2u, 17u, 0u, [CharMatcher(BitTable([15872u, 1u, 0u, 0u]), Trie(MultiArray([0LU, 2048LU], [8192LU, 1536LU], [281479271743488LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281483566710785LU, 281479271743489LU, 281479271743489LU, 281479271743491LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743492LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU, 281479271743489LU,
Re: mysql-native + vibe.d example
On Friday, 30 June 2017 at 16:18:33 UTC, tetyys wrote: On Friday, 30 June 2017 at 00:52:28 UTC, crimaniak wrote: Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: seems like it's already fixed https://github.com/mysql-d/mysql-native/commit/477636ad92a15d504308d1893f987685cd71 Yes, this is relevant fix. Thanks!
mysql-native + vibe.d example
Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: Log: SELECT id FROM versionupdate ORDER BY id Task terminated with unhandled exception: etc.linux.memoryerror.NullPointerError@src/etc/linux/memoryerror.d(325) ??:? void etc.linux.memoryerror.sigsegvUserspaceProcess(void*) [0x102ebad] ??:? void etc.linux.memoryerror.sigsegvDataHandler() [0x102eaee] ../../.dub/packages/mysql-native-1.1.0/mysql-native/source/mysql/result.d:466 const(pure nothrow @property bool function()) mysql.result.ResultRange.isValid [0xdf1626] ../../.dub/packages/mysql-native-1.1.0/mysql-native/source/mysql/result.d:536 void mysql.result.ResultRange.close() [0xdf1cb8] ../../.dub/packages/mysql-native-1.1.0/mysql-native/source/mysql/result.d:460 void mysql.result.ResultRange.__dtor() [0xdf15cc] ../../.dub/packages/mysql-native-1.1.0/mysql-native/source/mysql/result.d:430 ref return mysql.result.ResultRange mysql.result.ResultRange.opAssign(mysql.result.ResultRange) [0xdf1dba] source/vcm/sqlWrapper.d:63 mysql.result.ResultRange vcm.sqlWrapper.SqlWrapper.query!().query(immutable(char)[]) [0xdd57e3] source/updater/manager.d:92 void updater.manager.UpdateManager.update() [0xd74886] source/app.d:81 void app.prepareDb().__lambda1() [0xcfe740] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/core/core.d:595 void vibe.core.core.makeTaskFuncInfo!(void delegate()).makeTaskFuncInfo(ref void delegate()).callDelegate(vibe.core.core.TaskFuncInfo*) [0xc5b703] ../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/core/core.d:1224 void vibe.core.core.CoreTask.run() [0xf6a916] ??:? void core.thread.Fiber.run() [0x107f17b] ??:? fiber_entryPoint [0x107eede] ??:? [0x] Code fragment: string s = Sql(sqlString, args).toString!MysqlDialect; writeln(s);stdout.flush; // debugging... if(conn.__conn() is null) // debugging... throw new Exception("connection is null"); ResultRange result; // synchronized (mutex) result = conn.query(s); // <-- sqlWrapper.d:63 is here It seems I am doing something wrong so myself-native fails to detect it in isValid(). So I search for example how to use mysql-native in real multi-threaded vibe.d application with usage of MySQLPool. Please do not point me to basic example provided with package because it is single thread. Thanks.
Re: Checked vs unchecked exceptions
On Monday, 26 June 2017 at 19:31:53 UTC, Moritz Maxeiner wrote: And the good *way* to achieve this result would be the following: - When visiting `startFoo`, the compiler automatically aggregates all different exceptions it may throw and stores the resulting set - If `startFoo` is going to be part of a (binary) library and its symbol is exported, also export its exception set - Improve the compiler's nothrow analysis such that if startFoo is called in scope S, but all of the exceptions in its exception set are caught (i.e. can't break out of scope S), it is treated as nothrow in S. - Enclose the call to `startFoo` in B in a nothrow scope. After preparing my message I read tail of the thread and see your vision very close to mine. So listing exceptions that can be thrown is a good thing because it helps you write more reliable code. It is a bad thing because you force a human to do a machine's job. This is a bad necessity, but a necessary opportunity. Sometimes you need to be sure that the compiler's vision matches yours.
Re: Checked vs unchecked exceptions
On Sunday, 25 June 2017 at 17:38:14 UTC, mckoder wrote: I am disappointed that D doesn't have checked exceptions. Warning, Google translate is used! (sorry) I fully support mckoder with regard to exceptions. This is a great advantage of Java. I think, the problem with the introduction of verified exceptions in D is rather psychological, as the authors and the community mostly came from C++. Indeed, in C++, the checked exceptions failed, but I think this is more a failure of C++ than the ideas of checked exceptions. The Java experience has shown that this is a powerful tool that really helps to write reliable programs. Most of the arguments against exceptions are somewhat similar to the arguments of language lovers with a weak dynamic typing, by which listing argument types seems tedious. The relevant objection is that there is a problem with lambdas. I think everyone who started using the stream API in Java 8 was faced with this problem. But who said that you need to exactly repeat the approach of Java? When I encountered this problem, I tried to write an analog of this API, only with support for exceptions. As a result, the root of the problem was easily identified. In Java, each exception type thrown is an additional method parameter, similar to the input parameters, and there are no variadic templates for them. The correct implementation should have some TypeTuple for all the types thrown. And the possibility of calculating it. The following thoughts should be considered as speculative, I understand that these ideas will not be accepted. Take for start the system adopted in Java. Now add 'throws auto'. This does not mean 'throws Exception'! This means that the compiler must determine what exceptions this method or function throws. Now add a default - all functions where there are no throws are treated like 'throws auto'. What does this give us? The old code without throws continues to work, since exceptions, except for intercepted ones, successfully pop up to main() and are caught by runtime. But as soon as the author began to denote throws or nothrows, he gets all the benefits of the Java exception system. In addition, if the lower layer has changed, the intermediate layers that delegate the exceptions above do not need to be rewritten, only the code that deals directly with the exception processing and declares it with throws or nothrows will be affected. (I think that you should not abuse this, libraries that are supplied as a separate product should still encapsulate the underlying exceptions in their own). In addition, now the specification of 'throws A, B, C' lowered to 'throws ExceptionTypeTyple! (A, B, C)'. What does it give? We easily write templates that work with functions with any number of types of throws exceptions, and this can be handled according to the same rules as the other template parameters of the method.
Re: Isn't it about time for D3?
On Tuesday, 13 June 2017 at 17:57:14 UTC, Patrick Schluter wrote: I haven't the impression that the *language* itself suffer from so big flaws that it would warrant to fork it in a way that will lead to a lot frustration and bewilderment. I have the same opinion. Raw libraries, poor documentation and infrastructure are much more problematic. If it depended on me, I would declare an embargo on language changes and throw all the forces to eliminate the problems of infrastructure and libraries.
Re: Expressing range constraints in CNF form
On Sunday, 11 June 2017 at 00:28:58 UTC, Andrei Alexandrescu wrote: enum bool isInputRange(R) = is(typeof((ref R r) => r)) && "must be copyable" Regardless of the implementation method, this will require the previously proposed Phobos refactoring. Independent special definitions have to be reduced to general ones and use "static if" to select the algorithm. Otherwise, each failed independent definition will give an additional error message, and the compiler does not have the ability to determine which one is relevant.
site examples
I tried to run an example from the site. Example from https://dlang.org/phobos/std_regex.html#replaceAllInto section. And this is problem number 0: I can't give a link to the example, only to section. The section can be long, there can be more than one example, so it's good to have an anchor for each example. Problem #1: "Compilation output (255: Unknown signal 255) unable to fork: Cannot allocate memory." As I understand it, this is a common problem, and it leaves a bad impression. Ok, I copy example text and try to compile it. Oh, I need to make main(). Ok. "t1.d(6): Error: undefined identifier 'regex' t1.d(12): Error: undefined identifier 'replaceAllInto' t1.d(14): Error: 'writeln' is not defined, perhaps you need to import std.stdio; ?" Problem #3: we have imports in the example, but not all imports. Ok, I add it. Compile, run. A lot of commas. Is this proof that the method worked? Yes. Do these commas illustrate how this method works? Absolutely not. This is a replacement method, so I expect to see "before" and "after". It seems to me that examples on the site require additional work and in the current form are counterproductive in terms of attracting new users.
Re: Code improvement for DNA reverse complement?
On Friday, 19 May 2017 at 12:55:05 UTC, Biotronic wrote: revComp6 seems to be the fastest, but it's probably also the least readable (a common trade-off). Try revComp7 with -release :) string revComp7(string bps) { char[] result = new char[bps.length]; auto p1 = result.ptr; auto p2 = [$ - 1]; enum AT = 'A'^'T'; enum CG = 'C'^'G'; while (p2 > bps.ptr) { *p1 = *p2 ^ ((*p2 == 'A' || *p2 == 'T') ? AT : CG); p1++; p2--; } return result.assumeUnique; } In fact, when the size of the sequence is growing time difference between procedures is shrinking, so it's much more important to use memory-efficient presentation than to optimize logic.
Re: How to write parser?
On Sunday, 14 May 2017 at 19:00:09 UTC, Suliman wrote: I am trying to learn how to write text parser. I have example doc with follow format: #Header my header text ##SubHeader my sub header text it's there any better way to parse such format? Ready markdown Pegged based parser: https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/markdown.d
Re: How to avoid throwing an exceptions for a built-in function?
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote: I have a line of code that uses "to" function in std.conv for a purpose like: int index = to!int( user_apply[ 4 ] ); // string to int When the user_apply[ 4 ] has value, there is no problem; but when it is empty: "" it throws an ConvException exception and I want to avoid this exception. currently I have to use a dummy catch: try{ index = to!int( user_apply[ 4 ] ); } catch( ConvException conv_error ){ // nothing } I no need to handle that, so is there any way to prevent this exception? try this: https://dlang.org/phobos/std_exception.html#ifThrown
Re: Productive vibe.d dev environment (IDE, debugger) on Linux?
On Wednesday, 3 May 2017 at 17:43:07 UTC, kinke wrote: can anyone recommend a more or less production-ready dev environment for vibe.d on Linux? I'm evaluating vibe.d against Phoenix (Elixir/Erlang) for a new project. Today I gave Visual Studio Code a quick shot (with LDC 1.1.1 and DMD 2.071/72/74), with Webfreak's plugins, but I'm not happy at all (gdb/lldb crashing most of the time incl. debugged process, no AutoComplete/IntelliSense due to problems when building some of the plugin dependencies etc.). Any hints are greatly appreciated, as I'm really impressed by vibe.d itself so far. DDT: http://ddt-ide.github.io/ It just works including debugging, but autocompletion is rudimental.
Re: Default-valued nothrow @nogc std.conv:to
On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: Have anyone tried to implement a variant of `std.conv.to` that can be `nothrow @nogc` if the exception handling is replaced by an extra second parameter (`defaultValue`) returned iff the call to `to` throws? There is common ifThrown template in Phobos: https://dlang.org/phobos/std_exception.html#ifThrown I think it's better to add nothrow ifThrown implementation if needed. As for me, for such cases, where input data can be not relevant, is better to use Nullable type to indicate the error. In this case, an input value equal to the default value does not cause problems. Something like this: import std.typecons: Nullable; Nullable!T nullableTo(T, S)(S source) { import std.conv : to; tryreturn Nullable!T(source.to!T); catch(Exception e) return Nullable!T(); } T orElse(T)(Nullable!T n, T value){ return n.isNull() ? value : n.get; } unittest { assert(! "0".nullableTo!int.isNull); assert("0.0".nullableTo!int.isNull); assert("123.45".nullableTo!int.isNull); assert("123".nullableTo!int.get == 123); // And easy convertable to default value variant assert("123.45".nullableTo!int.orElse(5) == 5); }
Re: The app hanging after reach 1750MB of RAM
On Tuesday, 18 April 2017 at 11:43:24 UTC, Suliman wrote: I am writing app that extract data from DB to array of structures. void getSingleTrackInfo() { foreach(item; getTablesGPSSensorList) { ResultRange result = mysqlconnection.query(sqlquery); auto MySQLPointsLonLat = result.array; Is ResultRange closing query when exhausted? Did you try to call .close() on it after work?
Re: Interpolated strings
On Sunday, 16 April 2017 at 16:10:15 UTC, Nick Sabalausky (Abscissa) wrote: Yea, and note, I'm still open to the idea of better names than "interp". I'm still not entirely happy with that name. I'm even half-tempted to use "_". When I needed interpolation, I did not know about this library. So I create my own implementation and name it `expand`. I only needed class properties and did not support the expression, so this can not be considered a general solution, but name `expand` seems to be good for me. unittest { class InterTest { static int a = 1; static string bb = "--bb--"; mixin ExpandLocals; auto getInterpolated() { return expand!"a is $a, bb is $bb, and this is just $ sign"; } } assert((new InterTest).getInterpolated() == "a is 1, bb is --bb--, and this is just $ sign"); } What I think would be ideal is a language enhancement to allow "interp" to do its job without the extra syntactical noise. That would not only give us good interpolates strings, but would likely have other applications as well. Now I spend thinking some time about it and didn't find common solution without text mixin too.
Re: Interpolated strings
On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote: The compiler will basically lower the $"..." string to a mixin that concatenates the expression parts of the (inside the {}) and the plain text parts. It's easy implementable as a library (see https://github.com/Abscissa/scriptlike#string-interpolation) so it does not seem like a good idea to modify the language, only to change interp!"" to $"".
Re: Dlang Features You Would Like To Share
On Thursday, 13 April 2017 at 05:51:27 UTC, Dukc wrote: auto use(alias F, T)(T t){return F(t);} void main() { import std.stdio; foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((i * j).use!(x => x*x), " "); writeln; } } This way, you can avoid writing long expressions twice with UFCS. If fact you don't need any template to do this. Try the next: foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((x => x*x)(i * j), " "); writeln; }
URL (or URI) Pegged grammar - is it exists?
Hi, all! Yes, I know, most simple way to validate URL is regex and it works for most cases, but I search for a correct solution (ideally rfc3986-compatible), which will be hard to implement using regular expressions.
Re: Dlang forum: some feature requests
On Sunday, 9 April 2017 at 12:58:30 UTC, Vladimir Panteleev wrote: _Someone_ should write Markdown rendering plugins for popular news readers. What mime type will the Markdown enhanced messages use? text/plain or text/markdown as per https://de.wikipedia.org/wiki/Markdown ? text/plain because text/markdown will appear as an unreadable attachment for most clients (not least Gmail). IMHO, it's better to do the same as with HTML letters: text/markdown body + text/plain body for clients not supporting markdown.
Re: CTFE Status 2
On Sunday, 9 April 2017 at 00:25:45 UTC, Stefan Koch wrote: ... I assume that what you want will quite expensive in terms of compiler performance. ... Thanks for your answer!
Re: CTFE Status 2
On Saturday, 8 April 2017 at 09:14:17 UTC, Stefan Koch wrote: This is a question for D.Learn. please post there. Yes, I did it already and know, it is not possible for now: https://forum.dlang.org/post/crkxlbtfhsplxfila...@forum.dlang.org This is exact reason why I asked, how hard _to implement_ it. I asked you, because UDF constructor executed in CTFE, and you can give the most competent answer, because you are working on it. Also the question is to terse, I do not know what you are asking. How hard to implement something like special keyword __SYMBOL__, which will be alias for Foo (or string with fully qualified name of Foo) in example in my initial letter, in the scope of udf constructor.
Re: CTFE Status 2
Hi! Is it hard to implement some way to access symbol from UDA constructor of symbol? ``` class uda { this() { // Iterate by Foo members foreach (member; __traits(allMembers, __SYMBOL__)) ... } } @uda struct Foo { } ```
Re: Proposal: Exceptions and @nogc
On Sunday, 2 April 2017 at 05:16:23 UTC, Walter Bright wrote: Using a ref counted solution brings with it a host of problems because the compiler is not set up to ref count class object references, nor is any existing code set up to deal with that. Please describe in more detail the problems in this part. If you are still planning to introduce RC-based objects into the language, then it is not obvious that the dedicated allocators in the runtime are better than using RC-based exception objects.
Re: 'fopen64 cannot be interpreted at compile time' for __gshared File
On Saturday, 25 March 2017 at 16:08:49 UTC, NotSpooky wrote: __gshared implies static,... Thanks! Confusing for me moment.
'fopen64 cannot be interpreted at compile time' for __gshared File
Simple File test: void main() { import std.stdio; File f = File("test.txt", "w"); f.writeln("hello"); } All works as expected. Now let's add __gshared: void main() { import std.stdio; __gshared File f = File("test.txt", "w"); f.writeln("hello"); } Now we have: /usr/include/dmd/phobos/std/stdio.d(3797): Error: fopen64 cannot be interpreted at compile time, because it has no available source code /usr/include/dmd/phobos/std/stdio.d(3804):called from here: fopenImpl(namez.ptr(), modez.ptr()) /usr/include/dmd/phobos/std/stdio.d(404):called from here: fopen(name, stdioOpenmode) /usr/include/dmd/phobos/std/stdio.d(404):called from here: errnoEnforce(fopen(name, stdioOpenmode), delegate string() => text("Cannot open file `", name, "' in mode `", stdioOpenmode, "'")) /usr/include/dmd/phobos/std/stdio.d(404):called from here: this.this(errnoEnforce(fopen(name, stdioOpenmode), delegate string() => text("Cannot open file `", name, "' in mode `", stdioOpenmode, "'")), name, 1u, false) file.d(5):called from here: ((File __slFile648 = File(null, null);) , __slFile648).this("test.txt", "w") Oooops! Who can explain this error message to me? DMD64 D Compiler v2.073.0
Re: how to test if member of instance exists/defined?
On Wednesday, 22 March 2017 at 20:35:27 UTC, StarGrazer wrote: I've tried compiles but I guess that only checks if the code has valid syntax, not if it actually will compile in context. https://dlang.org/spec/traits.html#hasMember
Re: Question about vibe.conf file
On Sunday, 5 March 2017 at 13:41:23 UTC, Suliman wrote: I had seen some mentions about `vibe.conf` file in vibed docs. But can't understand it's structure and find examples of it's usage. Json file. Real example: ``` { "mqttHost" : "***.***.**.***", "mqttPort" : 1883, "mqttClientName" : "*", "mqttUsername" : "*", "mqttPassword" : "*", "listenInterface": "127.0.0.1", "listenPort" : 8088, "dbConnection" : "host=127.0.0.1;user=root;pwd=;db=dbname" } ``` You can read values from it like this: ``` // Read http setting from vibe.conf and init session store HTTPServerSettings prepareHttpSettings() { auto settings = new HTTPServerSettings; settings.port = readRequiredOption!ushort("listenPort","Port to listen by internal HTTP server"); settings.bindAddresses = [readRequiredOption!string("listenInterface", "Interface to listen by internal HTTP server")]; settings.sessionStore = new MemorySessionStore; return settings; } ```
Problem with send / receive
Hi all! I make vibe-d based project and now I have problem passing messages between threads. First some words about architecture. Each event in the system has a corresponding class that validates and performs the required actions. Each class has a nested structure with the parameters that are required for this event. Like this: ``` module vcm.bll.event.deleteSite; import vcm.bll.basicEvent; class DeleteSite : BasicEvent { import vcm.bll.model.types : Id; struct Params { Id siteId; } mixin EventConstructor; override bool canDo() { import std.conv : to; return errorList .addIf(!engine.sites.contains(params.siteId), "SiteModel with id "~params.siteId.to!string~" is not found") .isEmpty(); } override EventResult doIt() { engine.db.execute("DELETE FROM sites WHERE id=?", params.siteId); return EventResult(true,[],0); } } ``` I have Engine class object which resides in own thread and listen message queue for messages with event parameters. After receiving message corresponding handler is executed, and message with EventResult object sent back to caller thread (Task). For every event type there is HTTP request handler, who make EventType.Params structure, send it to engine Task, then do receiveOnly!EventResult and take actions according to it. The only proble with this approach was a lot of boilerplate in engine receive() call because of big amout of event types. I resolve it by this way (is this possible without string mixin?): ``` private static string getReceiver(EventTypes...)() pure { import std.traits; string eventHandlers; foreach(EventType; EventTypes) eventHandlers ~= `,(`~EventType.stringof~`.Params params, Task caller, Id userId){ auto event = scoped!`~EventType.stringof~`(userId, params); event.setEngine(this); caller.send(event.execute()); }`; return `receive ((ExitMessage _){ exitFlag = true; } ,(LogMessage entry){ logger.log(entry.message); } ` ~eventHandlers ~");"; } private void run() { import vibe.core.concurrency : receive, send; import std.typecons: scoped; import vcm.bll.event; bool exitFlag = false; while(!exitFlag) mixin(getReceiver!AllEvents); } ``` After adding another event I ran into a problem: ``` Task terminated with unhandled exception: Range violation core.exception.RangeError@source/vcm/bll/idContainer.d(44): Range violation ... vcm.bll.event.deleteSite.DeleteSite.canDo() [0xd8dd5a] source/vcm/bll/basicEvent.d:182 bool vcm.bll.basicEvent.BasicEvent.check() [0xd2f8bc] source/vcm/bll/basicEvent.d:197 vcm.bll.basicEvent.EventResult vcm.bll.basicEvent.BasicEvent.execute() [0xd2f9a5] source/vcm/bll/engine.d-mixin-173:198 _D3vcm3bll6engine6Engine3runMFZ9__lambda8MFS3vcm3bll5event10deleteSite10DeleteSite6ParamsS4vibe4core4task4TaskmZv [0xd34375] /usr/include/dmd/phobos/std/concurrency.d:168 void std.concurrency.Message.map!(void delegate(vcm.bll.event.deleteSite.DeleteSite.Params, vibe.core.task.Task, ulong)).map(void delegate(vcm.bll.event.deleteSite.DeleteSite.Params, vibe.core.task.Task, ulong)) [0xc7df3d] /usr/include/dmd/phobos/std/concurrency.d:1956 _D3std11concurrency10MessageBox1467__T3getTDFNaNbNiNfS3vcm3bll7commons11ExitMessageZvTDFS3vcm3bll6engine10LogMessageZvTDFS3vcm3bll5event9addDevice9AddDevice6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event9addClient9AddClient6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event7addRole7AddRole6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event7addUser7AddUser6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event7addSite7AddSite6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event10deleteSite10DeleteSite6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event13adminEditUser13AdminEditUser6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event14changePassword14ChangePassword6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event12deleteDevice12DeleteDevice6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event10deleteRole10DeleteRole6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event10deleteUser10DeleteUser6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3bll5event10editDevice10EditDevice6ParamsS4vibe4core4task4TaskmZvTDFS3vcm3!
Re: code D'ish enough? - ignore previous post with same subject
On Sunday, 26 February 2017 at 21:50:38 UTC, Jordan Wilson wrote: .map!(a => a.to!double) If lambda just calls another function you can pass it directly: == .map!(to!double)