Workaround for dub build-path problem

2019-03-11 Thread bitwise via Digitalmars-d-learn
https://github.com/dlang/dub/issues/658 As noted in the above issue, dub runs in the root project directory for all packages, including dependancies. So if any project aside from the root project includes a relative path in it's dub.json, that dub build will break, due to the incorrect

Re: Make Dub output *.di files

2019-03-09 Thread bitwise via Digitalmars-d-learn
On Saturday, 9 March 2019 at 19:08:22 UTC, bitwise wrote: On Saturday, 9 March 2019 at 18:39:29 UTC, bitwise wrote: Is it possible to get Dub to output import headers for compiled D files? I found this, which almost works: "dflags": [ "-H", "-Hdimport", "-op" ] The only problem is that Dub

Re: Make Dub output *.di files

2019-03-09 Thread bitwise via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:39:29 UTC, bitwise wrote: Is it possible to get Dub to output import headers for compiled D files? I found this, which almost works: "dflags": [ "-H", "-Hdimport", "-op" ] The only problem is that Dub runs *above* the source directory, resulting in all my

Make Dub output *.di files

2019-03-09 Thread bitwise via Digitalmars-d-learn
Is it possible to get Dub to output import headers for compiled D files?

Re: Are Fibers just broken in D?

2018-04-24 Thread bitwise via Digitalmars-d-learn
On Friday, 20 April 2018 at 18:58:36 UTC, Byron Moxie wrote: [...] In WIN32 it looks like its leaking memory Unless there is something I'm misunderstanding, it seems that Fibers that were not run to completion won't unroll their stack, which would mean that some destructors wouldn't be

Re: How do I set a class member value by its name in a string?

2017-12-27 Thread bitwise via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 20:04:29 UTC, Marc wrote: I'd like to set the members of a class by its name at runtime, I would do something like this: __traits(getMember, myClass, name) = value; but since name is only know at runtime, I can't use __traits(). What's a workaround for

git workflow for D

2017-12-03 Thread bitwise via Digitalmars-d-learn
I've finally started learning git, due to our team expanding beyond one person - awesome, right? Anyways, I've got things more or less figured out, which is nice, because being clueless about git is a big blocker for me trying to do any real work on dmd/phobos/druntime. As far as working on a

Re: Undo?

2017-10-12 Thread bitwise via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 02:36:56 UTC, Mr. Jonse wrote: I requiring an undo feature in my code. Rather than go the regular route of using commands, I'm wondering if D can facilitate an undo system quite easily? We can think of an undo system in an app as a sort of recorder. The

Re: AliasSeq of T.tupleof for class and all base classes

2017-10-01 Thread bitwise via Digitalmars-d-learn
On Saturday, 30 September 2017 at 12:42:17 UTC, Steven Schveighoffer wrote: [...] https://issues.dlang.org/show_bug.cgi?id=17870

Re: @property with 2 arguments

2017-10-01 Thread bitwise via Digitalmars-d-learn
On Sunday, 1 October 2017 at 05:57:53 UTC, Tony wrote: "@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two parameters and the syntax for how it is accessed without (). And also this, which probably shouldn't

Re: AliasSeq of T.tupleof for class and all base classes

2017-09-30 Thread bitwise via Digitalmars-d-learn
On Saturday, 30 September 2017 at 12:42:17 UTC, Steven Schveighoffer wrote: I think the problem may be that derived classes' tupleof has some of the same variables as the base class? I agree it should work, but I think if it did work, it may not be what you want. You would see a lot of

AliasSeq of T.tupleof for class and all base classes

