Re: How to create nogc code?

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/11/2016 02:31 AM, Adam Sansier wrote: idup uses the gc, I am currently just malloc'ing the string and allowing for the memory leak. This is somewhat acceptable given that this code should rarely be called and generally only at startup. It will generally waste only a few KB of memory. If

Re: How to create nogc code?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 02:35:13 UTC, Jonathan M Davis wrote: On Monday, July 11, 2016 01:16:11 Adam Sansier via Digitalmars-d-learn wrote: [...] It's more a case that you're just making life harder for yourself if you avoid the GC. Some programs (like AAA games) are going to need to

Re: How to create nogc code?

2016-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 11, 2016 01:16:11 Adam Sansier via Digitalmars-d-learn wrote: > Thanks. I'd rather prematurely optimize out the gc then have to > go back and get it to work. It's not hard to write non-gc code, > it's been done for ages. But having some compiler help makes > things nice. It seems

Re: how to mark an extern function @nogc?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 01:58:23 UTC, Adam Sansier wrote: I'm using some win functions that don't use the gc and are not marked, specifically CLSIDFromString that I imported myself(it's not marked nogc in objbase). I went ahead and copied the import and added nogc. Shouldn't someone add

how to mark an extern function @nogc?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
I'm using some win functions that don't use the gc and are not marked, specifically CLSIDFromString that I imported myself(it's not marked nogc in objbase).

Re: How to create nogc code?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Monday, 11 July 2016 at 01:08:16 UTC, Jonathan M Davis wrote: On Monday, July 11, 2016 00:37:39 Adam Sansier via Digitalmars-d-learn wrote: [...] When manually managing memory, you're dealing with basically the same constructs that you would have in C/C++. I mean, you're even using the

Re: How to create nogc code?

2016-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 11, 2016 00:37:39 Adam Sansier via Digitalmars-d-learn wrote: > Also, When dealing with a complex tree like structure, is there > an easy way to recursively free it by free'ing all the sub > elements? When manually managing memory, you're dealing with basically the same constructs

Re: How to create nogc code?

2016-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 11, 2016 00:31:10 Adam Sansier via Digitalmars-d-learn wrote: > So, I have to create some nogc code. Basically all it uses is > idup to create a string that is passed as a return value. It > seems this is necessary or the string will be reused and > corrupted. > > idup uses the gc,

Re: How to create nogc code?

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
Also, When dealing with a complex tree like structure, is there an easy way to recursively free it by free'ing all the sub elements? Also, since I'm dealing with simple structs and strings, maybe I more intelligent string type can be used? One that uses opAssign to do reference counting? I

Re: mutable string

2016-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 10, 2016 23:38:26 ag0aep6g via Digitalmars-d-learn wrote: > On 07/10/2016 11:26 PM, Adam Sansier wrote: > > For example, I'm trying to compare a wchar buffer with a wstring using > > slices: > > > > x[0..$] == y[0..$] > > > > It fails. I think because x has length 1024. If do > > >

Re: Defining and overriding methods of an abstract base class which must accept a template parameter

2016-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 10, 2016 21:27:14 pineapple via Digitalmars-d-learn wrote: > On Sunday, 10 July 2016 at 21:20:34 UTC, Basile B. wrote: > > The problem you encounter here is that templatized functions > > cannot be virtual. If you remove "abstract" and put an empty > > body than it works, but you

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 11:38 PM, Adam Sansier wrote: Using this code import core.stdc.wchar_; // For wcslen. Hint: D has special syntax for importing only specific parts of a module: import core.std.wchar_: wcslen; wstring toWstring(wchar[] value) { return value ? cast(wstring)

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 11:26 PM, Adam Sansier wrote: For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since it was generated

Re: Defining and overriding methods of an abstract base class which must accept a template parameter

2016-07-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:27:14 UTC, pineapple wrote: On Sunday, 10 July 2016 at 21:20:34 UTC, Basile B. wrote: The problem you encounter here is that templatized functions cannot be virtual. If you remove "abstract" and put an empty body than it works, but you lose the whole OOP thing,

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:26:29 UTC, Adam Sansier wrote: For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 11:17 PM, Adam Sansier wrote: The problem is things like https://msdn.microsoft.com/en-us/library/windows/desktop/ms724902(v=vs.85).aspx require data buffers to be used. I can't just plug in a wstring to it, can I? You can't. `First-chance exception:

Re: Defining and overriding methods of an abstract base class which must accept a template parameter

2016-07-10 Thread pineapple via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:20:34 UTC, Basile B. wrote: The problem you encounter here is that templatized functions cannot be virtual. If you remove "abstract" and put an empty body than it works, but you lose the whole OOP thing, i.e you cannot call the most derived override from the base.

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
For example, I'm trying to compare a wchar buffer with a wstring using slices: x[0..$] == y[0..$] It fails. I think because x has length 1024. If do x[0..y.length] == str[0..y.length] it fails, also because y has length 1024(since it was generated from a buffer and the length wasn't set

Re: Defining and overriding methods of an abstract base class which must accept a template parameter

2016-07-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:20:34 UTC, Basile B. wrote: On Sunday, 10 July 2016 at 21:06:42 UTC, pineapple wrote: [...] It comes from the fact that the VTBL cannot be build from a template. See https://issues.dlang.org/show_bug.cgi?id=1657#c1

Re: Defining and overriding methods of an abstract base class which must accept a template parameter

2016-07-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 July 2016 at 21:06:42 UTC, pineapple wrote: This is essentially what I'm trying to accomplish. The intuitive solution, of course, does not work. In theory I could write a separate method for every anticipated return type, but that would be horrible and in that case I'd probably

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 20:31:34 UTC, Lodovico Giaretta wrote: On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar

Re: local const functions - bug ?

2016-07-10 Thread Basile B. via Digitalmars-d-learn
On Sunday, 10 July 2016 at 07:20:29 UTC, Meta wrote: On Friday, 8 July 2016 at 09:01:10 UTC, Marc Schütz wrote: `foo()` is effectively a delegate, therefore `const` applies to the context. AFAIK const on a function can only ever refer to the `this` pointer, but there is no `this` pointer.

Defining and overriding methods of an abstract base class which must accept a template parameter

2016-07-10 Thread pineapple via Digitalmars-d-learn
This is essentially what I'm trying to accomplish. The intuitive solution, of course, does not work. In theory I could write a separate method for every anticipated return type, but that would be horrible and in that case I'd probably just write the damn thing in a dynamically-typed language

Re: mutable string

2016-07-10 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2016 10:31 PM, Lodovico Giaretta wrote: That said, if you want char[] -> string or wchar[] -> wstring you can use assumeUnique, which casts a mutable array to an immutable one. After having ensured that the array is actually unique. That is, there must not be any other references to

Re: mutable string

2016-07-10 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than

Re: mutable string

2016-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:50:28 UTC, Adam Sansier wrote: But I need to compare the results, case insensitive, to a string(since that is what D uses). It's being a real pain in the butt to deal with the mixture. Are your strings literals or generated somewhere else? You can stick a w at

Re: mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:44:01 UTC, Adam D. Ruppe wrote: On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? What string functions in particular? If

Re: mutable string

2016-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 10 July 2016 at 19:19:57 UTC, Adam Sansier wrote: Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? What string functions in particular? If they are written correctly, it should just work mutable

mutable string

2016-07-10 Thread Adam Sansier via Digitalmars-d-learn
Is it possible to turn temporary char/wchar buffer in to a string to be used by string functions rather than having to convert? I'm working with win32 and have to use char*'s. This requires a lot of in place case conversions and comparisons and such. I want to avoid the gc too. I could use

Re: Asio Bindings?

2016-07-10 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 11 June 2016 at 04:11:59 UTC, Joerg Joergonson wrote: Are you using any of their source code from the vst sdk? If you hand re-write any of their source code, it is yours. That could actually be considered to be a translation and a derived work. If you implement from a

Re: Asio Bindings?

2016-07-10 Thread Smoke Adams via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 23:19:13 UTC, Andrej Mitrovic wrote: I do have (Steinberg) ASIO binding in D. The problem is I couldn't release the bindings. I've asked Steinberg if it was OK to release D bindings and they were strongly against it unfortunately (and this was over 3 years

Re: Singleton Pattern

2016-07-10 Thread yawniek via Digitalmars-d-learn
On Thursday, 5 January 2012 at 22:15:32 UTC, asm wrote: how can i implementing the singleton pattern in D? https://p0nce.github.io/d-idioms/#Leveraging-TLS-for-a-fast-thread-safe-singleton

Re: Dub recursive build and forcing pre-build commands to run

2016-07-10 Thread Antonio Corbi via Digitalmars-d-learn
On Sunday, 10 July 2016 at 07:00:18 UTC, Meta wrote: On Saturday, 9 July 2016 at 07:52:56 UTC, Antonio Corbi wrote: I use the "preGenerateCommands" and "dependencies" like this: "configurations" : [ { "comment" : "Classic app.", "name"

Re: local const functions - bug ?

2016-07-10 Thread Meta via Digitalmars-d-learn
On Friday, 8 July 2016 at 09:01:10 UTC, Marc Schütz wrote: `foo()` is effectively a delegate, therefore `const` applies to the context. AFAIK const on a function can only ever refer to the `this` pointer, but there is no `this` pointer.

Re: Dub recursive build and forcing pre-build commands to run

2016-07-10 Thread Meta via Digitalmars-d-learn
On Saturday, 9 July 2016 at 07:52:56 UTC, Antonio Corbi wrote: I use the "preGenerateCommands" and "dependencies" like this: "configurations" : [ { "comment" : "Classic app.", "name": "eqapp", "preGenerateCommands" :

Re: Singleton Pattern

2016-07-10 Thread Suliman via Digitalmars-d-learn
On Saturday, 9 July 2016 at 20:47:32 UTC, Ali Çehreli wrote: On 07/09/2016 01:35 PM, Suliman wrote: > On Thursday, 5 January 2012 at 22:53:12 UTC, Ali Çehreli wrote: >> On 01/05/2012 02:15 PM, asm wrote: >>> how can i implementing the singleton pattern in D? >> >> Is singleton still alive? ;)