Re: scope(~this)

2017-03-13 Thread thedeemon via Digitalmars-d-learn
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 of the object? I have a template method that takes a type an

Re: Phobos function to check if files are identical?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:47:09 UTC, H. S. Teoh wrote: Binary comparison is easy. Just read the files by fixed-sized chunks and compare them. Follow up question... What is the best @safe way? Since File.byChunk() is @system. Just out of curiosity, I would rather use it and flag my code

Re: code folding

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev wrote: If you have enough declarations in one file that they call for code folding, it may be better to move them to a separate module. Public imports and aliases allow doing this without breaking any code. [...] Generally speak

Re: Null-Safe Dereference Operator

2017-03-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 01:08:50 UTC, Jonathan M Davis wrote: It does not, though if you really wanted to, you could probably create template that did the same thing fairly easily. I recently added something similar to dom.d, since I wanted to pull a header if present, and was ok with a n

Re: Declaring interfaces with a constructor

2017-03-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 March 2017 at 19:31:52 UTC, David Zhang wrote: Basically, I want to define a common interface for a group of platform-specific classes, except that they should ideally also share constructor parameters. What I want to do is then alias them to a common name, selecting the implem

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread rikki cattermole via Digitalmars-d-learn
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 is provided by the NDK libc. At least according to this[0]. [0] https:

Re: Null-Safe Dereference Operator

2017-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 14, 2017 00:51:02 Jolly James via Digitalmars-d-learn wrote: > Does anybody know, if D has a null-safe dereference operator like > C# does (?.) or something similar? It does not, though if you really wanted to, you could probably create template that did the same thing fairly ea

Null-Safe Dereference Operator

2017-03-13 Thread Jolly James via Digitalmars-d-learn
Does anybody know, if D has a null-safe dereference operator like C# does (?.) or something similar?

Re: code folding

2017-03-13 Thread Vladimir Panteleev via Digitalmars-d-learn
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 is a useful feature that has proven it's worth and it is time that D

Re: code folding

2017-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 13, 2017 19:51:59 Inquie via Digitalmars-d-learn wrote: > 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

Re: Recursive template instantiation

2017-03-13 Thread ag0aep6g via Digitalmars-d-learn
On 03/13/2017 11:58 PM, Stefan Koch wrote: On Monday, 13 March 2017 at 22:05:24 UTC, Jack Applegame wrote: Is this a bug? No it's not struct C { B!C; } is an error. Howto compute C ? <--\ let's check the members; | The member needs a template. | Howto compute the template

Re: Recursive template instantiation

2017-03-13 Thread ag0aep6g via Digitalmars-d-learn
On 03/14/2017 12:02 AM, Stefan Koch wrote: On Monday, 13 March 2017 at 22:59:36 UTC, ag0aep6g wrote: [...] struct A(T) { void m() { char[T.sizeof] data; } } /* ... rest as above ... */ I don't see how the destructor makes a difference. Soo, bug? Try to use m. Work

Re: Recursive template instantiation

2017-03-13 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 13 March 2017 at 22:59:36 UTC, ag0aep6g wrote: On 03/13/2017 03:26 PM, Jack Applegame wrote: I'm pretty sure that this code should compile (https://dpaste.dzfl.pl/cf1e1ee6ef4b): struct A(T) { ~this() { char[T.sizeof] data; } } struct B(T) { A!T foo; } struct C {

Re: Recursive template instantiation

2017-03-13 Thread ag0aep6g via Digitalmars-d-learn
On 03/13/2017 03:26 PM, Jack Applegame wrote: I'm pretty sure that this code should compile (https://dpaste.dzfl.pl/cf1e1ee6ef4b): struct A(T) { ~this() { char[T.sizeof] data; } } struct B(T) { A!T foo; } struct C { B!C bar; } void main() { C c; } But it doesn't:

Re: Recursive template instantiation