2017-09-29 Thread bitwise via Digitalmars-d-learn
As far as I can tell, this code should compile: class B { int a; } class D1 : B { int b; } class D2 : D1 { int c; } template TupleOf(Classes...) { static if(Classes.length > 1) alias TupleOf = AliasSeq!(Classes[0].tupleof, TupleOf!(Classes[1..$])); else static

Re: detect implicitly convertible typeid's?

2017-09-26 Thread bitwise via Digitalmars-d-learn
On Tuesday, 26 September 2017 at 19:31:56 UTC, Steven Schveighoffer wrote: [...] I just recently fixed Variant so it could accept shared data (so you could pass shared data using std.concurrency), and part of that depends on the fact that I know nothing else can point at the data (so no

Re: detect implicitly convertible typeid's?

2017-09-26 Thread bitwise via Digitalmars-d-learn
On Tuesday, 26 September 2017 at 17:27:02 UTC, Steven Schveighoffer wrote: -Steve About Variant - I was considering a pull request for retrieving a pointer to the internal data, but figured that it was left out on purpose due to @safety. OTOH, I was looking through dmd commits, and it

Re: detect implicitly convertible typeid's?

2017-09-26 Thread bitwise via Digitalmars-d-learn
On Monday, 25 September 2017 at 15:12:57 UTC, Steven Schveighoffer wrote: [...] I'm not sure of how much use this is, but I do not know enough to say that it's completely useless :) Certainly, some code somewhere has to be able to understand what the actual type of something is. That code

Re: Is it possible to avoid call to destructor for structs?

2017-09-25 Thread bitwise via Digitalmars-d-learn
On Monday, 25 September 2017 at 08:39:26 UTC, Adrian Matoga wrote: [...] You shouldn't store the pointer to barBuffer inside Foo. The language allows moving the structure around with a simple memcpy, so _bar is likely to point into garbage soon after it's assigned. Good point - but it's a

Re: detect implicitly convertible typeid's?

2017-09-25 Thread bitwise via Digitalmars-d-learn
On Monday, 25 September 2017 at 13:20:03 UTC, Steven Schveighoffer wrote: On 9/23/17 11:52 AM, bitwise wrote: Is it possible to tell if two objects represented by TypeInfo's are convertible to each other? Basically, is there a built in way to do this? int x; long y;

Re: Is it possible to avoid call to destructor for structs?

2017-09-24 Thread bitwise via Digitalmars-d-learn
On Monday, 25 September 2017 at 01:46:15 UTC, Haridas wrote: [...] It all works well so far. But as soon as I create an instance of Bar inside a Dlang class (say Foo) or as part of a Dlang dynamic array, hell follows. At some point, Dlang's GC kicks in and Bar's destructor gets called from

Re: Is it possible to avoid call to destructor for structs?

2017-09-24 Thread bitwise via Digitalmars-d-learn
On Sunday, 24 September 2017 at 17:11:26 UTC, Haridas wrote: In the following code, Bar is an element of struct Foo. Is there a way to avoid a call to ~Bar when ~Foo is getting executed? Don't construct it to begin with. struct Bar { import std.stdio : writeln; int a = 123;

detect implicitly convertible typeid's?

2017-09-23 Thread bitwise via Digitalmars-d-learn
Is it possible to tell if two objects represented by TypeInfo's are convertible to each other? Basically, is there a built in way to do this? int x; long y; assert(typeid(x).isImplicitlyConvertibleTo(typeid(y)); Thanks

Re: extern(C) enum

2017-09-17 Thread bitwise via Digitalmars-d-learn
On Monday, 18 September 2017 at 00:12:49 UTC, Mike Parker wrote: On Sunday, 17 September 2017 at 19:16:06 UTC, bitwise wrote: [...] I've been maintaining bindings to multiple C libraries (including Freetype 2 bindings) for 13 years now. I have never encountered an issue with an enum size

Re: extern(C) enum

2017-09-17 Thread bitwise via Digitalmars-d-learn
On Sunday, 17 September 2017 at 18:44:47 UTC, nkm1 wrote: On Sunday, 17 September 2017 at 17:06:10 UTC, bitwise wrote: [...] Just put the burden on the users then. It's implementation defined, so they are in position to figure it out... This isn't something that can really be done with

Re: extern(C) enum

2017-09-17 Thread bitwise via Digitalmars-d-learn
On Saturday, 16 September 2017 at 12:34:58 UTC, nkm1 wrote: On Saturday, 16 September 2017 at 03:06:24 UTC, Timothy Foster wrote: [...] [...] So it appears I'm screwed then. Example: typedef enum FT_Size_Request_Type_ { FT_SIZE_REQUEST_TYPE_NOMINAL, FT_SIZE_REQUEST_TYPE_REAL_DIM,

Re: extern(C) enum

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Friday, 15 September 2017 at 19:35:50 UTC, nkm1 wrote: On Friday, 15 September 2017 at 19:21:02 UTC, Timothy Foster wrote: I believe C enum size is implementation defined. A C compiler can pick the underlying type (1, 2, or 4 bytes, signed or unsigned) that fits the values in the enum.

Re: Ranges suck!

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Thursday, 14 September 2017 at 23:53:20 UTC, Your name wrote: [...] I understand your frustration. The fact that "inout" is actually a keyword makes it hard not to think that some very strange fetishes were at play during the creation of this language. As a whole though, the language

Re: extern(C) enum

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Friday, 15 September 2017 at 07:24:34 UTC, Jonathan M Davis wrote: On Friday, September 15, 2017 04:15:57 bitwise via Digitalmars-d-learn wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D

Re: extern(C) enum

2017-09-15 Thread bitwise via Digitalmars-d-learn
On Friday, 15 September 2017 at 06:57:31 UTC, rikki cattermole wrote: On 15/09/2017 5:15 AM, bitwise wrote: I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D, is it guaranteed to have the same underlying type

extern(C) enum

2017-09-14 Thread bitwise via Digitalmars-d-learn
I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members. If I declare an extern(C) enum in D, is it guaranteed to have the same underlying type and size as it would for a C compiler on the same platform?

Re: Is compiling for Android/iOS possible?

2017-09-07 Thread bitwise via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 18:34:28 UTC, Timothy Foster wrote: I'm just wondering if I made an application for Windows/Mac/Linux if I could get it to also work on mobile devices, or would I have to rewrite the application in another language to get it to work? If it's possible, what

Re: string to character code hex string

2017-09-02 Thread bitwise via Digitalmars-d-learn
On Saturday, 2 September 2017 at 18:28:02 UTC, Moritz Maxeiner wrote: [...] Code will eventually look something like the following. The point is to be able to retrieve the exported function at runtime only by knowing what the template arg would have been. export extern(C) const(Reflection)

Re: string to character code hex string

2017-09-02 Thread bitwise via Digitalmars-d-learn
On Saturday, 2 September 2017 at 18:28:02 UTC, Moritz Maxeiner wrote: In UTF8: --- utfmangle.d --- void fun_ༀ() {} pragma(msg, fun_ༀ.mangleof); --- --- $ dmd -c utfmangle.d _D6mangle7fun_ༀFZv --- Only universal character names for identifiers are allowed, though, as per [1]

Re: string to character code hex string

2017-09-02 Thread bitwise via Digitalmars-d-learn
On Saturday, 2 September 2017 at 17:45:30 UTC, Moritz Maxeiner wrote: If this (unnecessary waste) is of concern to you (and from the fact that you used ret.reserve I assume it is), then the easy fix is to use `sformat` instead of `format`: Yes, thanks. I'm going to go with a variation of

Re: string to character code hex string

2017-09-02 Thread bitwise via Digitalmars-d-learn
On Saturday, 2 September 2017 at 17:41:34 UTC, Ali Çehreli wrote: You're right but I think there is no intention of interpreting the result as UTF-8. "f62026" is just to be used as "f62026", which can be converted byte-by-byte back to "ö…". That's how understand the requirement anyway. Ali

Re: string to character code hex string

2017-09-02 Thread bitwise via Digitalmars-d-learn
On Saturday, 2 September 2017 at 15:53:25 UTC, bitwise wrote: [...] This seems to work well enough. string toAsciiHex(string str) { import std.array : appender; auto ret = appender!string(null); ret.reserve(str.length * 2); foreach(c; str) ret.put(format!"%x"(c)); return

string to character code hex string

2017-09-02 Thread bitwise via Digitalmars-d-learn
I need to convert a string of characters to a string of their hex representations. "AAA" -> "414141" This seems like something that would be in the std lib, but I can't find it. Does it exist? Thanks

Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
On Friday, 1 September 2017 at 17:26:11 UTC, ketmar wrote: [...] they *should* listen. anyone who doesn't just aksing for troubles, and i see no reason to guard 'em further. Yeah...eventually came to the same conclusion ;) Thanks

Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
On Friday, 1 September 2017 at 14:38:38 UTC, bitwise wrote: When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out? dlang's "Lexical" page says: "Identifiers starting

traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out?

Re: struct field initialization

2017-08-16 Thread bitwise via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 18:17:36 UTC, kinke wrote: On Wednesday, 16 August 2017 at 18:11:05 UTC, bitwise wrote: If I define a non-default constructor for a struct, are the fields initialized to T.init by the time it's called? The struct instance is initialized with T.init before

Re: struct field initialization

2017-08-16 Thread bitwise via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 18:11:05 UTC, bitwise wrote: [...] I'm asking this because I need to forward args to a container's node's value. Something like this: struct Node(T) { int flags; T value; // maybe const this(Args...)(int flags, auto ref Args args) {

struct field initialization

2017-08-16 Thread bitwise via Digitalmars-d-learn
If I define a non-default constructor for a struct, are the fields initialized to T.init by the time it's called? or am I responsible for initializing all fields in that constructor? ..or do structs follow the same rules as classes? https://dlang.org/spec/class.html#field-init Thanks

Re: __dtor vs __xdtor

2017-08-11 Thread bitwise via Digitalmars-d-learn
On Friday, 11 August 2017 at 17:20:18 UTC, HyperParrow wrote: [...] I made a mistake but it's not about i, which is a global. I meant "other.__dtor." just before the last assert. This doesn't change the results. hmm...indeed ;) On Friday, 11 August 2017 at 17:24:17 UTC, HyperParrow wrote:

