Re: Reordered class fields?

2012-10-31 Thread Jacob Carlborg
On 2012-10-31 02:53, Peter Summerland wrote: The order of the fields is rearranged for packing. Does that affect the tupleof property? The example in http://dlang.org/class.html for Class properties tulpleof seems to implie that the the fields the returned Expression Tuple are arranged in

Re: Reordered class fields?

2012-10-31 Thread Peter Summerland
On Wednesday, 31 October 2012 at 07:19:19 UTC, Jacob Carlborg wrote: On 2012-10-31 02:53, Peter Summerland wrote: The order of the fields is rearranged for packing. Does that affect the tupleof property? The example in http://dlang.org/class.html for Class properties tulpleof seems to implie

Re: Reordered class fields?

2012-10-31 Thread Jacob Carlborg
On 2012-10-31 09:14, Peter Summerland wrote: Thanks for the help. Should the the following example, taken from the D Language Reference, be considered incorrect or at least misleading? It clearly depends on lexical ordering of the returned fields: Class Properties The .tupleof property

Re: Reordered class fields?

2012-10-31 Thread bearophile
Peter Summerland: The order of the fields is rearranged for packing. Does that affect the tupleof property? The example in http://dlang.org/class.html for Class properties tulpleof seems to implie that the the fields the returned Expression Tuple are arranged in lexical order (i.e., as

Re: getters and setters not an lvalue

2012-10-31 Thread bearophile
maarten van damme: Is there a rationale behind this decision of not translating test.value+=1 to test.value= test.value +1 ? I think it's a temporary limit, meant to be removed/fixed. Bye, bearophile

Re: getters and setters not an lvalue

2012-10-31 Thread maarten van damme
Ok, looking forward to the fix :) Btw, I have a foreach loop and in that foreach loop I want to decide if the current element can stay and if not, I want to remove it. If removing it yields an empty range in the foreach loop, it crashes. What's the sane way to do this?

Re: getters and setters not an lvalue

2012-10-31 Thread Regan Heath
On Wed, 31 Oct 2012 14:08:18 -, maarten van damme maartenvd1...@gmail.com wrote: Ok, looking forward to the fix :) Btw, I have a foreach loop and in that foreach loop I want to decide if the current element can stay and if not, I want to remove it. If removing it yields an empty range in

Re: getters and setters not an lvalue

2012-10-31 Thread Jacob Carlborg
On 2012-10-31 13:46, maarten van damme wrote: In my current code I'd like to do something ala: void main(){ getsettest test=new getsettest(); test.value+=1; } class getsettest{ int myvalue; this(){ }

Re: Reordered class fields?

2012-10-31 Thread Peter Summerland
On Wednesday, 31 October 2012 at 08:23:26 UTC, Jacob Carlborg wrote: On 2012-10-31 09:14, Peter Summerland wrote: Thanks for the help. Should the the following example, taken from the D Language Reference, be considered incorrect or at least misleading? It clearly depends on lexical

Re: getters and setters not an lvalue

2012-10-31 Thread Maxim Fomin
On Wednesday, 31 October 2012 at 12:46:12 UTC, maarten van damme wrote: In my current code I'd like to do something ala: void main(){ getsettest test=new getsettest(); test.value+=1; } class getsettest{ int myvalue;

Re: getters and setters not an lvalue

2012-10-31 Thread Maxim Fomin
On Wednesday, 31 October 2012 at 12:46:12 UTC, maarten van damme wrote: Is there a rationale behind this decision of not translating test.value+=1 to test.value= test.value +1 ? Probably there were no such decision at all and you just ran into issue which has never worked. BTW properties are

Re: getters and setters not an lvalue

2012-10-31 Thread monarch_dodra
On Wednesday, 31 October 2012 at 12:46:12 UTC, maarten van damme wrote: In my current code I'd like to do something ala: void main(){ getsettest test=new getsettest(); test.value+=1; } class getsettest{ int myvalue;

cast question

