### Re: Why D isn't the next "big thing" already

On Wednesday, 27 July 2016 at 10:17:57 UTC, NX wrote: On Wednesday, 27 July 2016 at 09:28:49 UTC, chmike wrote: 4. Web server && IO performance (see: https://www.techempower.com/benchmarks or https://github.com/nanoant/WebFrameworkBenchmark). Please, these are terribly outdated benchmarks.

### Re: Check of point inside/outside polygon

On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: ... Big thanks! Ehm... Now I should add iteration on array of points in first and second polygon? If it's not hard for you could you show how it should look please. Sorry, I may have misunderstood the initial problem. You were

### Re: Why D isn't the next "big thing" already

On Tuesday, 26 July 2016 at 15:11:00 UTC, llaine wrote: Hi guys, I'm using D since a few month now and I was wondering why people don't jump onto it that much and why it isn't the "big thing" already. Everybody is into javascript nowadays, but IMO even for doing web I found Vibe.d more

### Re: Check of point inside/outside polygon

The algorithm is to draw a horizontal (or vertical) half line starting at your point and count the number of polygon edges crossed by the line. If that number is even, the point is outside the polygon, if it's odd, the point is inside. Let (x,y) be the point to test and (x1,y1)(x2,y2) the end

### Go’s march to low-latency GC

In case you missed it https://blog.twitch.tv/gos-march-to-low-latency-gc-a6fa96f06eb7#.emwja62y1

### Re: Asynchronous Programming and Eventhandling in D

On Wednesday, 6 July 2016 at 11:33:53 UTC, Eugene Wissner wrote: The only reason libev was choosen is that it is the simplest implementation I know about. A few C files. I had an educational purpose: I wanted to see how an event loop works on low level. Asyncio was for me no-go, since I've

### Re: Asynchronous Programming and Eventhandling in D

On Tuesday, 5 July 2016 at 20:38:53 UTC, Eugene Wissner wrote: On Tuesday, 5 July 2016 at 08:24:43 UTC, O/N/S wrote: Hi ("Grüss Gott") I like the asynchronous events in Javascript. Is something similar possible in D? Found Dragos Carp's asynchronous library

### Re: What's the secret to static class members

On Wednesday, 29 June 2016 at 17:00:49 UTC, Guido wrote: On Wednesday, 29 June 2016 at 15:40:57 UTC, Andrea Fontana wrote: On Wednesday, 29 June 2016 at 15:33:58 UTC, Guido wrote: The problem is actually much more profound. The classes need to be declared outside the main() scope. WTF?!?!?!

### Re: Fibers, what for?

On Monday, 13 June 2016 at 00:57:11 UTC, Alex Parrill wrote: This is misleading. Any sort of cooperative system needs synchronization when two or more tasks try to access the same data, whether those "tasks" are OS threads, fibers, different machines on a network, etc. That is true. Sorry.

### Re: Fibers, what for?

On Sunday, 12 June 2016 at 05:11:57 UTC, Ali Çehreli wrote: For convenience, here's the link: http://www.ustream.tv/recorded/86352137/highlight/699197 unfortunately iPads are not supported to view the video. :( I see two major benefits of fibers overs threads. Fibers don't need

### Re: template with enum arg ?

This is awesome! I added it to my D cookbook. Thank you very much.

### template with enum arg ?

In a first implementation I defined a named enum in my class which I could use with my template function foo. final class Info { ... enum Value { info_1 = 1, ... } ... static bar(Value e) {...} } void foo(T)(T.Value e) { T.bar(e); } I could then write :

### Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"

I have an immutable final class with methods with the following signature import std.typecons; immutable class Base{ ... @safe pure nothrow final Tuple!(int,"value",bool,"hasValue") value(const string name) { return nameImpl(value); } @safe pure nothrow protected

### Re: Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"

final Tuple!(int,"value",bool,"hasValue") value(const string name) { return nameImpl(value); } Sorry, this is the error. It should have been final Tuple!(int,"value",bool,"hasValue") value(const string name) { return valueImpl(name); }

### Recommended coding convention for combining unix and windows code ?

Hello I'm writing some code that I want to be portable across Posix and Windows. What is the recommended code convention for such type of code ? 80% of the class implementation is the same for both OS. Should I write the following and copy past the 80% version( Windows ) { import

### Re: Implicit conversion of struct to bool for if (s) operation ?

On Monday, 6 June 2016 at 15:28:35 UTC, John wrote: Thank you John and Adam. That was a quick answer !

### Re: Overriden method not detected ?

On Friday, 3 June 2016 at 21:04:41 UTC, ag0aep6g wrote: Thank you ag0aep6g, especially for the missing shared in my static this ! Since I'm implementing a (hopefully useful) library, it would be unpleasant for users to have to cast away shared to print the info. It works with immutable at

### Re: Overriden method not detected ?

On Friday, 3 June 2016 at 15:23:16 UTC, Jonathan M Davis wrote: Thank you for your detailed explanation. If I have a static immutable object, I don't have to declare it as shared because it is implicit. Right ? Changing my __gshared into static shared raises some errors which I don't know

### Re: Overriden method not detected ?

On Friday, 3 June 2016 at 12:41:39 UTC, Jonathan M Davis wrote: ... On a side note, be warned that you almost certainly shouldn't be using __gshared like this. It's intended for interacting with C code not for D objects to be marked with D. As far as the type system is concerned, __gshared

### Overriden method not detected ?

When trying to compile the following code I get a compilation error import std.stdio; class Info { final string name() { return nameImpl(); } protected abstract string nameImpl(); } final class MyInfo : Info { this() { assert(__ctfe); } private __gshared info_ = new

### Re: Why simple code using Rebindable doesn't compile ?

On Tuesday, 31 May 2016 at 06:40:31 UTC, Era Scarecrow wrote: On Tuesday, 31 May 2016 at 05:31:59 UTC, chmike wrote: My conclusion is that rebindable is not a satisfying solution to have mutable references to immutable objects. I don't understand the rationale of these immutable references.

### Re: Why simple code using Rebindable doesn't compile ?

On Monday, 30 May 2016 at 21:32:46 UTC, Alex Parrill wrote: On Monday, 30 May 2016 at 10:09:19 UTC, chmike wrote: Why can't info() return a Rebindable!(immutable(InfoImpl)) ? What do you mean? `info` returns an `immutable(InfoImpl)`, not a `Rebindable!(immutable(InfoImpl))`. Rebindable

### Re: Why simple code using Rebindable doesn't compile ?

This code compile, but array appending doesn't work alias Rebindable!(immutable(InfoImpl)) Info; class InfoImpl { void foo() {} static immutable(InfoImpl) info() { __gshared immutable InfoImpl x = new immutable InfoImpl; return x; } } void main() {

### Re: Why simple code using Rebindable doesn't compile ?

Oops, the duplicate alias instruction and main are copy past error. It looks like the code was already too complex for me. ;) Here is the code I tested import std.typecons; Rebindable!(immutable TestImpl) Test; class TestImpl { void foo() {} Test test() { __gshared x = new

### Why simple code using Rebindable doesn't compile ?

Hello, here is a program stripped down to the minimum code that doesn't compile import std.typecons; Rebindable!(immutable TestImpl) Test; Rebindable!(immutable TestImpl) Test; class TestImpl { void foo() {} Test test() { __gshared x = new immutable TestImpl; return

### Re: String compare in words?

On average there would be less than 4 bytes remaining to compare. So a simple straightforward byte comparison should do the job efficiently.

### Re: String compare in words?

On Sunday, 29 May 2016 at 20:40:52 UTC, qznc wrote: On Sunday, 29 May 2016 at 18:15:16 UTC, qznc wrote: On Sunday, 29 May 2016 at 17:38:17 UTC, Jonathan M Davis wrote: And if you're not simply comparing for equality, what are you looking to figure out? Without more information about what

### Re: is my code to get CTFE instantiated object valid D ?

On Sunday, 29 May 2016 at 06:49:42 UTC, chmike wrote: What is the right way to use it ? I answer to my self after testing so that people looking for that info can find it here. The right way would be immutable Category category_; Rebindable!(immutable Category) instance() { return

### Re: is my code to get CTFE instantiated object valid D ?

On Saturday, 28 May 2016 at 21:21:34 UTC, ag0aep6g wrote: On 05/28/2016 09:54 PM, chmike wrote: The only inconvenience left is that we can't have mutable references to immutable objects. There is std.typecons.Rebindable for that. That would be a good news. What is the right way to use it ?

### Re: is my code to get CTFE instantiated object valid D ?

On Friday, 27 May 2016 at 20:20:36 UTC, chmike wrote: I need to create an app wide singleton instance for my class. The singleton is immutable, but I want to allow mutable references to that singleton object so that I can do fast 'is' tests. I declared this class Category { protected

### Is it possible to forbid synchronization on an object ?

In my long quest to implement a flyweight pattern with objects instantiated at compile time, I was indirectly notified of the possible problem of synchronization. In a flyweight pattern the user has the impression there are distinct instances where in fact objects with the same state (member

### Re: is my code to get CTFE instantiated object valid D ?

On Saturday, 28 May 2016 at 08:47:48 UTC, Kagamin wrote: For a trick of static mutable allocation see https://github.com/dlang/druntime/pull/1325 In the following instruction of the above commit, what effect has the [] after init ? _store[0 .. __traits(classInstanceSize, T)] =

### Re: is my code to get CTFE instantiated object valid D ?

On Saturday, 28 May 2016 at 08:47:48 UTC, Kagamin wrote: For a trick of static mutable allocation see https://github.com/dlang/druntime/pull/1325 Thank you that looks promising. I'll study an experiment with the code. If I would like that the instances are not in TLS, can I use the following

### Re: is my code to get CTFE instantiated object valid D ?

On Friday, 27 May 2016 at 21:41:02 UTC, Kagamin wrote: On Friday, 27 May 2016 at 20:20:36 UTC, chmike wrote: Is this code valid D or is the behavior undefined due to the cast ? A mutable object can be synchronized on: synchronized(Category.instance){} This will create and store a mutex in the

### is my code to get CTFE instantiated object valid D ?

I need to create an app wide singleton instance for my class. The singleton is immutable, but I want to allow mutable references to that singleton object so that I can do fast 'is' tests. I declared this class Category { protected static immutable Category instance_ = new Category;

### Effect of declaring a class immutable ?

I couldn't find any information about this on the dlang web site. What is the effect adding the immutable attribute to a class like this immutable class MyClass { ... } The compiler doesn't complain. Will it add the immutable attribute to all members ?

### Re: Problem with .debug info in program

After closer examination it seam that the second line with 9 is a bogus insertion. Removing it should fix the code line table. app.d 90x43aafb app.d 110x43aafe app.d

### Problem with .debug info in program

Hello, I've notice that gdb was improperly displaying source lines with disassembled code. I looked at the assembly to check what is inlined and what not and the difference between the use of is and == in the machine code. I then tested with objdump with a simple program and saw the same

### Re: Problem with .debug info in program

Here you have the object lines from app with the addresses. ./app.d:[++] app.d 30x43aae8 app.d 50x43aaf0 app.d 70x43aaf7 app.d

### Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote: (This effect could be simulated by making my_var into a function, but i don't want to do that.) May I ask why you don't want to do that ? In D you can call a function without args without (). So if you write private int my_var_ = 4; //

### Re: mutable keyword

There is a benefit in not allowing to get pointers to class members. It allows to have movable object instances and this give access to some faster GC algorithms like generational garbage collection which is in use in Java. As an old C++ programmer and newbee in D programming, the D

### Re: problems with Rebindable

On Saturday, 21 May 2016 at 13:17:11 UTC, ag0aep6g wrote: On 05/21/2016 12:42 PM, chmike wrote: Rebindable!Info x1, x2 = Infos.one; Rebindable!(immutable Info) x1, x2 = Infos.one; Indeed. Thanks. Reading the unit tests in the source code and the implementation of Rebindable helped.

### Re: problems with Rebindable

On Saturday, 21 May 2016 at 10:42:13 UTC, chmike wrote: source/app.d(23,27): Error: cannot implicitly convert expression (one) of type immutable(Obj) to app.Info Apparently Rebindable doesn't support polymorphism. This is hopefully fixable. source/app.d(43,5): Error: 'x1' must be of

### Re: Immutable objects and constructor ?

On Saturday, 21 May 2016 at 08:24:19 UTC, Ali Çehreli wrote: On 05/21/2016 01:07 AM, chmike wrote: > Unfortunately it is not possible to write this > > import std.typecons; > class Info{...} > rebindable!Info x; You have a capitalization typo. Rebindable is a type template, rebindable is a

### problems with Rebindable

This thread is a followup of https://forum.dlang.org/post/vuljzyufphsywzevu...@forum.dlang.org with a refocused subject and question. I'm looking for a mutable reference to a none mutable object to implement the flyweight pattern. It is for a library and its user interface. So I'm not

### Re: Immutable objects and constructor ?

Since I'm trying to implement a flyweight pattern, the opEqual need only comparision of reference in my case. By the way, what operation is the switch performing ? OpEqual or is ?

### Re: Immutable objects and constructor ?

Unfortunately it is not possible to write this import std.typecons; class Info{...} rebindable!Info x; I get the following error message source/app.d(11,3): Error: template std.typecons.rebindable matches more than one template declaration: /usr/include/dmd/phobos/std/typecons.d(1675,14):

### Re: Immutable objects and constructor ?

On Friday, 20 May 2016 at 17:35:01 UTC, Kagamin wrote: On Friday, 20 May 2016 at 16:09:54 UTC, chmike wrote: But I now met another error in my main(). I can't assign the immutable object to a mutable reference. Info x1 = MyInfos.one; Is it possible to define a mutable reference to an

### Re: Immutable objects and constructor ?

On Friday, 20 May 2016 at 15:43:28 UTC, Marc Schütz wrote: It looks like your don't actually need `Obj` to be a real nested class. Try declaring it as `static Obj : Info { }`. This should work if `Obj`'s methods don't need access to `MyInfo`'s non-static members. That worked great. Thank

### Re: Immutable objects and constructor ?

I solved the problem by moving the class Obj definition out of the class MyInfo. I still don't understand why I had to do that. In C++ this would work without problem. I now have interface Info {. . .} class Obj : Info {. . .} class MyInfos { . . . static immutable Obj one = new

### Re: Immutable objects and constructor ?

The error message is gone, but I now have another compilation error message I don't understand. This is what I have in fact interface Info { . . . } class MyInfos { . . . protected: class Obj : Info { . . . } public: static immutable Obj one = new immutable Obj(...);

### Immutable objects and constructor ?

I'm implementing the flyweight pattern. It means that I have a set of object instances representing all the possible values. This allows me to manipulate "values" by simply manipulating references to the instance. Testing "value" equality boils down to simply compare reference value. I hope

### Re: static member and/or @property ?

On Thursday, 19 May 2016 at 15:33:21 UTC, ag0aep6g wrote: . . . interface AThing { final string name() { return nameImpl(); } string nameImpl(); } class OneThing : AThing { static string name() { return "OneThing"; } override string nameImpl() { return name(); } } class

### static member and/or @property ?

Sorry for the confusing subject, I couldn't find a concise formulation of my question. I have a set of classes derived from the same interface so that I can use polymorphism. I would like to store the name of the class as a string so that it can be retrieved as a static member of the class

### ErrorException thrown when errno is modified ?

Hello, I'm planning to call some posix functions core.sys.posix that may set the errno value in case of error. e.g. read() or write(). Checking the std.exception documentation I see that ErrnoException may be thrown when errors setting errno may occur. Does this affect the posix calls ?

### How to find the content of core.sys.* ?

Hello, The nice and handy documentation of dlang doesn't provide any info on the core.sys. How can I find out all the things that are in there ?

### Re: D equivalent of C++ bind ?

On Monday, 16 May 2016 at 15:57:52 UTC, Dsby wrote: you can remove "auto ref". and I remove the "auto ref" in my use. if used the "alias T", It can not handle all while when the T is a delegate. in C++ std::bind, the arguments order you can sort by used. in D I do not find how to

### Re: Async or event library

On Thursday, 12 May 2016 at 14:02:30 UTC, Dsby wrote: https://github.com/putao-dev/collie Thank you very much for this library I wasn't aware of. I see it's using the Reactor pattern (select/kevent/epoll of Posix) by opposition to the Proactor pattern (IOCP on Windows) [D. Schmidt et al,

### Re: D equivalent of C++ bind ?

On Thursday, 12 May 2016 at 10:38:37 UTC, Dsby wrote: I write one, bind functon to a delegate. In here: https://github.com/putao-dev/collie/blob/master/source/collie/utils/functional.d this is the code: auto bind(T,Args...)(auto ref T fun,Args args) if (isCallable!(T)) { alias

### Re: D equivalent of C++ bind ?

Thanks. This does the job but it's not as concise.

### Re: Async or event library

vibed uses libevent, a C library. The discussion is regarding a possible pure D equivalent of libevent. libasync is an interesting proposal but it is apparently slower than libevent. I don't know the current status because vibed improved its performance in the last months. My initial

### D equivalent of C++ bind ?

Is there an equivalent in D of the C++11 std.bind template class [http://en.cppreference.com/w/cpp/utility/functional/bind] ? Here is a blog post showing different examples of its use https://oopscenities.net/2012/02/24/c11-stdfunction-and-stdbind/ A possible use case is for a callback

### Re: Async or event library

It seam that the scope of the event loop we are talking should be clarified to avoid confusions. There is the GUI event loop which is generally single threaded for efficient access to the data structure representing the GUI content. Single thread also simplifies synchronization and make

### Re: Async or event library

Excuse the naive question rikki, why does the window event loop have to be single threaded ? The question is just to expose the rationale. Is it to avoid the synchronization overhead to access the window data ? In this case there is indeed a lot of data. Is there another reason ? In some

### Re: Async or event library

On Thursday, 5 May 2016 at 09:21:04 UTC, rikki cattermole wrote: Event loops needs to be thread local not per process. So many API's such as WinAPI for e.g. GUI's have this requirement in it that its just not worth fighting over. I don't understand. Do you mean that these event loops are

### Re: Async or event library

I would like to add that the switchable TLS is only a half backed solution. It would't work in a multi core context where threads are truly executing in parallel. Two such threads might get the same TLS context which would invalidate its implicit predicate. Another strategy would be to forbit

### Async or event library

Hello I have seen the wiki page https://wiki.dlang.org/Event_system and would like to know the current status. Is there a working group for this subject ? This is a topic I'm interested in and did some modest work on some years ago. At the bottom of the wiki page there is an innocent

### Accepting function or delegate as function argument

I have implemented the following class (simplified ;) ) class Foo(K,T) { this(T delegate (K) factory) { m_factory = factory; } T delegate (K) m_factory; T bar(K key) { return m_factory(key); } } string dummyFactory(string key) { return "Hello "~key; } void main() { auto

### Re: Code example for function/delegate as template argument ?

Thank you Basile and Teoh.

### Re: Code example for function/delegate as template argument ?

I think you misunderstood the second question. Here is another attempt with an example. // function accepting a function as argument void foo(function void fg(int)) { fg(5); } // A class with a none static method with the same signature as the argument function of foo class Bar {

### Re: Code example for function/delegate as template argument ?

On Wednesday, 4 May 2016 at 06:59:00 UTC, Basile B. wrote: . . . void main(string[] args) { alias fun = (a) => a.writeln; auto foo = Foo!fun("hello"); } Is this equivalent to Foo!(a => a.writeln) or is it required to split this in two instructions as you did ? I also thought the

### Code example for function/delegate as template argument ?

Hello, I failed to find some code example for a template class/struct that accept a function/delegate as template argument. All examples I could find use simple value types like int or double. I piggy bag another question. Defining a function/delegate as function argument is shown in

### Re: struct cannot deduce function from argument types

Oops! Stupid of me. There were three bugs in the code. Correct code is as follow: import std.stdio; class Data { string m = "Hello world !"; } struct IdxElem(D) { bool inUse; D data; } IdxElem!(Data)[string] idx; void main() { idx["test1"] = IdxElem!Data(true, new Data);

### struct cannot deduce function from argument types

The following code does not compile and I don't understand why. import std.stdio; class Data { string m = "Hello world !"; } struct IdxElem(D) { bool inUse; D data; } IdxElem!Data[string] idx; void main() { idx["test1"] = IdxElem(true, new Data); idx["test2"] =

### Re: Testing Return Value Optimization (RVO)

Oops found it my self. I had to use auto x = foo();

### Re: Testing Return Value Optimization (RVO)

I tried your code as this and it doesn't work. #!/usr/bin/rdmd -O import std.stdio; struct S { int a; @disable this(this); }; S foo() { S v; v.a = 1; writeln(); return v; } void main() { S x; x = foo(); writeln(); } I even tried with dmd -O without

### Testing Return Value Optimization (RVO)

Hello, Sorry if this question is a bit naive or shows a misunderstanding of RVO. I was trying to see if my C compiler was doing RVO with struct, but after testing it at is apparently not the case. Since I have heard that D supports RVO I wanted to give it a try in D. But apparently it