Re: debug mixins

2017-03-14 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 03:43:20 UTC, Inquie wrote: 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

Re: debug mixins

2017-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 15, 2017 03:43:20 Inquie via Digitalmars-d-learn wrote: > 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

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

Re: strange CFTE issue

2017-03-14 Thread ag0aep6g via Digitalmars-d-learn
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 with the form but of the foreach(x ) "Compile time variable"

Re: Declaring interfaces with a constructor

2017-03-14 Thread evilrat via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 13:54:41 UTC, David Zhang wrote: Yeah, that's the idea. Though I just thought of a possibility using an isPublicInterface template. Is that what you meant by templates and duck typing? Not sure about what that template does, but the idea behind ranges is

Re: Function Template Overloading

2017-03-14 Thread Q. Schroll via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 02:33:36 UTC, ketmar wrote: Q. Schroll wrote: void test(T)(T* arg); void test(T)(ref T arg); Let p be any pointer. Why is test(p) not an ambiguity error? Why is the second overload chosen? 'cause `ref T` is more generic than `T*`. think of it as "greedy

Re: Function Template Overloading

2017-03-14 Thread ketmar via Digitalmars-d-learn
Q. Schroll wrote: void test(T)(T* arg); void test(T)(ref T arg); Let p be any pointer. Why is test(p) not an ambiguity error? Why is the second overload chosen? 'cause `ref T` is more generic than `T*`. think of it as "greedy matching": compiler first tries to match `int*`, and if that

Function Template Overloading

2017-03-14 Thread Q. Schroll via Digitalmars-d-learn
void test(T)(T* arg); void test(T)(ref T arg); Let p be any pointer. Why is test(p) not an ambiguity error? Why is the second overload chosen? Making the first one take auto ref T* lets the compiler choose the first. Making the second one non-ref lets the compiler give me an ambiguity error.

Re: MemberDefaults trait

2017-03-14 Thread Ali Çehreli via Digitalmars-d-learn
On 10/10/2016 04:50 PM, Ali Çehreli wrote: > Could you please review the following template to see whether it makes > sense. It produces an AliasSeq type consisting of the default values of > the members of a struct. It should and does support members that are > initialized with '= void'. I could

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

Acruvex dll in D

2017-03-14 Thread Cassio Butrico via Digitalmars-d-learn
I have this activex dll in vb6 and would like to be able to use it in D CClasexp.cls Public Function Add (X As Integer, and As Integer) Add = (X + y) End Function How do i instantiate activex dll in D?

Re: code folding

