Re: vibe.d + dub dynamic library

2015-01-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-01-02 19:44, Benjamin Thaut wrote: Is it possible to get dub to build vibe.d into a dynamic library? Or is it at least possible to make dub link against the shared version of phobos? I found this blog post about dynamic linktimes, unfortunately it does not describe how to actually make

Re: Example usage of the core.sync classes

2015-01-03 Thread Matt via Digitalmars-d-learn
On Friday, 2 January 2015 at 18:52:11 UTC, Benjamin Thaut wrote: Am 02.01.2015 um 19:45 schrieb Vlad Levenfeld: My personal favorite method is to use the primitives in core.atomic with a double or triple buffer. To double buffer, keep two buffers in an array (data[][] or something) and an

Re: getting all children classes in program

2015-01-03 Thread Baz via Digitalmars-d-learn
On Saturday, 3 January 2015 at 15:00:53 UTC, Ondra wrote: I'm not sure if there's a way around that other than to add some code in the class to register itself. You could use a static constructor that adds itself to a list. Or, to give each class a shared ID, you could add a static

Re: Weird UFC and opCall issues

2015-01-03 Thread Darrell via Digitalmars-d-learn
Ooops. Test() wasn't valid. Still working to create a range object that iterates over an internal data struct. But this was may error. On Saturday, 3 January 2015 at 20:26:41 UTC, Darrell wrote: Fails with: t.d(34): Error: need 'this' for 'opCall' of type 'int()' Also opCall seems to be

Re: getting all children classes in program

