Re: Visibility of variables in struct nested within a class

2013-07-08 Thread bearophile
Charles Hixson: Is this the way things are supposed to happen? (Changing the struct to a class is an OK patch, but I don't understand why it should either work or be necessary.) Please show a complete very little program, and maybe someone will try to help you. (Eventually it's a good

Re: Visibility of variables in struct nested within a class

2013-07-08 Thread bearophile
Please show a complete very little program, and maybe someone will try to help you. I've seen there is code in another (broken) thread, so please ignore this request. Bye, bearophile

enforcing alias this on derived types

2013-07-08 Thread JS
I have an interface that I would like to make sure that any classes derived from it will use alias this, else it can potentially break code. interface A(T) { @property T Value(); @property T Value(T value); // need to enforce alias _value this somehow } class B(T) : A!T {

Re: How can i increase max number recursive template expansions?

2013-07-08 Thread bearophile
Simen Kjaeraas: However, you can amend std.traits.EnumMembers to work with larger enums by using this version: Worth putting in Phobos? Bye, bearophile

Re: enforcing alias this on derived types

2013-07-08 Thread JS
interface A(T) { @property T Value(); @property T Value(T value); // need to enforce alias Value this somehow } class B(T) : A!T { private T _value; @property T Value() { return _value; } @property T Value(T value) { return value = _value; } alias Value this;

creating a variadic interface

2013-07-08 Thread JS
this may seem a bit nonsensical but it is just an example: interface A(T, S...) { ... Generate a getter for each type in S... // e.g., @property S[0] property1(); // @property S[1] property2(); // } I imagine I have to use a mixin template but I'm unsure how to create a

Re: enforcing alias this on derived types

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 08:59:16 UTC, JS wrote: I have an interface that I would like to make sure that any classes derived from it will use alias this, else it can potentially break code. interface A(T) { @property T Value(); @property T Value(T value); // need to enforce alias

Re: enforcing alias this on derived types

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 09:52:44 UTC, John Colvin wrote: Most other solutions I tried failed because the compiler evaluates the check (e.g. out contracts) in the interface, which makes the check either semantically wrong, or statically false/failed. Woops, should be the contract exists in

Re: creating a variadic interface

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 09:34:46 UTC, JS wrote: this may seem a bit nonsensical but it is just an example: interface A(T, S...) { ... Generate a getter for each type in S... // e.g., @property S[0] property1(); // @property S[1] property2(); // } I imagine I have to

Re: How can i increase max number recursive template expansions?

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 09:03:24 UTC, bearophile wrote: Simen Kjaeraas: However, you can amend std.traits.EnumMembers to work with larger enums by using this version: Worth putting in Phobos? Bye, bearophile I reckon so. It's rare to have such huge structs or classes that this sort of

Re: creating a variadic interface

2013-07-08 Thread JS
On Monday, 8 July 2013 at 10:16:22 UTC, John Colvin wrote: On Monday, 8 July 2013 at 09:34:46 UTC, JS wrote: this may seem a bit nonsensical but it is just an example: interface A(T, S...) { ... Generate a getter for each type in S... // e.g., @property S[0] property1(); //

Re: enforcing alias this on derived types

2013-07-08 Thread JS
On Monday, 8 July 2013 at 09:55:29 UTC, John Colvin wrote: On Monday, 8 July 2013 at 09:52:44 UTC, John Colvin wrote: Most other solutions I tried failed because the compiler evaluates the check (e.g. out contracts) in the interface, which makes the check either semantically wrong, or

Re: How can i increase max number recursive template expansions?

2013-07-08 Thread Simen Kjaeraas
On 2013-07-08, 11:03, bearophile wrote: Simen Kjaeraas: However, you can amend std.traits.EnumMembers to work with larger enums by using this version: Worth putting in Phobos? Filed: http://d.puremagic.com/issues/show_bug.cgi?id=10569 And created a pull request:

Re: creating a variadic interface

2013-07-08 Thread Artur Skawina
On 07/08/13 13:25, JS wrote: mixin template a(T...) { template b(TT...) { static string eval() { string s; int i = 0; foreach(t; TT) s = @property ~(t).stringof~ Name~to!string(i++)~();\n; return s;

Re: creating a variadic interface

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 13:01:32 UTC, Artur Skawina wrote: It won't work if one of the types isn't already available inside the template - the .stringof will give you the name, but the mixin will fail; When would the type not be available?

Re: enforcing alias this on derived types

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 11:37:31 UTC, JS wrote: On Monday, 8 July 2013 at 09:55:29 UTC, John Colvin wrote: On Monday, 8 July 2013 at 09:52:44 UTC, John Colvin wrote: Most other solutions I tried failed because the compiler evaluates the check (e.g. out contracts) in the interface, which

Re: creating a variadic interface

2013-07-08 Thread Artur Skawina
On 07/08/13 15:12, John Colvin wrote: On Monday, 8 July 2013 at 13:01:32 UTC, Artur Skawina wrote: It won't work if one of the types isn't already available inside the template - the .stringof will give you the name, but the mixin will fail; When would the type not be available? auto

Re: creating a variadic interface

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 13:42:36 UTC, Artur Skawina wrote: On 07/08/13 15:12, John Colvin wrote: On Monday, 8 July 2013 at 13:01:32 UTC, Artur Skawina wrote: It won't work if one of the types isn't already available inside the template - the .stringof will give you the name, but the mixin

Re: creating a variadic interface

2013-07-08 Thread Artur Skawina
On 07/08/13 16:12, John Colvin wrote: On Monday, 8 July 2013 at 13:42:36 UTC, Artur Skawina wrote: On 07/08/13 15:12, John Colvin wrote: On Monday, 8 July 2013 at 13:01:32 UTC, Artur Skawina wrote: It won't work if one of the types isn't already available inside the template - the .stringof

Re: creating a variadic interface

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 14:25:17 UTC, Artur Skawina wrote: On 07/08/13 16:12, John Colvin wrote: On Monday, 8 July 2013 at 13:42:36 UTC, Artur Skawina wrote: On 07/08/13 15:12, John Colvin wrote: On Monday, 8 July 2013 at 13:01:32 UTC, Artur Skawina wrote: It won't work if one of the types

Re: Allocating a slice object

2013-07-08 Thread Marco Leise
Am Thu, 04 Jul 2013 15:54:48 +0200 schrieb monarch_dodra monarchdo...@gmail.com: This should work: int[] *pSlice = (new int[][1]).ptr; -Steve Hum... That would allocate a dynamic array of slices though right? There'd be the Appendable overhead for just one element... No, it

Re: Allocating a slice object

2013-07-08 Thread monarch_dodra
On Monday, 8 July 2013 at 15:43:21 UTC, Marco Leise wrote: Am Thu, 04 Jul 2013 15:54:48 +0200 schrieb monarch_dodra monarchdo...@gmail.com: This should work: int[] *pSlice = (new int[][1]).ptr; -Steve Hum... That would allocate a dynamic array of slices though right? There'd be the

Re: enforcing alias this on derived types

2013-07-08 Thread Marco Leise
Am Mon, 08 Jul 2013 10:59:14 +0200 schrieb JS js.m...@gmail.com: I have an interface that I would like to make sure that any classes derived from it will use alias this, else it can potentially break code. interface A(T) { @property T Value(); @property T Value(T value);

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread JohnnyK
On Monday, 8 July 2013 at 03:35:03 UTC, Jesse Phillips wrote: On Monday, 8 July 2013 at 02:42:50 UTC, JohnnyK wrote: Hi all, I have searched everywhere over the Internet and I have yet to find a way to clone a project using git when my workstation is behind a company proxy. Can you guys

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread Dicebot
On Monday, 8 July 2013 at 02:42:50 UTC, JohnnyK wrote: Hi all, I have searched everywhere over the Internet and I have yet to find a way to clone a project using git when my workstation is behind a company proxy. Can you guys clone your projects to a single zip file that I can download?

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 16:24:53 UTC, JohnnyK wrote: On Monday, 8 July 2013 at 03:35:03 UTC, Jesse Phillips wrote: On Monday, 8 July 2013 at 02:42:50 UTC, JohnnyK wrote: Hi all, I have searched everywhere over the Internet and I have yet to find a way to clone a project using git when my

Help me investigate a bug to file it.

2013-07-08 Thread monarch_dodra
Yeah, not very exiting, but I just spent an hour tracking down the fix, but now I'd like to track down *what* was making it break (my fix was luck). This should help Kenji (or others) have an easier time fixing it :) Also, I'm only repro'ing this on linux... I think there are two things

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread monarch_dodra
On Monday, 8 July 2013 at 16:49:05 UTC, John Colvin wrote: On Monday, 8 July 2013 at 16:24:53 UTC, JohnnyK wrote: On Monday, 8 July 2013 at 03:35:03 UTC, Jesse Phillips wrote: On Monday, 8 July 2013 at 02:42:50 UTC, JohnnyK wrote: Hi all, I have searched everywhere over the Internet and I

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread Jesse Phillips
On Monday, 8 July 2013 at 16:24:53 UTC, JohnnyK wrote: It would be nice if GitHUB would change their Downlaod Zip button such that it does a recursive zip to include all the subfolders. Ehhh, well that is useless. Sorry I couldn't hook you up with a solution.

Re: Help me investigate a bug to file it.

2013-07-08 Thread Artur Skawina
On 07/08/13 19:54, monarch_dodra wrote: struct S(R) { R _input; void foo() { static assert(is(typeof(_input[size_t.max .. size_t.max]))); //ok static assert(is(typeof(_input[size_t.max .. $]))); //ok } static assert(is(typeof(_input[size_t.max ..

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread John Colvin
On Monday, 8 July 2013 at 18:09:44 UTC, monarch_dodra wrote: On Monday, 8 July 2013 at 16:49:05 UTC, John Colvin wrote: On Monday, 8 July 2013 at 16:24:53 UTC, JohnnyK wrote: On Monday, 8 July 2013 at 03:35:03 UTC, Jesse Phillips wrote: On Monday, 8 July 2013 at 02:42:50 UTC, JohnnyK wrote:

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread JohnnyK
On Monday, 8 July 2013 at 18:34:33 UTC, Jesse Phillips wrote: On Monday, 8 July 2013 at 16:24:53 UTC, JohnnyK wrote: It would be nice if GitHUB would change their Downlaod Zip button such that it does a recursive zip to include all the subfolders. Ehhh, well that is useless. Sorry I

Re: GitHub behind proxy servers among other questions

2013-07-08 Thread JohnnyK
On Monday, 8 July 2013 at 19:37:08 UTC, JohnnyK wrote: Another thing about GitHub's Download Zip button and this process as a whole. While the Download Zip button does allow you to download the master folders with recursive directories I do find it somewhat cumbersome or should I say awkward

Beginner problem: casting in opCmp override

2013-07-08 Thread Ugbar Ikenaki
I'm trying to implement rational numbers with fully functioning comparison operators, but I can't seem to figure out why I'm getting this error and any help would be appreciated: Error: cannot cast from object.Object to Rat The code I have is as follows: int opCmp( Object o ) { Rat

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Jonathan M Davis
On Monday, July 08, 2013 23:21:59 Ugbar Ikenaki wrote: I'm trying to implement rational numbers with fully functioning comparison operators, but I can't seem to figure out why I'm getting this error and any help would be appreciated: Error: cannot cast from object.Object to Rat The code I

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Ugbar Ikenaki
Also…Rat is a struct, not a class. Herein might lie the problem.

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Ugbar Ikenaki
Thanks for the quick response! Here is the initialization code for my Rat struct. I created a GCD function that I've tested to work fine: import std.stdio, std.exception; struct Rat { private long n; //Numerator private long d; //Denominator

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Jonathan M Davis
On Monday, July 08, 2013 23:31:14 Ugbar Ikenaki wrote: Also…Rat is a struct, not a class. Herein might lie the problem. So, this is Rat's opCmp, correct? If it's a struct, it makes no sense for it to take an Object. Object is the base class for all classes and has nothing to do with structs.

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Ali Çehreli
On 07/08/2013 02:21 PM, Ugbar Ikenaki wrote: I'm trying to implement rational numbers with fully functioning comparison operators, but I can't seem to figure out why I'm getting this error and any help would be appreciated: Error: cannot cast from object.Object to Rat The code I have is as

Re: Help me investigate a bug to file it.

2013-07-08 Thread monarch_dodra
On Monday, 8 July 2013 at 18:55:30 UTC, Artur Skawina wrote: On 07/08/13 19:54, monarch_dodra wrote: struct S(R) { R _input; void foo() { static assert(is(typeof(_input[size_t.max .. size_t.max]))); //ok static assert(is(typeof(_input[size_t.max .. $]))); //ok

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread H. S. Teoh
On Mon, Jul 08, 2013 at 02:42:30PM -0700, Jonathan M Davis wrote: On Monday, July 08, 2013 23:31:14 Ugbar Ikenaki wrote: Also…Rat is a struct, not a class. Herein might lie the problem. So, this is Rat's opCmp, correct? If it's a struct, it makes no sense for it to take an Object. Object is

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Ugbar Ikenaki
Wow! You guys are fast and helpful! Thank you Jonathan and Ali! I already got it to work, and Ali, your book is great! I've read about the first 150 pages. I'll check out those operator overloading chapters for sure. -U

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Ugbar Ikenaki
And thanks for that pointer, too, H.S.

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Ugbar Ikenaki
Here's one more question: Before I knew that opEquals existed, I tried overloading the equality expressions (== and !=) in opBinary using the code below. It worked. Why would the overloaded opBinary version get called if the equality expressions are held in opEquals? I'm just interested in

Re: Help me investigate a bug to file it.

2013-07-08 Thread Artur Skawina
On 07/08/13 23:45, monarch_dodra wrote: On Monday, 8 July 2013 at 18:55:30 UTC, Artur Skawina wrote: On 07/08/13 19:54, monarch_dodra wrote: struct S(R) { R _input; void foo() { static assert(is(typeof(_input[size_t.max .. size_t.max]))); //ok static

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Jonathan M Davis
On Tuesday, July 09, 2013 00:35:32 Ugbar Ikenaki wrote: Here's one more question: Before I knew that opEquals existed, I tried overloading the equality expressions (== and !=) in opBinary using the code below. It worked. Why would the overloaded opBinary version get called if the equality

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread H. S. Teoh
On Tue, Jul 09, 2013 at 12:35:32AM +0200, Ugbar Ikenaki wrote: Here's one more question: Before I knew that opEquals existed, I tried overloading the equality expressions (== and !=) in opBinary using the code below. It worked. Why would the overloaded opBinary version get called if the

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Jonathan M Davis
On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote: On Tue, Jul 09, 2013 at 12:35:32AM +0200, Ugbar Ikenaki wrote: Here's one more question: Before I knew that opEquals existed, I tried overloading the equality expressions (== and !=) in opBinary using the code below. It worked. Why

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Jonathan M Davis
On Monday, July 08, 2013 16:48:05 Jonathan M Davis wrote: On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote: On Tue, Jul 09, 2013 at 12:35:32AM +0200, Ugbar Ikenaki wrote: Here's one more question: Before I knew that opEquals existed, I tried overloading the equality expressions

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread H. S. Teoh
On Mon, Jul 08, 2013 at 04:48:05PM -0700, Jonathan M Davis wrote: On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote: [...] Basically, when you write x==y, the compiler looks for opEquals and opCmp. If opEquals is found, then it's rewritten as x.opEquals(y); otherwise, if opCmp is found,

Re: Help me investigate a bug to file it.

2013-07-08 Thread Artur Skawina
On 07/09/13 00:43, Artur Skawina wrote: On 07/08/13 23:45, monarch_dodra wrote: But, the context pointer *should* be defined as whatever the owner of the indexing/slicing object is, no? In this case, it's simply _input. It has nothing to do with the this pointer being available... If

Re: Beginner problem: casting in opCmp override

2013-07-08 Thread Jonathan M Davis
On Monday, July 08, 2013 16:58:03 H. S. Teoh wrote: On Mon, Jul 08, 2013 at 04:48:05PM -0700, Jonathan M Davis wrote: On Monday, July 08, 2013 16:38:16 H. S. Teoh wrote: [...] Basically, when you write x==y, the compiler looks for opEquals and opCmp. If opEquals is found, then it's

function type stringification

2013-07-08 Thread Timothee Cour
I'm a bit confused with the behavior of function type stringification: int main(string[]args){ auto foo=main; pragma(msg,typeid(typeof(foo))); pragma(msg,typeid(typeof(foo)).stringof); //pragma(msg,typeid(typeof(foo))); import std.stdio; writeln(typeid(typeof(foo)).stringof);