2017-03-14 Thread Ali Çehreli via Digitalmars-d-learn
On 03/14/2017 02:48 PM, Inquie wrote: >> version (all) { >> // ... >> } >> >> You can define your own version identifiers as well: >> >> version = some_descriptive_name; >> >> version (some_descriptive_name) { >> // ... >> } >> >> Ali > > Oh, that might be better. I thought of versions

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: Phobos function to check if files are identical?

2017-03-14 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 18:26:52 UTC, flamencofantasy wrote: import std.mmfile; auto f1 = new MmFile("file1"); auto f2 = new MmFile("file2"); return f1[] == f2[]; Nice! I don't have experience with memory-mapped files. What are the pros and cons?

Re: code folding

2017-03-14 Thread Ali Çehreli via Digitalmars-d-learn
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 if(true) { ... junk } but the static if is uninformative

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

Re: Filter out common object functions

2017-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 19:39:26 UTC, Inquie wrote: __traits(allMembers, T); Try derivedMembers instead.

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 member

Re: Function pointer pitfalls

2017-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 14, 2017 at 06:59:58PM +, Inquie via Digitalmars-d-learn wrote: > On Tuesday, 14 March 2017 at 17:42:34 UTC, H. S. Teoh wrote: [...] > > struct X { > > int method(float x) { return 0; } > > } > > > > typeof() membptr; > > pragma(msg, typeof(membptr));

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

Re: Inline mixin

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 18:38 Inquie via Digitalmars-d-learn napsal(a): 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

Re: Phobos function to check if files are identical?

2017-03-14 Thread flamencofantasy via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 08:31:20 UTC, XavierAP wrote: On Tuesday, 14 March 2017 at 08:12:16 UTC, Andrea Fontana wrote: First I would check if the files have different size or if they are the same file (same path, symlink, etc). Good idea. Good reason to have it in std.file. There might

Re: Function pointer pitfalls

2017-03-14 Thread H. S. Teoh via Digitalmars-d-learn
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 function that could use any types. > > Is there any pitfalls

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 {},

Re: code folding

2017-03-14 Thread flamencofantasy via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 16:58:21 UTC, Inquie wrote: On Tuesday, 14 March 2017 at 16:29:15 UTC, Mike Parker wrote: [...] It's not that I feel strongly about, I simply would like the best useable solution. Like usually what happens, my original post was taken completely out of context:

Re: code folding

2017-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
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 {}, even in comments so it is convenient to jump anywhere, and i can

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: groupBy in D?

2017-03-14 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-03-14 at 16:35 +, Russel Winder wrote: > So by analogy with the Python code I get the following D code, but it seems ugly compared to the niceness of the Groovy code (and equivalent Kotlin and Ceylon codes): import std.array: array, split; import std.algorithm: filter, map;

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: Using chunks with Generator

2017-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 14, 2017 at 12:30:13PM +, Era Scarecrow via Digitalmars-d-learn wrote: > On Tuesday, 14 March 2017 at 10:00:24 UTC, Tetiana wrote: > > Build fails with the following error: > > Just looking at the Documentation, Generator is an InputRange and > chunks requires a ForwardRange

Re: code folding

2017-03-14 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 16:29:15 UTC, Mike Parker wrote: If it's something you feel strongly about, then the way to go about it is to put together a DIP. There was a time when you could open a forum post about a new feature and eventually see it added, but those days are long gone (for

Re: groupBy in D?

2017-03-14 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-03-14 at 16:12 +0100, Daniel Kozak via Digitalmars-d-learn wrote: > […] > > Can you post some example? Maybe in python, kotlin whatever so I can  > better understand what you want In my head I had something such as Groovy's files = new

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Paolo Invernizzi via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 13:32:31 UTC, Suliman wrote: On Tuesday, 14 March 2017 at 13:21:39 UTC, Paolo Invernizzi wrote: On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote: [...] I'm using ddb [1], a full-D implementation of the PostgreSQL protocol. Not everything it's in place,

Re: code folding

2017-03-14 Thread Mike Parker via Digitalmars-d-learn
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 though I'd rather have proper code structuring support in

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: Can i using D & LLVM & SDL2 for Android?

2017-03-14 Thread Joakim via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 01:57:56 UTC, rikki cattermole wrote: On 14/03/2017 6:08 AM, Joakim wrote: On Monday, 13 March 2017 at 09:33:39 UTC, rikki cattermole wrote: On 13/03/2017 7:48 PM, Joakim wrote: [...] Why exactly doesn't the Android port support dlopen, dlsym and dlclose? It

Re: code folding

2017-03-14 Thread bachmeier via Digitalmars-d-learn
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 demonstrably false: every popular language without the

Testing directory processing codes

2017-03-14 Thread Russel Winder via Digitalmars-d-learn
I am wondering how to test D functions that manipulate filestores. In Python I'd wheel out pytest and create fixtures that use tempfile module functions to create temporary directories and files. I'd also try and use Hypothesis to do some property based testing using randomly generated

Re: groupBy in D?

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 16:02 Russel Winder via Digitalmars-d-learn napsal(a): I am having a hard time Google-ing today. Pytho, Groovy, Kotlin, etc. have a "groupBy" function that takes a sequence and a key and creates a dictionary/associative array with keys the result of the key function on the

Re: listdir

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
There is no such function in D2 You can use dirEntries https://dlang.org/phobos/std_file.html#.dirEntries.2 Dne 14.3.2017 v 16:04 hadas via Digitalmars-d-learn napsal(a): Hi, I'm trying to read all the txt files in specific path. I tried to use listdir function, but I get this error: Error:

listdir

2017-03-14 Thread hadas via Digitalmars-d-learn
Hi, I'm trying to read all the txt files in specific path. I tried to use listdir function, but I get this error: Error: undefined identifier 'listdir' in module 'std.file' import std.stdio; import std.file; void main(string[] args) { auto vm_files =

groupBy in D?

2017-03-14 Thread Russel Winder via Digitalmars-d-learn
I am having a hard time Google-ing today. Pytho, Groovy, Kotlin, etc. have a "groupBy" function that takes a sequence and a key and creates a dictionary/associative array with keys the result of the key function on the sequence and key values all the items that match the key. D doesn't seem to

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: Declaring interfaces with a constructor

2017-03-14 Thread David Zhang via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 02:14:53 UTC, evilrat wrote: like this? -- [snip] - there is also way to do this using templates and duck typing, I think it will be more idiomatic way since ranges and stuff heavily use

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 14:21 Daniel Kozak napsal(a): Dne 14.3.2017 v 14:13 Suliman via Digitalmars-d-learn napsal(a): I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Suliman via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 13:21:39 UTC, Paolo Invernizzi wrote: On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote: I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Paolo Invernizzi via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote: I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible will not on x64 PG on Linux (I can't test it now).

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Daniel Kozak via Digitalmars-d-learn
Dne 14.3.2017 v 14:13 Suliman via Digitalmars-d-learn napsal(a): I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible will not on x64 PG on Linux (I can't test it

What is PostgreSQL driver is most stable?

2017-03-14 Thread Suliman via Digitalmars-d-learn
I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible will not on x64 PG on Linux (I can't test it now). Could anybody advice me good driver without problems? I seen

Re: Using chunks with Generator

2017-03-14 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 10:00:24 UTC, Tetiana wrote: Build fails with the following error: Just looking at the Documentation, Generator is an InputRange and chunks requires a ForwardRange (able to use save functionality). So the API doesn't match up more or less.

Using chunks with Generator

2017-03-14 Thread Tetiana via Digitalmars-d-learn
I'd like to evaluate values lazily and then process them one by one, using e.g. `map`. One of the steps requires processing the values in chunks. I was thinking of using a Generator for lazy evaluation, but I can't seem to make it work with the `chunks`. How can I make `std.range.chunks` work

Re: Phobos function to check if files are identical?

2017-03-14 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 08:12:16 UTC, Andrea Fontana wrote: First I would check if the files have different size or if they are the same file (same path, symlink, etc). Good idea. Good reason to have it in std.file. There might also be platform dependent shortcuts?

Re: Phobos function to check if files are identical?

2017-03-14 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:47:09 UTC, H. S. Teoh wrote: bool isEqual(string filename1, string filename2) { import std.algorithm.comparison : equal; import std.range : zip; import std.stdio : File, chunks; auto f1 =