2017-03-13 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 13 March 2017 at 22:05:24 UTC, Jack Applegame wrote: Is this a bug? No it's not struct C { B!C; } is an error. Howto compute C ? <--\ let's check the members; | The member needs a template. | Howto compute the template ? | let's compute the parameters. | What

Re: Recursive template instantiation

2017-03-13 Thread Jack Applegame via Digitalmars-d-learn
Is this a bug?

Re: code folding

2017-03-13 Thread bachmeier via Digitalmars-d-learn
On Monday, 13 March 2017 at 19:51:59 UTC, Inquie wrote: This is wrong. It is a language feature. #region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor. In longer code files, it is convenient to be able to co

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 anything

Re: Phobos function to check if files are identical?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:47:09 UTC, H. S. Teoh wrote: Why it is not easy to do by hand? Sorry typo, I had intended to type "I know it is easy"

Re: code folding

2017-03-13 Thread XavierAP via Digitalmars-d-learn
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 anything about folding/collapsing, just about "marking sections of

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 and t

Re: Phobos function to check if files are identical?

2017-03-13 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 13, 2017 at 10:47:09AM -0700, H. S. Teoh via Digitalmars-d-learn wrote: [...] > P.S. I just realized that std.stdio.chunks() doesn't return a range. > Bah. File an enhancement request. I might even submit a PR for it. ;-) [...] > P.P.S. It's not overly hard to write an alternative ver

Re: Declaring interfaces with a constructor

2017-03-13 Thread David Zhang via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:52:09 UTC, XavierAP wrote: On Monday, 13 March 2017 at 02:15:21 UTC, David Zhang wrote: What it says on the tin. Is there a way to create interfaces with a constructor or must I use an abstract class. What do you want to do in your constructor? I can't think of

Re: TLS

2017-03-13 Thread Rainer Schuetze via Digitalmars-d-learn
On 13.03.2017 14:35, M-exe wrote: On Friday, 10 March 2017 at 21:32:05 UTC, sarn wrote: On Friday, 10 March 2017 at 19:24:29 UTC, bauss wrote: Mark your variables with __gshared. I would say shred, but it has some restrictions to it, where __gshared is the equivalent to global variables in C.

Re: code folding

2017-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
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 and together. > > I have been using > > static if(true) > { > ..

Re: Phobos function to check if files are identical?

2017-03-13 Thread H. S. Teoh via Digitalmars-d-learn
P.P.S. It's not overly hard to write an alternative version of std.stdio.chunks that returns a real range. Something like this should do: // Warning: untested code auto realChunks(File f, size_t blockSize) { static struct Result {

Re: Phobos function to check if files are identical?

2017-03-13 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 13, 2017 at 04:50:49PM +, XavierAP via Digitalmars-d-learn wrote: > It's not easy to do by hand of course, but I was wondering if there > was one simple function taking two file names and just returning a > bool or something like that. I haven't found it in std.file. Why it is not

Re: Declaring interfaces with a constructor

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 02:15:21 UTC, David Zhang wrote: What it says on the tin. Is there a way to create interfaces with a constructor or must I use an abstract class. What do you want to do in your constructor? I can't think of anything that wouldn't change some state, either of the cl

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 shown

Re: Can you fix this code to avoid using pointers?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 14:47:20 UTC, H. S. Teoh wrote: On Sat, Mar 11, 2017 at 08:07:39PM +, XavierAP via Digitalmars-d-learn wrote: [...] But I still like the version with pointers ;) There's nothing wrong with using pointers in D. The fact that D alleviates most cases of (explicit

Re: TLS

2017-03-13 Thread Joakim via Digitalmars-d-learn
On Friday, 10 March 2017 at 06:41:46 UTC, M-exe wrote: I found that D is great language, but for my own reasons I'm trying to use it without TLS at all. Can the TLS directory be avoided? (compiling on windows) I don't know what you mean by the TLS directory, can you explain? I mean, can it a

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread Joakim via Digitalmars-d-learn
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 is provided by the NDK libc. At least according to this[0]. [0] https://developer.android.com/ndk/guides/s