Re: __dtor vs __xdtor

2017-08-11 Thread bitwise via Digitalmars-d-learn
On Friday, 11 August 2017 at 17:06:40 UTC, HyperParrow wrote: [...] int i; struct Foo { template ToMix(){ ~this(){i;}} ~this(){++i;} mixin ToMix; } void main() { Foo* foo = new Foo; foo.__xdtor; assert(i==3); Foo* other = new Foo; foo.__dtor;

Re: __dtor vs __xdtor

2017-08-11 Thread bitwise via Digitalmars-d-learn
On Friday, 11 August 2017 at 17:02:20 UTC, HyperParrow wrote: On Friday, 11 August 2017 at 16:53:02 UTC, bitwise wrote: What do they do? What's the difference? Thanks __xdtor() also calls the __dtor() that are mixed with template mixins while __dtor() only call the __dtor() that matches to

__dtor vs __xdtor

2017-08-11 Thread bitwise via Digitalmars-d-learn
What do they do? What's the difference? Thanks

Re: lambda function with "capture by value"

2017-08-06 Thread bitwise via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote: If a lambda function uses a local variable, that variable is captured using a hidden this-pointer. But this capturing is always by reference. Example: int i = 1; auto dg = (){ writefln("%s", i); }; i = 2; dg(); //

Re: returning D string from C++?

2017-08-06 Thread bitwise via Digitalmars-d-learn
On Sunday, 6 August 2017 at 16:46:40 UTC, Mike Parker wrote: On Sunday, 6 August 2017 at 16:23:01 UTC, bitwise wrote: So I guess you're saying I'm covered then? I guess there's no reason I can think of for the GC to stop scanning at the language boundary, let alone any way to actually do that

Re: returning D string from C++?

2017-08-06 Thread bitwise via Digitalmars-d-learn
On Sunday, 6 August 2017 at 05:31:51 UTC, Marco Leise wrote: Am Sat, 05 Aug 2017 20:17:23 + schrieb bitwise : [...] In due diligence, you are casting an ANSI string into a UTF-8 string which will result in broken Unicode for non-ASCII window titles. In any case it is

Re: returning D string from C++?

2017-08-06 Thread bitwise via Digitalmars-d-learn
On Saturday, 5 August 2017 at 21:18:29 UTC, Jeremy DeHaan wrote: On Saturday, 5 August 2017 at 20:17:23 UTC, bitwise wrote: I have a Windows native window class in C++, and I need a function to return the window title. [...] As long as you have a reachable reference to the GC memory

returning D string from C++?

2017-08-05 Thread bitwise via Digitalmars-d-learn
I have a Windows native window class in C++, and I need a function to return the window title. So in D, I have this: // isn't D's ABI stable enough to just return this from C++ // and call it a string in the extern(C++) interface? anyways.. struct DString { size_t length;

Re: Mallocator and 'shared'

2017-02-12 Thread bitwise via Digitalmars-d-learn
On Saturday, 11 February 2017 at 04:32:37 UTC, Michael Coulombe wrote: On Friday, 10 February 2017 at 23:57:18 UTC, bitwise wrote: [...] A shared method means that it can only be called on a shared instance of the struct/class, which will have shared fields. A shared method should be

Mallocator and 'shared'

2017-02-10 Thread bitwise via Digitalmars-d-learn
https://github.com/dlang/phobos/blob/cd7846eb96ea7d2fa65ccb04b4ca5d5b0d1d4a63/std/experimental/allocator/mallocator.d#L63-L65 Looking at Mallocator, the use of 'shared' doesn't seem correct to me. The logic stated in the comment above is that 'malloc' is thread safe, and therefore all

Re: struct: default construction or lazy initialization.

2017-02-01 Thread bitwise via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 23:24:27 UTC, kinke wrote: It's not that bad. D just doesn't support a default ctor for structs at all and simply initializes each instance with T.init. Your `s2` initialization is most likely seen as explicit default initialization (again with T.init).

Re: struct: default construction or lazy initialization.

2017-02-01 Thread bitwise via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 01:52:40 UTC, Adam D. Ruppe wrote: On Wednesday, 1 February 2017 at 00:43:39 UTC, bitwise wrote: Container!int c; // = Container!int() -> can't do this. Can you live with Container!int c = Container!int.create(); because D supports that and can force the

Re: struct: default construction or lazy initialization.

2017-01-31 Thread bitwise via Digitalmars-d-learn
C#'s "Dispose" pattern comes to mind here. You don't leak memory, you just leak file handles and graphics resources instead when you forget to explicitly call Dispose().

Re: struct: default construction or lazy initialization.

2017-01-31 Thread bitwise via Digitalmars-d-learn
On Tuesday, 31 January 2017 at 23:52:31 UTC, Ali Çehreli wrote: On 01/31/2017 03:15 PM, bitwise wrote: [...] Thanks for the response, but this doesn't really solve the problem. > If the object is defined at module scope as shared static > immutable It is indeed possible to initialize

struct: default construction or lazy initialization.

2017-01-31 Thread bitwise via Digitalmars-d-learn
Unless I'm missing something, it seems that neither of these are actually possible. Consider an object which needs internal state to function. The obvious answer is to create it in the constructor: struct Foo(T) { T* payload; this() { payload =

Re: returning 'ref inout(T)' - not an lvalue?

2017-01-25 Thread bitwise via Digitalmars-d-learn
On Wednesday, 25 January 2017 at 21:04:50 UTC, Adam D. Ruppe wrote: On Wednesday, 25 January 2017 at 20:42:52 UTC, bitwise wrote: Is it not possible to return a ref from an inout function? It isn't the inout that's getting you, it is the const object in main(). const(List!int) c; Make

Re: Safely moving structs in D

2017-01-25 Thread bitwise via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 11:46:47 UTC, Jonathan M Davis wrote: On Monday, January 23, 2017 22:26:58 bitwise via Digitalmars-d-learn wrote: [...] Moving structs is fine. The postblit constructor is for when they're copied. A copy is unnecessary if the original isn't around anymore

returning 'ref inout(T)' - not an lvalue?

2017-01-25 Thread bitwise via Digitalmars-d-learn
Compiling the code below gives these errors: main.d(92): Error: cast(inout(int))this.list.data[cast(uint)(this.pos + i)] is not an lvalue main.d(101): Error: template instance main.Iterator!(const(List!int)) error instantiating main.d(108): instantiated from here: first!(const(List!int))

Re: Safely moving structs in D

2017-01-23 Thread bitwise via Digitalmars-d-learn
On Monday, 23 January 2017 at 23:04:45 UTC, Ali Çehreli wrote: On 01/23/2017 02:58 PM, bitwise wrote: I'm confused about what the rules would be here. It would make sense to call the postblit if present, but std.Array currently does not:

Re: Safely moving structs in D

2017-01-23 Thread bitwise via Digitalmars-d-learn
I'm confused about what the rules would be here. It would make sense to call the postblit if present, but std.Array currently does not: https://github.com/dlang/phobos/blob/04cca5c85ddf2be25381fc63c3e941498b17541b/std/container/array.d#L884

Safely moving structs in D

2017-01-23 Thread bitwise via Digitalmars-d-learn
Is it ok to memcpy/memmove a struct in D? Quote from here: https://dlang.org/spec/garbage.html "Do not have pointers in a struct instance that point back to the same instance. The trouble with this is if the instance gets moved in memory, the pointer will point back to where it came from,

Re: Threading Questions

2015-10-08 Thread bitwise via Digitalmars-d-learn
On Thursday, 8 October 2015 at 10:11:38 UTC, Kagamin wrote: On Thursday, 8 October 2015 at 02:31:24 UTC, bitwise wrote: If you have System.Collections.Generic.List(T) static class member, there is nothing wrong with using it from multiple threads like this: The equivalent of your D example

Re: Threading Questions

2015-10-08 Thread bitwise via Digitalmars-d-learn
On Thursday, 8 October 2015 at 20:42:46 UTC, Kagamin wrote: On Thursday, 8 October 2015 at 13:44:46 UTC, bitwise wrote: That still doesn't explain what you mean about it being illegal in other languages or why you brought up C# in the first place. Illegal means the resulting program behaves

Re: Threading Questions

2015-10-07 Thread bitwise via Digitalmars-d-learn
On Wednesday, 7 October 2015 at 09:09:36 UTC, Kagamin wrote: On Sunday, 4 October 2015 at 04:24:55 UTC, bitwise wrote: I use C#(garbage collected) for making apps/games, and while, _in_theory_, the GC is supposed to protect you from leaks, memory is not the only thing that can leak. Threads

Re: Threading Questions

2015-10-05 Thread bitwise via Digitalmars-d-learn
On Monday, 5 October 2015 at 00:23:21 UTC, Jonathan M Davis wrote: On Sunday, October 04, 2015 14:42:48 bitwise via Digitalmars-d-learn wrote: Since D is moving towards a phobos with no GC, what will happen to things that are classes like Condition and Mutex? Phobos and druntime will always

Re: Threading Questions

2015-10-05 Thread bitwise via Digitalmars-d-learn
On Monday, 5 October 2015 at 20:18:18 UTC, Laeeth Isharc wrote: On Monday, 5 October 2015 at 17:40:24 UTC, bitwise wrote: You may be right. I wrote a simple download manager in D using message passing. It was a little awkward at first, but in general, the spawn/send/receive API seems very

Re: Threading Questions

2015-10-04 Thread bitwise via Digitalmars-d-learn
On Wednesday, 30 September 2015 at 10:32:01 UTC, Jonathan M Davis wrote: On Tuesday, September 29, 2015 22:38:42 Johannes Pfau via Digitalmars-d-learn wrote: [...] What I took from the answers to that SO question was that in general, it really doesn't matter whether a condition variable has

Re: Threading Questions

2015-10-04 Thread bitwise via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 23:20:31 UTC, Steven Schveighoffer wrote: yeah, that could probably be done. One thing to note is that these classes are from ages ago (probably close to 10 years). New API suggestions may be allowed. -Steve I'm still thinking about my last rant, here...

Re: Threading Questions

2015-10-03 Thread bitwise via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 19:10:58 UTC, Steven Schveighoffer wrote: An object that implements the Monitor interface may not actually be a mutex. For example, a pthread_cond_t requires a pthread_mutex_t to operate properly. Right! I feel like I should have caught the fact that

Re: Threading Questions

2015-09-28 Thread bitwise via Digitalmars-d-learn
On Monday, 28 September 2015 at 11:47:38 UTC, Russel Winder wrote: I hadn't answered as I do not have answers to the questions you ask. My reason: people should not be doing their codes using these low-level shared memory techniques. Data parallel things should be using the std.parallelism

Threading Questions

2015-09-25 Thread bitwise via Digitalmars-d-learn
Hey, I've got a few questions if anybody's got a minute. I'm trying to wrap my head around the threading situation in D. So far, things seem to be working as expected, but I want to verify my solutions. 1) Are the following two snippets exactly equivalent(not just in observable behaviour)?

Re: Threading Questions

2015-09-25 Thread bitwise via Digitalmars-d-learn
Pretty please? :)

