is char[] faster than string?

2017-04-05 Thread Inquie via Digitalmars-d-learn
I have a lot of string concatenation to do and I'm wondering if char[] is faster? Does it simply extend the buffer or are new buffers created every time? What I am looking for is something like StringBuilder in C#.

Re: Single exe vibe.d app

2017-04-05 Thread Inquie via Digitalmars-d-learn
On Wednesday, 5 April 2017 at 12:42:23 UTC, evilrat wrote: On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote: Hi, How can I build single exe application with vibe.d (windows)? now it require zlib.dll, libeay32.dll and ssleay32.dll But I need it as single app. btw, if all you need is

opDispatch/template get this

2017-04-03 Thread Inquie via Digitalmars-d-learn
I am using opDispatch to wrap function calls Error: 'this' is only defined in non-static member functions, not opDispatch!"foo" class X { auto localfoo() { return 3; } template opDispatch(string name, Args...) { static if (name == `foo`) { alias opDispatch = () { return

Re: Write file at compile time?

2017-04-03 Thread Inquie via Digitalmars-d-learn
On Monday, 3 April 2017 at 19:34:36 UTC, Adam D. Ruppe wrote: On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote: what if I don't care about security reasons? I'm only needing it for developmental purposes. Why does it have to be at compile time then? Just run an ordinary runtime program

Re: Write file at compile time?

2017-04-03 Thread Inquie via Digitalmars-d-learn
On Monday, 3 April 2017 at 19:06:01 UTC, Meta wrote: On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote: I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible? D does not allow IO at compile time for

Re: delegate with optional parameters

2017-04-02 Thread Inquie via Digitalmars-d-learn
On Monday, 3 April 2017 at 03:08:22 UTC, Ali Çehreli wrote: On 04/02/2017 03:24 PM, Inquie wrote: >> Show a usage, someone certainly propose a pattern that does the job. > > int delegate() f; > void delegate(int) f; That won't work because both of those are variables and variables don't have

Re: delegate with optional parameters

2017-04-02 Thread Inquie via Digitalmars-d-learn
On Sunday, 2 April 2017 at 21:47:55 UTC, Basile B. wrote: On Sunday, 2 April 2017 at 20:48:09 UTC, Inquie wrote: On Sunday, 2 April 2017 at 20:02:56 UTC, Basile B. wrote: On Sunday, 2 April 2017 at 19:24:14 UTC, Inquie wrote: is it possible to create a delegate that takes an optional number

Re: delegate with optional parameters

2017-04-02 Thread Inquie via Digitalmars-d-learn
On Sunday, 2 April 2017 at 20:02:56 UTC, Basile B. wrote: On Sunday, 2 April 2017 at 19:24:14 UTC, Inquie wrote: is it possible to create a delegate that takes an optional number of parameters and/or return type? T delegate(S...)(S) special_delegate; I guess this is impossible? alias

Write file at compile time?

2017-04-02 Thread Inquie via Digitalmars-d-learn
I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?

delegate with optional parameters

2017-04-02 Thread Inquie via Digitalmars-d-learn
is it possible to create a delegate that takes an optional number of parameters and/or return type? T delegate(S...)(S) special_delegate; I guess this is impossible?

Re: Building DMD

2017-03-31 Thread Inquie via Digitalmars-d-learn
On Saturday, 1 April 2017 at 00:12:10 UTC, Inquie wrote: So, I rebuilt everything again from scratch, I fixed up the make files and such and everything went smooth. I was able to not have the errors. [...] I was able to solve the comdat problem by moving a local function outside a

Re: Building DMD

2017-03-31 Thread Inquie via Digitalmars-d-learn
So, I rebuilt everything again from scratch, I fixed up the make files and such and everything went smooth. I was able to not have the errors. I think what I did first was I built dmdx64 then copied it to the bin dir and tried to use it but got the phobos errors. I then tried to build

Re: Building DMD

2017-03-31 Thread Inquie via Digitalmars-d-learn
On Friday, 31 March 2017 at 14:24:43 UTC, Stefan Koch wrote: On Friday, 31 March 2017 at 14:19:59 UTC, Inquie wrote: On Friday, 31 March 2017 at 08:20:51 UTC, Nicholas Wilson wrote: [...] Yes, I downloaded druntime from github and built it as I did phobos. The 64-bit make files have issues

Re: Building DMD

2017-03-31 Thread Inquie via Digitalmars-d-learn
On Friday, 31 March 2017 at 08:20:51 UTC, Nicholas Wilson wrote: On Friday, 31 March 2017 at 07:23:42 UTC, Inquie wrote: I am trying to build DMD 64-bit. I was able to build everything after getting the paths fixed for zlib, druntime, and phobos. Everything seems to compile. I replaced all the

Building DMD

2017-03-31 Thread Inquie via Digitalmars-d-learn
I am trying to build DMD 64-bit. I was able to build everything after getting the paths fixed for zlib, druntime, and phobos. Everything seems to compile. I replaced all the files generated in to the dmd directories of the old ones. (phobos64.lib, gcstub.obj, dmd.exe) But anytime I build my

64-bit DMD

2017-03-30 Thread Inquie via Digitalmars-d-learn
Is there a 64-bit DMD compiler that doesn't have the 2GB memory limitations that the 32-bit one has? I am not talking about compiling 64-bit programs but the dmd binary itself.

Re: debug mixins

2017-03-15 Thread Inquie via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 03:50:21 UTC, Jonathan M Davis wrote: On Wednesday, March 15, 2017 03:43:20 Inquie via Digitalmars-d-learn wrote: [...] Related: https://issues.dlang.org/show_bug.cgi?id=5051 - Jonathan M Davis So, after 3 years, nothing?

Re: strange CFTE issue

2017-03-15 Thread Inquie via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 03:40:42 UTC, ag0aep6g wrote: On 03/15/2017 03:01 AM, Inquie wrote: If I do something like enum X = Methods!(C); foreach(x; X) { mixin(x); } I get an error about x not being a compile time variable. (code above is simplified, the error has nothing to do

Re: scope(~this)

2017-03-15 Thread Inquie via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 08:17:11 UTC, thedeemon wrote: On Tuesday, 14 March 2017 at 14:35:11 UTC, Inquie wrote: There is really no any arrays to keep track of or anything like that matter you stated. ... 3 steps: ... 3. The compiler calls all the delegates on destruction. Here you

debug mixins

2017-03-14 Thread Inquie via Digitalmars-d-learn
So, is it possible to debug string mixins? I ran visual D and tried to step in to a function that was generated by a mixin and it brought an open file dialog box asking me to load the source code where the function was located... of course, it wasn't located anywhere except in the mixin

strange CFTE issue

2017-03-14 Thread Inquie via Digitalmars-d-learn
If I do something like enum X = Methods!(C); foreach(x; X) { mixin(x); } I get an error about x not being a compile time variable. (code above is simplified, the error has nothing to do with the form but of the foreach(x ) but if I wrap it in a function it works string foo() { enum X

Re: code folding

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 20:56:02 UTC, Ali Çehreli wrote: On 03/13/2017 10:29 AM, Inquie wrote: Does D have any nice way to specify a block for cold folding? I have a very large set of structs and I'd like to be able to code fold them all at once and together. I have been using static

Re: Filter out common object functions

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 19:43:59 UTC, Adam D. Ruppe wrote: On Tuesday, 14 March 2017 at 19:39:26 UTC, Inquie wrote: __traits(allMembers, T); Try derivedMembers instead. That doesn't work, unfortunately, probably because of the types I'm using(just returns object. What I can do is

Filter out common object functions

2017-03-14 Thread Inquie via Digitalmars-d-learn
I am iterating over the members of classes and interfaces and get things like hash, this, etc. These are causing problems in my code. I would like to get only the "specified" members. While I can filter out __traits(allMembers, T); using Erase, it is tedius and error prone. Is there a way

Re: Function pointer pitfalls

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 19:14:34 UTC, H. S. Teoh wrote: On Tue, Mar 14, 2017 at 06:59:58PM +, Inquie via Digitalmars-d-learn wrote: [...] [...] > [...] [...] [...] [...] Keep in mind, though, that the above creates a function pointer with the same signature as the mem

Re: Function pointer pitfalls

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 17:42:34 UTC, H. S. Teoh wrote: On Tue, Mar 14, 2017 at 05:05:10PM +, Inquie via Digitalmars-d-learn wrote: I am generating member function pointers using the declaration specified from a standard member function. The standard member function is a valid D

Inline mixin

2017-03-14 Thread Inquie via Digitalmars-d-learn
Many times I need to build a type using a string. I have to resort to building the entire expression/statement using the mixin: mixin("This is a long and complex expression where I only need to modify X") Is there any way to do a sort of "inline mixin"? This is a long and complex

Re: code folding

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 17:07:57 UTC, Adam D. Ruppe wrote: On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote: Does D have any nice way to specify a block for cold folding? I personally sometimes use // some description { // } since my editor does a really good job matching {},

Function pointer pitfalls

2017-03-14 Thread Inquie via Digitalmars-d-learn
I am generating member function pointers using the declaration specified from a standard member function. The standard member function is a valid D function that could use any types. Is there any pitfalls like there are in C++ from generating a function pointer from them? e.g., X

Re: code folding

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 16:29:15 UTC, Mike Parker wrote: On Tuesday, 14 March 2017 at 15:44:27 UTC, Inquie wrote: So, with all the bloviating, all I have arrived at is that my original hack is still the only way to get the cold folding I wanted(the original use case I had in mind, even

Re: code folding

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 15:18:00 UTC, bachmeier wrote: On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev wrote: FYI: The "you must implement my feature request or D will never succeed" attitude is rather common and never helpful. Not to mention that such an argument would be

Re: code folding

2017-03-14 Thread Inquie via Digitalmars-d-learn
Just for fun: 1. Folding directives are glorified comments. #region has zero meaning to the compiler; it's a hint to the editor to allow code folding. It doesn't do any namespacing or scoping. Why, exactly, are we writing code to accommodate the editor? It boggles my mind that we'd add

Re: code folding

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev wrote: On Monday, 13 March 2017 at 21:33:56 UTC, Inquie wrote: One can say that it is a useless feature because D doesn't have it... or one could say that D is useless because it doesn't have it. A nice balance is simply to say "It

Re: scope(~this)

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 05:33:28 UTC, thedeemon wrote: On Monday, 13 March 2017 at 14:28:01 UTC, Inquie wrote: On Monday, 13 March 2017 at 05:18:18 UTC, Nicholas Wilson wrote: On Sunday, 12 March 2017 at 21:38:44 UTC, Inquie wrote: Is there any easy way to create a scope for termination

Re: how to assign tuple named Tuple easily

2017-03-14 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 14:15:05 UTC, Adam D. Ruppe wrote: On Monday, 13 March 2017 at 14:09:58 UTC, Inquie wrote: Yeah, so, surely though we can extract the names from the variable and then supply those like I mentioned? Yeah, we prolly could, but a simpler thing might be to just use

Re: code folding

2017-03-13 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 21:17:31 UTC, XavierAP wrote: On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote: I have been using static if(true) { ... junk } Indeed #region is part of the C# specification, even if it has no effect on the code. (The specification does not say

Re: code folding

2017-03-13 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 18:26:22 UTC, Jonathan M Davis wrote: On Monday, March 13, 2017 17:29:41 Inquie via Digitalmars-d-learn wrote: Does D have any nice way to specify a block for cold folding? I have a very large set of structs and I'd like to be able to code fold them all at once

code folding

2017-03-13 Thread Inquie via Digitalmars-d-learn
Does D have any nice way to specify a block for cold folding? I have a very large set of structs and I'd like to be able to code fold them all at once and together. I have been using static if(true) { ... junk } but the static if is uninformative since that is the only line that is

Re: how to assign tuple named Tuple easily

2017-03-13 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 00:23:36 UTC, ag0aep6g wrote: On 03/13/2017 01:02 AM, Inquie wrote: Ok, it doesn't work for appending though ;) [...] Tuple!(int, "A", double, "B")[] y; y ~= tuple(3, 2.5); Interestingly, this works: Tuple!(int, "A", double, "B")[] y; y.length += 1;

Re: scope(~this)

2017-03-13 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 05:18:18 UTC, Nicholas Wilson wrote: On Sunday, 12 March 2017 at 21:38:44 UTC, Inquie wrote: Is there any easy way to create a scope for termination of the object? I have a template method that takes a type and allocates and deallocates based on that type. class

Re: how to assign tuple named Tuple easily

2017-03-13 Thread Inquie via Digitalmars-d-learn
On Monday, 13 March 2017 at 00:51:27 UTC, Adam D. Ruppe wrote: On Monday, 13 March 2017 at 00:02:12 UTC, Inquie wrote: I just figured it didn't work in general, but seems to be an issue with appending. Oh, it is because of the implicit construction thing, see my answer here to learn more:

Re: how to assign tuple named Tuple easily

2017-03-12 Thread Inquie via Digitalmars-d-learn
On Sunday, 12 March 2017 at 23:55:44 UTC, Adam D. Ruppe wrote: On Sunday, 12 March 2017 at 23:16:48 UTC, Inquie wrote: Tuple!(int, "A") x; x = tuple(3); fails of course umm it works for me... Ok, it doesn't work for appending though ;) Tuple!(int, "A", double, "B")[] y; y ~= tuple!("A",

Re: scope(~this)

2017-03-12 Thread Inquie via Digitalmars-d-learn
On Sunday, 12 March 2017 at 22:13:21 UTC, Stefan Koch wrote: On Sunday, 12 March 2017 at 21:38:44 UTC, Inquie wrote: Is there any easy way to create a scope for termination of the object? [...] scope(exit) That is for the function, correct? If I release the resource at the end of the

scope(~this)

2017-03-12 Thread Inquie via Digitalmars-d-learn
Is there any easy way to create a scope for termination of the object? I have a template method that takes a type and allocates and deallocates based on that type. class bar { void foo(T)() { T x; alloc(x); scope(~this) dealloc(x); // hypothetical that wraps the

Re: Accessing COM Objects

2017-03-10 Thread Inquie via Digitalmars-d-learn
On Friday, 17 June 2016 at 08:09:42 UTC, John wrote: On Wednesday, 15 June 2016 at 21:06:01 UTC, Joerg Joergonson wrote: My thinking is that CoCreateinstance is suppose to give us a pointer to the interface so we can use it, if all this stuff is crashing does that mean the interface is invalid

Re: Accessing COM Objects

2017-03-10 Thread Inquie via Digitalmars-d-learn
On Friday, 17 June 2016 at 08:09:42 UTC, John wrote: On Wednesday, 15 June 2016 at 21:06:01 UTC, Joerg Joergonson wrote: [...] The problem is Photoshop hasn't provided an interface with methods that can be called directly. They don't exist on the interface, hence them being commented out.