2015-01-03 Thread jklp via Digitalmars-d-learn
Off Topic ! But in the same way: --- static string[] IDs; ptrdiff_t getClassID(ClassType, ClassBase)() if ((is(ClassType == class)) (is(ClassBase == class))) { import std.algorithm; if (!is(ClassType : ClassBase)) return -1; else { auto classTypeString =

Re: simple question about using dub to import CyberShadow's aeutils

2015-01-03 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 3 January 2015 at 12:08:16 UTC, Vladimir Panteleev wrote: On Saturday, 3 January 2015 at 11:58:48 UTC, Laeeth Isharc wrote: import ae.utils; ae.utils is a package, perhaps you meant to import ae.utils.xml? aha. schoolboy error on my part. thank you for your help, and

Re: What exactly shared means?

2015-01-03 Thread via Digitalmars-d-learn
On Saturday, 3 January 2015 at 13:53:09 UTC, John Colvin wrote: I think you're talking cross-purposes. thread-local as in TLS v.s. thread-local as in not-shared. I am not talking TLS. TLS is related to object files, not types. You don't have shared vs non-shared. You have many different

Re: Weird UFC and opCall issues

2015-01-03 Thread Darrell via Digitalmars-d-learn
Seems when creating your own ranges they can't be a class. Must be a struct or Segmentation fault (core dumped) will follow. This works as long as Test is a struct. struct Test { @property int front() { return 2; } void popFront() { } enum bool empty = false; }; static

Re: Weird UFC and opCall issues

2015-01-03 Thread Darrell via Digitalmars-d-learn
Fails with: t.d(34): Error: need 'this' for 'opCall' of type 'int()' Also opCall seems to be required to create a range. class Test { int opCall() { return 1; } @property int front() { return 2; } void popFront() { } @property bool empty() { return

Re: getting all children classes in program

2015-01-03 Thread Ondra via Digitalmars-d-learn
Hi Baz jklp, thank you for ideas I will use your approach for this problem.

Re: What exactly shared means?

2015-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 03, 2015 12:14:54 via Digitalmars-d-learn wrote: On Saturday, 3 January 2015 at 00:12:35 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: In D, if a type is not marked as shared, then it is by definition thread-local, and the compiler is free to assume that it's

Re: What exactly shared means?

2015-01-03 Thread John Colvin via Digitalmars-d-learn
On Saturday, 3 January 2015 at 12:12:47 UTC, Ola Fosheim Grøstad wrote: On Saturday, 3 January 2015 at 10:13:52 UTC, John Colvin wrote: The Java, C11 and C++11 memory model. Well... http://en.cppreference.com/w/cpp/atomic/memory_order Ok, with the exception of relaxed atomics. Yes, I

Re: What exactly shared means?

2015-01-03 Thread John Colvin via Digitalmars-d-learn
On Saturday, 3 January 2015 at 13:33:21 UTC, Ola Fosheim Grøstad wrote: On Saturday, 3 January 2015 at 12:17:52 UTC, ketmar via Digitalmars-d-learn wrote: why should it? thread locals are... well, local for each thread. you can't access local of different thread without resorting to low-level

Re: getting all children classes in program

2015-01-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 3 January 2015 at 14:28:07 UTC, Ondra wrote: class C(T): B {} // missing in ModuleInfo The reason is that's technically not a class and doesn't exist at runtime, it is just a template for one (you can't new that, you'd have to new C!some_actual_type). If you were to add a

Re: What exactly shared means?

2015-01-03 Thread via Digitalmars-d-learn
On Saturday, 3 January 2015 at 12:34:10 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: their memory model into account. The vast majority of D code won't care one whit and won't have any problems, because very little of it needs to be shared, and thread communication most typically is

Re: getting all children classes in program

2015-01-03 Thread Ondra via Digitalmars-d-learn
I'm not sure if there's a way around that other than to add some code in the class to register itself. You could use a static constructor that adds itself to a list. Or, to give each class a shared ID, you could add a static member which returns some variation of its typeinfo. In fact,

Re: What exactly shared means?

2015-01-03 Thread via Digitalmars-d-learn
On Saturday, 3 January 2015 at 12:17:52 UTC, ketmar via Digitalmars-d-learn wrote: why should it? thread locals are... well, local for each thread. you can't access local of different thread without resorting to low-level assembly and OS dependent tricks. Of course you can, anything that is

Re: What exactly shared means?

2015-01-03 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 12:14:54 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Saturday, 3 January 2015 at 00:12:35 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: In D, if a type is not marked as shared, then it is by definition thread-local, and the

getting all children classes in program

2015-01-03 Thread Ondra via Digitalmars-d-learn
Hi, how can I get list of all children classes of class in program? I was trying to use ModuleInfo from D Coockbook but this does not work for template classes? ex.: class A{} class B:A{} // ok in ModuleInfo class C(T): B {} // missing in ModuleInfo I am trying to assign every class its

simple question about using dub to import CyberShadow's aeutils

2015-01-03 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I would like to use the XML parser from CyberShadow's ae.utils - I am building a tool to index RSS feeds in elasticsearch (something like rssriver but with more complete functionality). I am using dub to build the code. So far I just have an empty boilerplate app.d with the line import

Re: What exactly shared means?

2015-01-03 Thread via Digitalmars-d-learn
On Saturday, 3 January 2015 at 00:12:35 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: In D, if a type is not marked as shared, then it is by definition thread-local, and the compiler is free to assume that it's thread-local. I find this to be rather vague. If the compiler exploit this

Re: What exactly shared means?

2015-01-03 Thread via Digitalmars-d-learn
On Saturday, 3 January 2015 at 10:13:52 UTC, John Colvin wrote: The Java, C11 and C++11 memory model. Well... http://en.cppreference.com/w/cpp/atomic/memory_order Yes, I was hoping that perhaps you knew more specifics. AFAIK, when not restricted by any kind of barriers, SC-DRF does not

Re: What exactly shared means?

2015-01-03 Thread John Colvin via Digitalmars-d-learn
On Saturday, 3 January 2015 at 00:48:23 UTC, Peter Alexander wrote: On Friday, 2 January 2015 at 23:51:05 UTC, John Colvin wrote: The rule (in C(++) at least) is that all data is assumed to be visible and mutable from multiple other threads unless proved otherwise. However, given that you do

Re: cannot modify struct with immutable members

2015-01-03 Thread ted via Digitalmars-d-learn
Ali Çehreli wrote: On 01/02/2015 10:10 PM, ted wrote: I'm now taking the view that const is there for the compiler to optimise code on the basis that nothing can alter it once set (and can only be set on initialisation). Of course, that is true for const values, not for const

Re: What exactly shared means?

2015-01-03 Thread John Colvin via Digitalmars-d-learn
On Friday, 2 January 2015 at 23:56:44 UTC, Ola Fosheim Grøstad wrote: On Friday, 2 January 2015 at 23:10:46 UTC, John Colvin wrote: What significant optimisations does SC-DRF actually prevent? By SC-DRF I assume you mean the Java memory model. The Java, C11 and C++11 memory model. AFAIK

Re: cannot modify struct with immutable members

2015-01-03 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 01:00:58 -0800 Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 01/02/2015 09:07 PM, ketmar via Digitalmars-d-learn wrote: structure instance with const fields can be initialized only once, upon creation. so did `Test myTest1;` -- you

Re: cannot modify struct with immutable members

2015-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/02/2015 09:07 PM, ketmar via Digitalmars-d-learn wrote: structure instance with const fields can be initialized only once, upon creation. so did `Test myTest1;` -- you initialized `myTest1` with default values. you can't reinitialize it later. in C++ constness on member doesn't impose

Re: cannot modify struct with immutable members

2015-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/02/2015 10:10 PM, ted wrote: I'm now taking the view that const is there for the compiler to optimise code on the basis that nothing can alter it once set (and can only be set on initialisation). Of course, that is true for const values, not for const references. In the latter case it

Re: simple question about using dub to import CyberShadow's aeutils

2015-01-03 Thread Vladimir Panteleev via Digitalmars-d-learn
On Saturday, 3 January 2015 at 11:58:48 UTC, Laeeth Isharc wrote: import ae.utils; ae.utils is a package, perhaps you meant to import ae.utils.xml?

Re: Example usage of the core.sync classes

2015-01-03 Thread Vlad Levenfeld via Digitalmars-d-learn
On Saturday, 3 January 2015 at 15:44:16 UTC, Matt wrote: Right, I've been looking at core.atomic, but it has very little documentation, and it's territory I haven't explored, yet. Any chance of some pointers along the way? Could you be more specific about what you need help understanding?

Re: Weird UFC and opCall issues

2015-01-03 Thread ted via Digitalmars-d-learn
Darrell wrote: Seems when creating your own ranges they can't be a class. Must be a struct or Segmentation fault (core dumped) will follow. This works as long as Test is a struct. struct Test { @property int front() { return 2; } void popFront() { }

Re: Weird UFC and opCall issues

2015-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/03/2015 12:26 PM, Darrell wrote: Fails with: t.d(34): Error: need 'this' for 'opCall' of type 'int()' Also opCall seems to be required to create a range. D has a feature that does not exists e.g. in C++: You can call the type itself as a function. The 'Test()' syntax is a call

Re: What exactly shared means?

2015-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 03, 2015 13:39:51 via Digitalmars-d-learn wrote: On Saturday, 3 January 2015 at 12:34:10 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: their memory model into account. The vast majority of D code won't care one whit and won't have any problems, because very

Re: Weird UFC and opCall issues

2015-01-03 Thread Darrell via Digitalmars-d-learn
Thanks for the feedback. With classes, you need to create an instance Need to read up classes vs struct. This bit of syntax was very intresting. /* Alternatively, you can move test() inside Test as a static opCall: static Test opCall() { return new Test(); } Then,

Template function type inference with default arguments

2015-01-03 Thread ixid via Digitalmars-d-learn
Why don't templates take a type from the default argument if nothing else is supplied? It would be useful to be able to use an enum to set a default. enum MAX = 1_000; auto sieve(T)(T max = MAX) { import std.bitmanip : BitArray; BitArray n; n.length = max; T[]

Re: Example usage of the core.sync classes

2015-01-03 Thread Matt via Digitalmars-d-learn
On Saturday, 3 January 2015 at 22:10:49 UTC, Vlad Levenfeld wrote: On Saturday, 3 January 2015 at 15:44:16 UTC, Matt wrote: Right, I've been looking at core.atomic, but it has very little documentation, and it's territory I haven't explored, yet. Any chance of some pointers along the way?

Re: Template function type inference with default arguments

2015-01-03 Thread Meta via Digitalmars-d-learn
On Sunday, 4 January 2015 at 00:22:01 UTC, ixid wrote: Why don't templates take a type from the default argument if nothing else is supplied? It would be useful to be able to use an enum to set a default. I doubt anyone's ever thought of that particular use-case. Using your typeof(MAX)

Re: Example usage of the core.sync classes

2015-01-03 Thread Vlad Levenfeld via Digitalmars-d-learn
On Sunday, 4 January 2015 at 01:02:07 UTC, Matt wrote: What I mean is that I don't understand what atomicStore, atomicLoad, etc. actually DO, although in the case of the two mentioned, I can hazard a pretty good guess. The documentation doesn't exist to tell me how to use the functions found

Need extern (C) interface even though using Derelict GLFW

2015-01-03 Thread WhatMeWorry via Digitalmars-d-learn
I've been translating C++, OpenGL, and GLUT code into D, Derelict OpenGL, and Derelict GLFW using: import derelict.opengl3.gl3; import derelict.glfw3.glfw3; auto window = glfwCreateWindow(800, 600, Shaders, null, null); etc. Things have been going well. I then tried to implement window

Re: Need extern (C) interface even though using Derelict GLFW

2015-01-03 Thread Rikki Cattermole via Digitalmars-d-learn
On 4/01/2015 5:34 p.m., WhatMeWorry wrote: I've been translating C++, OpenGL, and GLUT code into D, Derelict OpenGL, and Derelict GLFW using: import derelict.opengl3.gl3; import derelict.glfw3.glfw3; auto window = glfwCreateWindow(800, 600, Shaders, null, null); etc. Things have been going

Re: How to create instance of class that get data from 2 another instance?

2015-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 01/02/2015 12:42 PM, Suliman wrote: auto seismodownload = new seismoDownload(emsc_csem, this); then: auto mysql = new MySQL(parseconfig,eqs); So could anybody show me better way? Yes, there is a better way. As I said I did not fully understand how use global class instance... One