Re: Calling DLL coded in D from Java

2015-06-16 Thread bitwise via Digitalmars-d-learn
On Tue, 16 Jun 2015 18:47:03 -0400, DlangLearner bystan...@gmail.com wrote: I'd like to know if it is possible to call an DLL coded in D from Java? What you're looking for is JNI (Java Native Interface). If you export your D functions correctly, as you have done(extern(C) export) then

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread bitwise via Digitalmars-d-learn
On Sat, 13 Jun 2015 08:21:50 -0400, ketmar ket...@ketmar.no-ip.org wrote: On Fri, 12 Jun 2015 20:41:59 -0400, bitwise wrote: Is there a way to compile for multiple conditions? Tried all these: version(One | Two){ } version(One || Two){ } version(One Two){ } version(One) | version(Two){ }

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread bitwise via Digitalmars-d-learn
On Sat, 13 Jun 2015 12:20:40 -0400, ketmar ket...@ketmar.no-ip.org wrote: On Sat, 13 Jun 2015 13:49:49 +, anonymous wrote: Taking it one step further: template Version(string name) { mixin( version(~name~) enum Version = true; else enum Version = false; ); }

Conditional Compilation Multiple Versions

2015-06-12 Thread bitwise via Digitalmars-d-learn
Is there a way to compile for multiple conditions? Tried all these: version(One | Two){ } version(One || Two){ } version(One Two){ } version(One) | version(Two){ } version(One) || version(Two){ } version(One) version(Two){ } Bit