2012-10-31 Thread Dan
Why do the commented out calls to goo fail? Thanks Dan - import std.stdio; struct S { } void goo(const ref S s) { writeln(s); } struct T { S s; void foo(const ref T other) const { goo(s); // Error: function fdsaf.goo (ref const(S) s) is //

Re: cast question

2012-10-31 Thread Tobias Pankrath
On Wednesday, 31 October 2012 at 16:59:14 UTC, Dan wrote: Why do the commented out calls to goo fail? Thanks Dan Compiles fine with git-head.

Re: getters and setters not an lvalue

2012-10-31 Thread maarten van damme
Ok, makes sense now :) 2012/10/31 monarch_dodra monarchdo...@gmail.com: On Wednesday, 31 October 2012 at 12:46:12 UTC, maarten van damme wrote: In my current code I'd like to do something ala: void main(){ getsettest test=new getsettest(); test.value+=1; }

Re: cast question

2012-10-31 Thread Dan
On Wednesday, 31 October 2012 at 17:11:47 UTC, Tobias Pankrath wrote: On Wednesday, 31 October 2012 at 16:59:14 UTC, Dan wrote: Why do the commented out calls to goo fail? Thanks Dan Compiles fine with git-head. I did git clone: git clone https://github.com/D-Programming-Language/dmd.git

Re: getters and setters not an lvalue

2012-10-31 Thread Michael
but this gives the following error: test.d(4): Error: test.value() is not an lvalue Is there a rationale behind this decision of not translating test.value+=1 to test.value= test.value +1 ? http://forum.dlang.org/thread/xcbweciovapinaicx...@forum.dlang.org and

Re: cast question

2012-10-31 Thread Tobias Pankrath
Ah, okay. I just dumped it into a file and ran dmd before leaving the office. This looks like a compiler bug to me. The struct should be implicitly convertable to const(S)

Re: getters and setters not an lvalue

2012-10-31 Thread Andrej Mitrovic
On 10/31/12, Michael p...@m1xa.com wrote: http://d.puremagic.com/issues/show_bug.cgi?id=8006 I wonder if this is low-hanging fruit to implement in the DMD frontend. Could we really just implement var.property += 5; to var.property = var.property + 5; or is it much more complicated than that.. I

Re: getters and setters not an lvalue

2012-10-31 Thread Adam D. Ruppe
On Wednesday, 31 October 2012 at 22:46:17 UTC, Andrej Mitrovic wrote: I wonder if this is low-hanging fruit to implement in the DMD frontend. I tried it and found getting almost there is easy... but getting it to work in a bunch of edge cases is incredibly difficult.

Re: getters and setters not an lvalue

2012-10-31 Thread Andrej Mitrovic
On 10/31/12, Adam D. Ruppe destructiona...@gmail.com wrote: On Wednesday, 31 October 2012 at 22:46:17 UTC, Andrej Mitrovic wrote: I wonder if this is low-hanging fruit to implement in the DMD frontend. I tried it and found getting almost there is easy... but getting it to work in a bunch

modules in other directory trees

2012-10-31 Thread dsmith
What is your way to import modules from other directory trees? Here is my (incorrect?) ideal: Given: /home/user/library_directory/ Containing: lib_one.d lib_two.d lib_interface.d lib_interface.d source: module lib_interface; public import lib_one, lib_two; Implementation in program

Ranges and Library and toir.c internal error

2012-10-31 Thread StupidIsAsStupidDoes
There may be a better way to solve this but I'm trying to learn Phobos and parameter typing and anonymous function, etc. So this is probably more of an academic question but I've got the following code: int countBetween(T)(T[] x, T low, T high) { auto k = count!( (x){return ((x = low)

Re: Ranges and Library and toir.c internal error

2012-10-31 Thread bearophile
StupidIsAsStupidDoes: The char call doesn't compile and I get a toir.c internal error. Such internal errors are compiler bugs that should be added to Bugzilla. But I have compiled the following program with the latest DMD GIT-head 32 bit Windows, and I see no compiler bugs: import

Re: Ranges and Library and toir.c internal error

2012-10-31 Thread Ellery Newcomer
On 10/31/2012 04:35 PM, StupidIsAsStupidDoes wrote: The char call doesn't compile and I get a toir.c internal error. On a recent dmd build from github, I don't get any ICE, so it may have been fixed. I do get some disconcerting type deduction failures, though... I'm still trying to get