Phobos function to check if files are identical?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
It's not easy to do by hand of course, but I was wondering if there was one simple function taking two file names and just returning a bool or something like that. I haven't found it in std.file. If such a function doesn't exist in Phobos but there's a good implementation in some other librar

Re: Can you fix this code to avoid using pointers?

2017-03-13 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Mar 11, 2017 at 08:07:39PM +, XavierAP via Digitalmars-d-learn wrote: [...] > I realized that the code that sparked the question made no sense and > should be done in a different way... As is always the case when these > questions come up. > But I still like the version with pointers ;

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; y

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

Recursive template instantiation

2017-03-13 Thread Jack Applegame via Digitalmars-d-learn
I'm pretty sure that this code should compile (https://dpaste.dzfl.pl/cf1e1ee6ef4b): struct A(T) { ~this() { char[T.sizeof] data; } } struct B(T) { A!T foo; } struct C { B!C bar; } void main() { C c; } But it doesn't: /d300/f416.d(3): Error: struct f416.C no size

Re: how to assign tuple named Tuple easily

2017-03-13 Thread Adam D. Ruppe via Digitalmars-d-learn
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 typeof: Tuple!(int, "A")[] x; x ~= typeof(x[0])(3

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: ht

Re: TLS

2017-03-13 Thread M-exe via Digitalmars-d-learn
On Friday, 10 March 2017 at 21:32:05 UTC, sarn wrote: On Friday, 10 March 2017 at 19:24:29 UTC, bauss wrote: Mark your variables with __gshared. I would say shred, but it has some restrictions to it, where __gshared is the equivalent to global variables in C. immutable variables are also not

Re: GDC options

2017-03-13 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2017-03-12 at 16:38 +0100, Johannes Pfau via Digitalmars-d- learn wrote: > […] > > https://github.com/D-Programming-GDC/GDMD/tree/dport > > gdmd -unittest --main > > The unittest flag for GDC is -funittest but there's no flag to > generate > a main function. gdmd generates a temporary f

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread dummy via Digitalmars-d-learn
On Monday, 13 March 2017 at 10:11:35 UTC, Mike Parker wrote: On Monday, 13 March 2017 at 06:48:01 UTC, Joakim wrote: [...] The alpha release of DerelictSDL2 3.0 supports static linking. When compiling manually, it requires -version=DerelictSDL_static on the command line and all files match

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread dummy via Digitalmars-d-learn
On Monday, 13 March 2017 at 06:48:01 UTC, Joakim wrote: On Thursday, 9 March 2017 at 10:35:18 UTC, dummy wrote: [...] Regarding the link to that forum post, that bug has since been found and fixed. If you're planning on using Derelict, there is an issue where all Derelict libraries are loa

How can I get changed members in class object?

2017-03-13 Thread donglei via Digitalmars-d-learn
In hibernate,update object is set all table columns to sql. code for example: ``` //orm entity class User { int id; string firstName; string lastName; } Session sess = factory.openSession(); User user =sess.createQuery("FROM User WHERE first_name=:firstName").setParam

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 March 2017 at 06:48:01 UTC, Joakim wrote: If you're planning on using Derelict, there is an issue where all Derelict libraries are loaded as shared libraries, whereas the Android port currently doesn't support loading shared libraries. If DLangUI is using SDL2, maybe he has a he

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread rikki cattermole via Digitalmars-d-learn
On 13/03/2017 7:48 PM, Joakim wrote: On Thursday, 9 March 2017 at 10:35:18 UTC, dummy wrote: On Wednesday, 8 March 2017 at 10:24:24 UTC, Joakim wrote: On Tuesday, 7 March 2017 at 12:06:48 UTC, dummy wrote: Just thought. I do want to know. :-) As far as I know is, * LDC2 woring on NDK(yah!)