Re: Conditional Compilation Multiple Versions

2015-06-12 Thread bitwise via Digitalmars-d-learn
On Fri, 12 Jun 2015 20:55:51 -0400, Márcio Martins marcio...@gmail.com wrote: I know... I too hate that one can't use simple logic ops... Indeed... Thanks. Bit

Re: GC Destruction Order

2015-05-20 Thread bitwise via Digitalmars-d-learn
On Wednesday, 20 May 2015 at 08:01:46 UTC, Kagamin wrote: On Tuesday, 19 May 2015 at 22:15:18 UTC, bitwise wrote: Thanks for confirming, but given your apparent tendency toward pinhole view points, it's unsurprising that you don't understand what I'm asking. And what you're asking. Just for

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 19:03:02 -0400, bitwise bitwise@gmail.com wrote: Maybe I worded that incorrectly, but my point is that when you're running with the GC disabled, you should only use methods marked with @nogc if you want to make sure your code doesn't leak right? that's a lot of

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 19:16:14 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Tuesday, 19 May 2015 at 23:10:21 UTC, bitwise wrote: which is why I am asking if there are any plans to implement something like @nogc for entire modules or classes. At the top: @nogc: stuff here

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Tuesday, 19 May 2015 at 18:15:06 UTC, bitwise wrote: Is this also true for D? Yes. The GC considers all the unreferenced memory dead at the same time and may clean up the class and its members in any

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 17:52:36 -0400, rsw0x anonym...@anonymous.com wrote: On Tuesday, 19 May 2015 at 21:07:52 UTC, bitwise wrote: Any idea what the plans are?. Does RefCounted become thread safe? Correct me if I'm wrong though, but even if RefCounted itself was thread-safe, RefCounted

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 15:36:21 -0400, rsw0x anonym...@anonymous.com wrote: On Tuesday, 19 May 2015 at 18:37:31 UTC, bitwise wrote: On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Tuesday, 19 May 2015 at 18:15:06 UTC, bitwise wrote: Is this also true for

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 18:47:26 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On 5/19/15 5:07 PM, bitwise wrote: On Tue, 19 May 2015 15:36:21 -0400, rsw0x anonym...@anonymous.com wrote: On Tuesday, 19 May 2015 at 18:37:31 UTC, bitwise wrote: On Tue, 19 May 2015 14:19:30 -0400,

GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
In C#, it's possible that class members can actually be destroyed before the containing object. Example: class Stuff { Class1 thing1; Class2 thing2; ~Stuff() { thing1.DoSomeFinalization(); // [1] } } I forget what the exact behavior was, but basically, [1] is

Re: GC Destruction Order

2015-05-19 Thread bitwise via Digitalmars-d-learn
On Tue, 19 May 2015 14:55:55 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On 5/19/15 2:37 PM, bitwise wrote: On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Tuesday, 19 May 2015 at 18:15:06 UTC, bitwise wrote: Is this also true for D? Yes.

Re: how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
On Sat, 09 May 2015 21:32:42 -0400, Mike n...@none.com wrote: it looks like what you are trying to implement is what `synchronized` already provides: http://ddili.org/ders/d.en/concurrency_shared.html#ix_concurrency_shared.synchronized Mike Yes, but synchronized uses a mutex. Spin locks

Re: how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
On Sat, 09 May 2015 15:38:05 -0400, Mike n...@none.com wrote: On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful. Here are a few interesting links: Iain Buclaw (lead

Re: how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
On Sat, 09 May 2015 15:59:57 -0400, tcak t...@gmail.com wrote: If a variable/class/struct etc is not shared, for variables and struct, you find their initial value. For class, you get null. For first timers (I started using shared keyword more than 2 years ago), do not forget that: a shared

how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
What does 'shared' do to member variables? It makes sense to me to put it on a global variable, but what sense does it make putting it on a member of a class? What happens if you try to access a member of a class/struct instance from another thread that is not marked 'shared'? Also, I

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 18:58:34 -0400, Namespace rswhi...@gmail.com wrote: On Tuesday, 5 May 2015 at 21:58:57 UTC, bitwise wrote: On Tue, 05 May 2015 17:33:09 -0400, Namespace rswhi...@gmail.com wrote: I've discussed that so many times... just search for auto / scope ref... ;) It will never

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 00:20:15 -0400, rsw0x anonym...@anonymous.com wrote: it does, auto ref can bind to both lvalues and rvalues. Create the function with an empty template like so, import std.stdio; struct S{ } void Foo()(auto ref S s){ } void main(){ S s; Foo(s);

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 10:44:13 -0400, rsw0x anonym...@anonymous.com wrote: On Tuesday, 5 May 2015 at 14:14:51 UTC, bitwise wrote: Interesting.. Has this always worked? Theres a couple of forum conversations about trying to get auto ref to work for non-templates. The main problem seems to be

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 18:27:54 -0400, Gomen go...@asai.jp wrote: I am sorry for this post, I am just testing something. The retired D forum seems to have been re-purposed for testing ;) Bit

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 17:33:09 -0400, Namespace rswhi...@gmail.com wrote: I've discussed that so many times... just search for auto / scope ref... ;) It will never happen. See: http://forum.dlang.org/thread/ntsyfhesnywfxvzbe...@forum.dlang.org?page=1

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 14:49:07 -0400, Ali Çehreli acehr...@yahoo.com wrote: http://ddili.org/ders/d.en/lvalue_rvalue.html#ix_lvalue_rvalue.auto%20ref,%20parameter I've actually stumbled upon this site a few times, and it has been very helpful, so thanks =D Unfortunately though, I had no idea

Re: Efficiently passing structs

2015-05-05 Thread bitwise via Digitalmars-d-learn
On Tue, 05 May 2015 11:54:53 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Tuesday, 5 May 2015 at 02:47:03 UTC, bitwise wrote: On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D will move the argument if it can

Re: Efficiently passing structs

2015-05-04 Thread bitwise via Digitalmars-d-learn
On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need for worrying about copying like you tend to have to do

  1   2   >