static class vs. static struct

2015-01-26 Thread ref2401 via Digitalmars-d-learn
What's the difference between static class and static struct? What should i use?

How to tell an identifier is a module?

2015-01-26 Thread bearophile via Digitalmars-d-learn
__traits(allMembers, mixin(__MODULE__)) also yields a module name like object, but then how can you find out that object is a module? This doesn't work: void main() { pragma(msg, is(int == int)); pragma(msg, is(object == module)); } Bye, bearophile

Re: Cannot infer argument types for foreach over byLine

2015-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/24/15 11:15 AM, Meta wrote: On Saturday, 24 January 2015 at 08:44:45 UTC, Ali Çehreli wrote: On 01/24/2015 12:14 AM, Meta wrote: import std.stdio; void main() { foreach (i, line; file.byLine()) Unless the range itself provides explicitly, automatic counter is available only for

Re: static class vs. static struct

2015-01-26 Thread bearophile via Digitalmars-d-learn
On Monday, 26 January 2015 at 14:02:54 UTC, ref2401 wrote: What's the difference between static class and static struct? What should i use? Non-static structs/classes have an extra pointer. Static ones don't have it, so their differences are the usual ones: a class is used by reference and

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Bayan Rafeh via Digitalmars-d-learn
Bug report at https://issues.dlang.org/show_bug.cgi?id=14051

Other libraries - web site link, and other thoughts

2015-01-26 Thread Laeeth Isharc via Digitalmars-d-learn
At the moment it goes straight go code.dlang.org, which may be a bit overwhelming if you have just arrived at dlang.org and want to see what it can do. Is it worth changing to the library wiki write up page on libraries? And making sure link to code.dlang.org is prominent, saying

enum, immutable or const for run-time constants?

2015-01-26 Thread Nordlöw
What's the preferred way of declaring run-time constant values in D from the point of view of 1, compile-time performance 2. run-time performance 3. code-size 4. load-time 5. locality of reference module global or function global (static)

Re: enum, immutable or const for run-time constants?

2015-01-26 Thread ketmar via Digitalmars-d-learn
On Mon, 26 Jan 2015 20:04:58 +, Nordlöw wrote: What's the preferred way of declaring run-time constant values in D from the point of view of 1, compile-time performance 2. run-time performance 3. code-size 4. load-time 5. locality of reference module global or function global (static)

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread ketmar via Digitalmars-d-learn
On Mon, 26 Jan 2015 11:37:12 +, Bayan Rafeh wrote: you are trying to use invariants for the things that invariants can't (and must not) check. invariants are meant for checking *internal* *object* *consistency*. NOT correctness. NOT applicability. ONLY consistency. object can be in

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Dicebot via Digitalmars-d-learn
On Monday, 26 January 2015 at 15:54:12 UTC, Bayan Rafeh wrote: I apologize, I thought the point of invariant was to ensure correctness of the object's state It is simply matter of internal correctness vs in-program correctness. Sorry, documentation should probably mention that explicitly. I

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-26 Thread Suliman via Digitalmars-d-learn
On Sunday, 25 January 2015 at 22:14:09 UTC, Adam D. Ruppe wrote: On Sunday, 25 January 2015 at 21:24:06 UTC, Suliman wrote: I need extract data inside rel (somedata) string s = element.rel; Do you mean something like this? string s = element.rel; foreach(row;

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-26 Thread Suliman via Digitalmars-d-learn
On Monday, 26 January 2015 at 17:24:23 UTC, Adam D. Ruppe wrote: On Monday, 26 January 2015 at 17:17:55 UTC, Suliman wrote: Do you mean something like this? I just mean to get the value of the rel=something attribute, use element.rel; assert(element.rel == something); The element is the

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 January 2015 at 17:17:55 UTC, Suliman wrote: Do you mean something like this? I just mean to get the value of the rel=something attribute, use element.rel; assert(element.rel == something); The element is the thing you see in the loop and stuff. querySelectorAll returns an

Re: static class vs. static struct

2015-01-26 Thread anonymous via Digitalmars-d-learn
On Monday, 26 January 2015 at 21:33:10 UTC, Piotrek wrote: On Monday, 26 January 2015 at 14:11:32 UTC, bearophile wrote: Non-static structs/classes have an extra pointer. Bye, bearophile Since when structs have an extra pointer? Maybe you are talking about nested structs? Non-static means

Using dub

2015-01-26 Thread Joel via Digitalmars-d-learn
I'm having trouble using dub. Nothing seems to work (-h works though). I would like an example or two of how to get an app going (stand alone for now). I'm using the Mac OS.

Re: Virtual functions and inheritance

2015-01-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 27, 2015 at 04:38:57AM +, David Monagle via Digitalmars-d-learn wrote: Hi guys, I'm a former C++ developer and really enjoying working with D now. I have a question that I hope some of you may be able to answer. class Parent { @property string typeName() { return

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Bayan Rafeh via Digitalmars-d-learn
but please, take my words with a grain of salt. i'm in no way a representative of D devs. that is how *i* understand invariants. it seems to be consistent with the cases where invariant works, This is the first serious project I do with D, so I'm kind of discovering the language as I write

Virtual functions and inheritance

2015-01-26 Thread David Monagle via Digitalmars-d-learn
Hi guys, I'm a former C++ developer and really enjoying working with D now. I have a question that I hope some of you may be able to answer. class Parent { @property string typeName() { return typeof(this).stringof; } } class Child : Parent { } void main() { auto p = new Parent;

Re: Array List object?

2015-01-26 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 06:16:03 UTC, H. S. Teoh wrote: On Tue, Jan 27, 2015 at 06:02:38AM +, Gan via Digitalmars-d-learn wrote: On Tuesday, 27 January 2015 at 06:00:50 UTC, Gan wrote: On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote: Hey I'm using normal arrays for my project:

Re: Virtual functions and inheritance

2015-01-26 Thread David Monagle via Digitalmars-d-learn
I can certainly work with that. Thank you very much! (and for pointing out my typo in the example)

Re: Array List object?

2015-01-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 27, 2015 at 06:02:38AM +, Gan via Digitalmars-d-learn wrote: On Tuesday, 27 January 2015 at 06:00:50 UTC, Gan wrote: On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote: Hey I'm using normal arrays for my project: //Declaring the array SBTile[] tiles; //Initializing the

Re: Array List object?

2015-01-26 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote: Hey I'm using normal arrays for my project: //Declaring the array SBTile[] tiles; //Initializing the array tiles = new SBTile[](0); //Clearing the array tiles = []; //Removing a tile at index i from the array tiles.remove(i); //Adding a

Re: Array List object?

2015-01-26 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 06:00:50 UTC, Gan wrote: On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote: Hey I'm using normal arrays for my project: //Declaring the array SBTile[] tiles; //Initializing the array tiles = new SBTile[](0); //Clearing the array tiles = []; //Removing a

Re: Using dub

2015-01-26 Thread Rikki Cattermole via Digitalmars-d-learn
On 27/01/2015 8:03 p.m., Joel wrote: I'm having trouble using dub. Nothing seems to work (-h works though). I would like an example or two of how to get an app going (stand alone for now). I'm using the Mac OS. Lets use Devisualization.Window as an example. Assuming in a safe directory and

Re: Using dub

2015-01-26 Thread Rikki Cattermole via Digitalmars-d-learn
On 27/01/2015 8:40 p.m., Joel wrote: On Tuesday, 27 January 2015 at 07:25:18 UTC, Rikki Cattermole wrote: On 27/01/2015 8:03 p.m., Joel wrote: I'm having trouble using dub. Nothing seems to work (-h works though). I would like an example or two of how to get an app going (stand alone for now).

Re: Using dub

2015-01-26 Thread Joel via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 07:25:18 UTC, Rikki Cattermole wrote: On 27/01/2015 8:03 p.m., Joel wrote: I'm having trouble using dub. Nothing seems to work (-h works though). I would like an example or two of how to get an app going (stand alone for now). I'm using the Mac OS. Lets use

Re: Linking C library (.dll) to D on windows

2015-01-26 Thread Roman via Digitalmars-d-learn
On Monday, 26 January 2015 at 02:18:05 UTC, Mike Parker wrote: On 1/26/2015 5:45 AM, Roman wrote: Stuff: 1. There are C code module.c and module.h 2. MinGW 3. DMD 2.066.1 4. Window 8.1 module.c: #include module.h int add(int a, int b) {return a + b;} module.h: int add(int,int); I want to

Re: Question about Allocating

2015-01-26 Thread wobbles via Digitalmars-d-learn
On Monday, 26 January 2015 at 07:52:06 UTC, Gan wrote: I've been working on my game and am getting some pretty gnarly memory problems. I think it's how I'm allocating. Sometimes when I use variables I can do Color(255, 255, 255). But why is that different than new Color(255, 255, 255)? Same

Why can't functions and struct types have the same name?

2015-01-26 Thread Joakim via Digitalmars-d-learn
Right now, any attempt to have symbols with the same name errors out, regardless of how they're used. This caused a problem for me because I'm trying to use a third-party C library that defines a struct type called socket and my code calls that library and some networking modules from

Re: Why can't functions and struct types have the same name?

2015-01-26 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 26 January 2015 at 11:15:26 UTC, Joakim wrote: Right now, any attempt to have symbols with the same name errors out, regardless of how they're used. This caused a problem for me because I'm trying to use a third-party C library that defines a struct type called socket and my code

Re: Why can't functions and struct types have the same name?

2015-01-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 26 January 2015 at 11:15:26 UTC, Joakim wrote: Right now, any attempt to have symbols with the same name errors out, regardless of how they're used. This caused a problem for me because I'm trying to use a third-party C library that defines a struct type called socket and my code

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Bayan Rafeh via Digitalmars-d-learn
you are trying to use invariants for the things that invariants can't (and must not) check. invariants are meant for checking *internal* *object* *consistency*. NOT correctness. NOT applicability. ONLY consistency. object can be in inapplicable state, but still consistent. Then I must have

Re: Why can't functions and struct types have the same name?

2015-01-26 Thread Joakim via Digitalmars-d-learn
On Monday, 26 January 2015 at 11:30:00 UTC, Daniel Kozak wrote: On Monday, 26 January 2015 at 11:15:26 UTC, Joakim wrote: Right now, I had to go through and selectively import all 14 symbols I needed from the 3 druntime modules that publicly import core.sys.posix.sys.socket, so that the

Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
Is there a way to tell DUB to compile all its sources as separate objects which are then fed to ld. My project has grown beyound 10k lines of code. And I don't want DMD to recompile every line in my project if I change only of them...and yes most of my cross-module interfaces are

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:33:21 UTC, Nordlöw wrote: Is there a way to tell DUB to compile all its sources as separate objects which are then fed to ld. For reference here's the DUB build file for my project: https://github.com/nordlow/justd/blob/master/knetquery/dub.json

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:51:44 UTC, Nordlöw wrote: On Monday, 26 January 2015 at 22:33:21 UTC, Nordlöw wrote: Is there a way to tell DUB to compile all its sources as separate objects which are then fed to ld. And, yes, I'm using ld.gold as my default linker ;)

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:41:09 UTC, Adam D. Ruppe wrote: On Monday, 26 January 2015 at 22:33:21 UTC, Nordlöw wrote: My project has grown beyound 10k lines of code. Eh, that's nothing, especially if they aren't templates. dmd will compile that in a fraction of a second (and even then,

Re: How to tell an identifier is a module?

2015-01-26 Thread Rikki Cattermole via Digitalmars-d-learn
On 27/01/2015 2:25 a.m., bearophile wrote: __traits(allMembers, mixin(__MODULE__)) also yields a module name like object, but then how can you find out that object is a module? This doesn't work: void main() { pragma(msg, is(int == int)); pragma(msg, is(object == module)); } Bye,

Re: Other libraries - web site link, and other thoughts

2015-01-26 Thread Rikki Cattermole via Digitalmars-d-learn
On 27/01/2015 8:29 a.m., Laeeth Isharc wrote: At the moment it goes straight go code.dlang.org, which may be a bit overwhelming if you have just arrived at dlang.org and want to see what it can do. Is it worth changing to the library wiki write up page on libraries? And making sure link to

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:41:09 UTC, Adam D. Ruppe wrote: On Monday, 26 January 2015 at 22:33:21 UTC, Nordlöw wrote: My project has grown beyound 10k lines of code. Eh, that's nothing, especially if they aren't templates. dmd will compile that in a fraction of a second (and even then,

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 January 2015 at 22:33:21 UTC, Nordlöw wrote: My project has grown beyound 10k lines of code. Eh, that's nothing, especially if they aren't templates. dmd will compile that in a fraction of a second (and even then, if you used phobos, reading the stdlib into memory will dominate

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:46:46 UTC, Nordlöw wrote: On Monday, 26 January 2015 at 22:44:26 UTC, Nordlöw wrote: Ok, then it's more than that. It takes 7 seconds: time dub build time dub build --combined --force is in the same order - around 7 seconds. Why is DUB compiling it all in

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:44:26 UTC, Nordlöw wrote: Ok, then it's more than that. It takes 7 seconds: time dub build time dub build --combined --force is in the same order - around 7 seconds.

Re: Cached Incremental Updates of DUB Builds

2015-01-26 Thread Nordlöw
On Monday, 26 January 2015 at 22:46:46 UTC, Nordlöw wrote: On Monday, 26 January 2015 at 22:44:26 UTC, Nordlöw wrote: Ok, then it's more than that. It takes 7 seconds: time dub build time dub build --combined --force is in the same order - around 7 seconds. The only way I managed to

Re: static class vs. static struct

2015-01-26 Thread Piotrek via Digitalmars-d-learn
On Monday, 26 January 2015 at 14:11:32 UTC, bearophile wrote: Non-static structs/classes have an extra pointer. Bye, bearophile Since when structs have an extra pointer? Maybe you are talking about nested structs? Piotrek