auto in library functions

2012-12-23 Thread Benjamin Thaut
I just created my first pull request for druntime and there where multiple commonets to _not_ use auto. I don't quite understand why it shouldn't be used in library functions. If it should not be used why is it in the language in the first place? Kind Regards Benjamin Thaut

Re: Bug or logic error in if with auto?

2012-12-07 Thread deadalnix
On Friday, 7 December 2012 at 14:21:51 UTC, Nick Treleaven wrote: On 03/12/2012 14:22, Nick Treleaven wrote: Most programmers would probably just pollute the existing scope: auto x = "thing" in arr; if (x && *x == 45) { ... } I expect this is because wrapping the abo

Re: Bug or logic error in if with auto?

2012-12-07 Thread Nick Treleaven
On 03/12/2012 14:22, Nick Treleaven wrote: Most programmers would probably just pollute the existing scope: auto x = "thing" in arr; if (x && *x == 45) { ... } I expect this is because wrapping the above in {} for a new scope is just too ugly, introducing more nesting an

Re: Bug or logic error in if with auto?

2012-12-04 Thread Nick Treleaven
On 03/12/2012 20:17, Rob T wrote: On Monday, 3 December 2012 at 14:22:28 UTC, Nick Treleaven wrote: Most programmers would probably just pollute the existing scope: auto x = "thing" in arr; if (x && *x == 45) { ... } You can always wrap it inside its own scope Yes,

Re: Bug or logic error in if with auto?

2012-12-03 Thread Rob T
On Monday, 3 December 2012 at 14:22:28 UTC, Nick Treleaven wrote: Most programmers would probably just pollute the existing scope: auto x = "thing" in arr; if (x && *x == 45) { ... } You can always wrap it inside its own scope main() { // temp scope { auto

Re: Bug or logic error in if with auto?

2012-12-03 Thread Nick Treleaven
On 02/12/2012 15:09, js.mdnq wrote: Can this be made to work in D? Error in D, x not found: if (auto x = "thing" in arr && x == 45) { } Works: if (auto x = "thing" in arr) if (x == 45) { } Most programmers would probably just pollute the exis

Re: Bug or logic error in if with auto?

2012-12-02 Thread Peter Alexander
On Sunday, 2 December 2012 at 15:09:17 UTC, js.mdnq wrote: Can this be made to work in D? Error in D, x not found: if (auto x = "thing" in arr && x == 45) { } You can't have both a declaration and expression in an if-statement. http://dlang.org/statement.html#I

Re: Bug or logic error in if with auto?

2012-12-02 Thread Peter Alexander
And no, it cannot be made to work, because the grammar would be ambiguous: if (auto x = y && z) Does this mean? if (auto x = (y && z)) or if (auto x = y) if (x && z) You could make it work with new syntax, but given you can just use two if-statements, I don't see any point.

Bug or logic error in if with auto?

2012-12-02 Thread js.mdnq
Can this be made to work in D? Error in D, x not found: if (auto x = "thing" in arr && x == 45) { } Works: if (auto x = "thing" in arr) if (x == 45) { }

D2 auto tester is hung on specific unittest

2012-10-31 Thread monarch_dodra
I'm not sure who to notify, but I seem to have hung the unittester on one of my releases: http://d.puremagic.com/test-results/pull-history.ghtml?repoid=3&pullid=915 Those first 3 tests have been running (as of now) for about 5 hours. I've tried to get in touch with a couple of people, but th

Re: Is anyone able to contribute a Solaris machine to the auto tester infrastructure?

2012-09-13 Thread Paulo Pinto
On Wednesday, 12 September 2012 at 06:09:04 UTC, Alex Rønne Petersen wrote: Hi, I'm currently working on porting the tool chain to Solaris (or rather, updating the existing, bitrotten port). It would be nice if we could add a Solaris machine to the auto tester infrastructure to make sur

Is anyone able to contribute a Solaris machine to the auto tester infrastructure?

2012-09-11 Thread Alex Rønne Petersen
Hi, I'm currently working on porting the tool chain to Solaris (or rather, updating the existing, bitrotten port). It would be nice if we could add a Solaris machine to the auto tester infrastructure to make sure the port doesn't regress. -- Alex Rønne Petersen a...@lycu

Re: Allow auto in function parameters with default arguments?

2012-09-11 Thread Artur Skawina
On 09/11/12 08:21, Mehrdad wrote: > http://forum.dlang.org/thread/is9jmn$2ia5$1...@digitalmars.com Completely different issue. That one is about syntax sugar for template functions, while this one would just save the programmer some typing when declaring "normal" functions (by propagating the type

Re: Allow auto in function parameters with default arguments?

2012-09-10 Thread Artur Skawina
On 09/10/12 15:46, Timon Gehr wrote: > On 09/10/2012 12:34 PM, Artur Skawina wrote: >> On 09/10/12 06:20, Andrej Mitrovic wrote: >>> It occurred to me that using a parameter with a default value that is >>> a function call could benefit from using auto: >>>

Re: Allow auto in function parameters with default arguments?

2012-09-10 Thread Andrej Mitrovic
On 9/10/12, Timon Gehr wrote: > Every type that you can get hold of a value of can be specified by the > means of typeof. Yeah but it's repetitive. typeof(exp) arg = exp;

Re: Allow auto in function parameters with default arguments?

2012-09-10 Thread Timon Gehr
On 09/10/2012 12:34 PM, Artur Skawina wrote: On 09/10/12 06:20, Andrej Mitrovic wrote: It occurred to me that using a parameter with a default value that is a function call could benefit from using auto: struct Foo(T) { } auto getFoo() { return Foo!int(); } void func(int x, auto foo

Re: Allow auto in function parameters with default arguments?

2012-09-10 Thread Timon Gehr
On 09/10/2012 06:20 AM, Andrej Mitrovic wrote: It occurred to me that using a parameter with a default value that is a function call could benefit from using auto: struct Foo(T) { } auto getFoo() { return Foo!int(); } void func(int x, auto foo = getFoo()) { } Granted this is a simple

Re: Allow auto in function parameters with default arguments?

2012-09-10 Thread Artur Skawina
On 09/10/12 06:20, Andrej Mitrovic wrote: > It occurred to me that using a parameter with a default value that is > a function call could benefit from using auto: > > struct Foo(T) { } > > auto getFoo() > { > return Foo!int(); > } > > void func(int x, auto

Allow auto in function parameters with default arguments?

2012-09-09 Thread Andrej Mitrovic
It occurred to me that using a parameter with a default value that is a function call could benefit from using auto: struct Foo(T) { } auto getFoo() { return Foo!int(); } void func(int x, auto foo = getFoo()) { } Granted this is a simple case and might be overkill, but if the function

Re: bug with auto or what?

2012-08-13 Thread Chris Cain
On Monday, 13 August 2012 at 19:09:04 UTC, Minas Mina wrote: Is it a bug with auto or something else? It's not really a bug. You're using insert before its return type has been inferred. Hence, it says "forward reference to inferred return type". However, in thi

bug with auto or what?

2012-08-13 Thread Minas Mina
null; } else { if( val < root.value ) root.left = insert(root.left, val); else root.right = insert(root.right, val); } return root; } This works (compiles). auto

Re: Type safety + auto = win!

2012-07-28 Thread Russel Winder
tems, they are a great structuring force. Which > is part of why I love D: "auto" and "Variant" lets you forget > about a lot of it, but you can still be explicit when it is > important. As David and Andrei suggest, it would be good to turn this into a blog post, especial

Re: Type safety + auto = win!

2012-07-27 Thread Andrei Alexandrescu
On 7/27/12 6:25 PM, David Nadlinger wrote: You might want to turn this into a blog post. Yes please. Andrei

Re: Type safety + auto = win!

2012-07-27 Thread David Nadlinger
yping (Python/Ruby/Ecmascript). But when thinking about complicated algorithms and systems, they are a great structuring force. Which is part of why I love D: "auto" and "Variant" lets you forget about a lot of it, but you can still be explicit when it is important. My two cents, NMS

Type safety + auto = win!

2012-07-27 Thread Nathan M. Swan
d become a pain (e.g. Java), hence the popularity of dynamic typing (Python/Ruby/Ecmascript). But when thinking about complicated algorithms and systems, they are a great structuring force. Which is part of why I love D: "auto" and "Variant" lets you forget about a lot of i

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Jonathan M Davis
you'd like the > >> compiler to avoid the copy if it can, I don't see why it's restrictive > >> at all to make> > > That's not what auto-ref does. We already had this discussion. auto-ref > > lets > To clarify - /avoiding a copy/ is not the only,

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Artur Skawina
don't see why it's restrictive at all to make > > That's not what auto-ref does. We already had this discussion. auto-ref lets To clarify - /avoiding a copy/ is not the only, or even the main, use of this feature. Copy avoidance mostly matters for structs, and these cases sh

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Artur Skawina
: >>>>>> On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: >>>>>>> On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis >>>>>>> >>>>>>> wrote: >>>>>>>> And how would that work? auto ref du

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Jonathan M Davis
gt;> > >>> wrote: > >>>> And how would that work? auto ref duplicates the function. If > >>>> you pass it an lvalue, then it generates a ref version. > >>> > >>> Two solutions: > >>> > >>> - Turn 'auto

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Jonathan M Davis
Mehrdad wrote: > >>>>> On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis > >>>>> > >>>>> wrote: > >>>>>> And how would that work? auto ref duplicates the function. If > >>>>>> you pass it a

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread bearophile
Artur Skawina: A new "override ref" could work like you describe. Introducing yet more modifiers and complexity should be done only if they are very useful. Bye, bearophile

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Artur Skawina
On 06/27/12 07:27, kenji hara wrote: > 2012/6/27 Jonathan M Davis : >> On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: >>> On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis >>> >>> wrote: >>>> And how would that work? auto ref duplic

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Timon Gehr
On 06/27/2012 01:12 PM, kenji hara wrote: 2012/6/27 Timon Gehr: On 06/27/2012 07:27 AM, kenji hara wrote: 2012/6/27 Jonathan M Davis: On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis wrote: And how would that work? auto

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread kenji hara
2012/6/27 Timon Gehr : > On 06/27/2012 07:27 AM, kenji hara wrote: >> >> 2012/6/27 Jonathan M Davis: >>> >>> On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: >>> >>>> On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis >>

Re: 'Auto can only be used for template function arguments' what?

2012-06-27 Thread Timon Gehr
On 06/27/2012 07:27 AM, kenji hara wrote: 2012/6/27 Jonathan M Davis: On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis wrote: And how would that work? auto ref duplicates the function. If you pass it an lvalue, then it generates

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Jonathan M Davis
On Wednesday, June 27, 2012 14:27:08 kenji hara wrote: > 2012/6/27 Jonathan M Davis : > > On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: > >> On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis > >> > >> wrote: > >> > And how would

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread kenji hara
2012/6/27 Jonathan M Davis : > On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: >> On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis >> >> wrote: >> > And how would that work? auto ref duplicates the function. If >> > you pass it an lvalue, the

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Jonathan M Davis
On Wednesday, June 27, 2012 07:02:28 Mehrdad wrote: > On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis > > wrote: > > And how would that work? auto ref duplicates the function. If > > you pass it an lvalue, then it generates a ref version. > > Two solut

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Mehrdad
On Wednesday, 27 June 2012 at 04:26:08 UTC, Jonathan M Davis wrote: And how would that work? auto ref duplicates the function. If you pass it an lvalue, then it generates a ref version. Two solutions: - Turn 'auto ref' into 'ref', but simply have the compiler generate a

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Jonathan M Davis
On Wednesday, June 27, 2012 06:03:12 Mehrdad wrote: > On Wednesday, 27 June 2012 at 03:54:12 UTC, Jonathan M Davis > > wrote: > > That isn't legal. auto ref can only be used with templated > > functions. > > > > - Jonathan M Davis > > The trouble

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Mehrdad
On Wednesday, 27 June 2012 at 03:54:12 UTC, Jonathan M Davis wrote: That isn't legal. auto ref can only be used with templated functions. - Jonathan M Davis The trouble is, distinguishing between when it should be illegal seems like a blur to me. Consider all the cases

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Jonathan M Davis
On Wednesday, June 27, 2012 02:54:49 Mehrdad wrote: > On Tuesday, 26 June 2012 at 16:37:30 UTC, Timon Gehr wrote: > > On 06/26/2012 06:17 PM, Mehrdad wrote: > >> void test1(T)(auto ref T) { } > >> void test2() { int a = 5; test1!(int)(a); } > >> >

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Mehrdad
On Tuesday, 26 June 2012 at 16:37:30 UTC, Timon Gehr wrote: On 06/26/2012 06:17 PM, Mehrdad wrote: void test1(T)(auto ref T) { } void test2() { int a = 5; test1!(int)(a); } Is there any reason this should fail? There is not. I suppose the compiler completes instantiation without looking at

Re: 'Auto can only be used for template function arguments' what?

2012-06-26 Thread Timon Gehr
On 06/26/2012 06:17 PM, Mehrdad wrote: void test1(T)(auto ref T) { } void test2() { int a = 5; test1!(int)(a); } Is there any reason this should fail? There is not. I suppose the compiler completes instantiation without looking at the function parameter.

'Auto can only be used for template function arguments' what?

2012-06-26 Thread Mehrdad
void test1(T)(auto ref T) { } void test2() { int a = 5; test1!(int)(a); } Is there any reason this should fail?

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-15 Thread Mehrdad
On Friday, 15 June 2012 at 07:15:50 UTC, Jonathan M Davis wrote: On Friday, June 15, 2012 09:09:48 Don Clugston wrote: On 10/06/12 23:43, Jonathan M Davis wrote: > On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: >> I honestly don't see the POINT of having a "dynamic array >> literal". >> >> Wh

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-15 Thread Jonathan M Davis
On Friday, June 15, 2012 09:09:48 Don Clugston wrote: > On 10/06/12 23:43, Jonathan M Davis wrote: > > On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: > >> I honestly don't see the POINT of having a "dynamic array > >> literal". > >> > >> What's the point of making the literals dynamic? > >> > >

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-15 Thread Don Clugston
On 10/06/12 23:43, Jonathan M Davis wrote: On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: I honestly don't see the POINT of having a "dynamic array literal". What's the point of making the literals dynamic? They should all be static, and only converted to dynamic if necessary from the contex

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-14 Thread Christophe Travert
"Steven Schveighoffer" , dans le message (digitalmars.D:169718), a écrit : > Note that D1 was like this, [1,2,3] was auto-typed to int[3u]. It was a > constant source of pain that I would not like to revisit. Especially > since static arrays are now passed by value.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-14 Thread Christophe Travert
Artur Skawina , dans le message (digitalmars.D:169717), a écrit : > On 06/11/12 12:06, Christophe Travert wrote: >> Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit : >>> auto found = find([1, 2, 3, 4, 5], 3); >> >> No problem if the rule could

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-11 Thread Steven Schveighoffer
27;t understand... could someone give me an example of what would break if we used the rule I suggested? Anything that uses type deduction? Most of the time, you do *not* want a static array, especially for template functions that use IFTI. Note that D1 was like this, [1,2,3] was auto-typed

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-11 Thread Artur Skawina
On 06/11/12 12:06, Christophe Travert wrote: > Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit : >> auto found = find([1, 2, 3, 4, 5], 3); > > No problem if the rule could be the following: > - array literals are static by default > - array literals a

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-11 Thread Christophe Travert
Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit : > auto found = find([1, 2, 3, 4, 5], 3); No problem if the rule could be the following: - array literals are static by default - array literals are copied to the heap when assigned to a dynamic array. - the former r

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 05:09:49 Mehrdad wrote: > On Monday, 11 June 2012 at 03:05:36 UTC, Jonathan M Davis wrote: > > What are you trying to fix beyond assignments to static arrays > > with array literals? > > Just the fact that it would reduce unnecessary heap allocations. > I'm not trying to '

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 03:05:36 UTC, Jonathan M Davis wrote: What are you trying to fix beyond assignments to static arrays with array literals? Just the fact that it would reduce unnecessary heap allocations. I'm not trying to 'fix' it though, as it's not broken. (Then again, neither is i

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
> > Yes, that's precisely why your statement didn't make sense to me. > > :) > : > > But for any templated function which returns a portion of its > > argument, having it take a static array for that argument would > > be horribly broken. For instance, &

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
:) But for any templated function which returns a portion of its argument, having it take a static array for that argument would be horribly broken. For instance, auto found = find([1, 2, 3, 4, 5], 3); _would_ definitely return a slice which referred to garbage were array literals static an

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 04:13:42 Mehrdad wrote: > On Monday, 11 June 2012 at 00:57:45 UTC, Jonathan M Davis wrote: > > And if all range-based functions were altered to work with > > static arrays, and we made array literals static, then this > > example would _still_ be

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 00:57:45 UTC, Jonathan M Davis wrote: And if all range-based functions were altered to work with static arrays, and we made array literals static, then this example would _still_ be broken auto found = find(arr, [1, 2]); Sorry, I don't quite seem to f

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 02:45:00 Mehrdad wrote: > On Monday, 11 June 2012 at 00:16:48 UTC, Jonathan M Davis wrote: > > auto found = find(arr, [1, 2]); > > > > wouldn't compile, because [1, 2] would be considered a static > > array, which > > isn't a

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 00:16:48 UTC, Jonathan M Davis wrote: auto found = find(arr, [1, 2]); wouldn't compile, because [1, 2] would be considered a static array, which isn't a range. - Jonathan M Davis Uh... that's pretty much just saying, "code that explicitly de

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
> > - Jonathan M Davis > > "Type deduction"? o.O > I don't understand... could someone give me an example of what > would break if we used the rule I suggested? Pretty much anything involving templates would break. For instance, auto found = find(arr, [1, 2]); wou

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
Type deduction. Exactly. And if they need to be assigned to a static array, then the compiler can automatically do what it needs to do to avoid the extra heap allocation. - Jonathan M Davis "Type deduction"? o.O I don't understand... could someone give me an example of what would break

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 01:35:41 Timon Gehr wrote: > On 06/11/2012 12:28 AM, Mehrdad wrote: > > Ugh... you keep on saying "on occasion" and "particular case", making it > > seem like it's such a rarity that it's not worth mentioning. > > > > > > > > Regarding your examples: the rule is quite si

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Timon Gehr
On 06/11/2012 12:28 AM, Mehrdad wrote: Ugh... you keep on saying "on occasion" and "particular case", making it seem like it's such a rarity that it's not worth mentioning. Regarding your examples: the rule is quite simple: - Literals are static by default - If they are to be assigned to a dy

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
Ugh... you keep on saying "on occasion" and "particular case", making it seem like it's such a rarity that it's not worth mentioning. Regarding your examples: the rule is quite simple: - Literals are static by default - If they are to be assigned to a dynamic array, then make them dynamic i

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
the context. > > But I really don't see the benefit of allocating them on the heap > just because we can... perhaps someone can enlighten me? In the vast majority of cases where an array literal is used, it's assigned to a dynamic array. And if you do something like auto

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
I honestly don't see the POINT of having a "dynamic array literal". What's the point of making the literals dynamic? They should all be static, and only converted to dynamic if necessary from the context. But I really don't see the benefit of allocating them on the heap just because we can.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Artur Skawina
ou're forced to create one on the stack first. >>>>>>> >>>>>>> int[5] array = [1, 2, 3, 4, 5]; >>>>>>> func(array); >>>>>>> >>>>>> >>>>>> func(cast(int[5])[1,2,3,4,5]); >

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Timon Gehr
Using 'static' is "inventing yet another literal syntax" as well. In a way - yes. But i think "static[...]" would be much better than "[...]S". Obviously, none is much better than the other. ... The isStaticArray!A problem is partially related to how

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Artur Skawina
t we're trying to solve, then that's a matter of fixing the >>>>> optimizer, not the language. >>>>> >>>> >>>> This is not about optimization. Allocating is simply incorrect. It is a >>>> 'wrong code' bug. >&g

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Timon Gehr
cally in these cases, The compiler should do the right thing, not automatically apply a hack that only works for CTFEable right hand sides. right now it doesn't. This hack won't of course work for the program mentioned in this thread. The isStaticArray!A problem is partially related to how

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread d1rulz
writefln(typeof([1, 2, 3, 4, 5]).stringof) is int[5u] in D1 haha.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Artur Skawina
d you've also shown that we don't need a new syntax > to accomplish this. When you want to avoid the heap allocation, you can always use hacks such as: template static_array(alias da) { typeof(da[0])[da.length] static_array = da; } f(...) { int[3] a = static_array!([1

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread mta`chrono
Am 10.06.2012 01:02, schrieb Timon Gehr: > On 06/10/2012 12:34 AM, Jonathan M Davis wrote: >> On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: >>> D static array literals don't perform a costly heap allocation. It is >>> simply a bug in the implementation. This is not a compelling reason to >>>

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Jonathan M Davis
On Sunday, June 10, 2012 01:02:40 Timon Gehr wrote: > On 06/10/2012 12:34 AM, Jonathan M Davis wrote: > > On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: > >> D static array literals don't perform a costly heap allocation. It is > >> simply a bug in the implementation. This is not a compelling

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Alex Rønne Petersen
On 10-06-2012 01:02, Timon Gehr wrote: On 06/10/2012 12:34 AM, Jonathan M Davis wrote: On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: D static array literals don't perform a costly heap allocation. It is simply a bug in the implementation. This is not a compelling reason to add new syntax.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Timon Gehr
On 06/10/2012 12:34 AM, Jonathan M Davis wrote: On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: D static array literals don't perform a costly heap allocation. It is simply a bug in the implementation. This is not a compelling reason to add new syntax. D DMD doesn't _have_ static array

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Jonathan M Davis
On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: > D static array literals don't perform a costly heap allocation. It is > simply a bug in the implementation. This is not a compelling reason to > add new syntax. D doesn't _have_ static array literals. It only has dynamic array literals. int[5]

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Timon Gehr
On 06/10/2012 12:05 AM, timotheecour wrote: (apologies for cross-posting here, I feel this is a better place to ask than in my original post where I only received 1 answer that seemed in favor of this: http://d.puremagic.com/issues/show_bug.cgi?id=8008 which was 2 months ago). Please see to the

static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread timotheecour
; a[1]=i+1; a[2]=i+2;a[3]=i+3;a[4]=i+4;a[5]=i+5;a[6]=i+6;a[7]=i+7;a[8]=i+8;a[9]=i+9; Having the new syntax auto a=[i,i+1,i+2,i+3,i+4,i+5,i+6,i+7,i+8,i+9]S would prevent the intermediate heap allocation and should be at least as fast as the C version, possibly faster if SSE instructions are

Re: Not auto-vectorization

2012-05-22 Thread Martin Nowak
GCC is good, it knows many tricks, it contains a lot of pattern matching code and other code to allow such vectorizations, and that C code is almost transparent & standard (restrict is standard, and I think __builtin_assume_aligned isn't too much hard to #define away when not available. And

Re: Not auto-vectorization

2012-05-22 Thread Andrew Wiley
On Tue, May 22, 2012 at 1:52 PM, bearophile wrote: > On Reddit they have linked an article that shows auto vectorization in GCC > 4.7: > > http://locklessinc.com/**articles/vectorize/<http://locklessinc.com/articles/vectorize/> > > http://www.reddit.com/r/**pr

Re: Not auto-vectorization

2012-05-22 Thread Denis Shelomovskij
22.05.2012 22:52, bearophile написал: How is the development of the D SIMD ops going? Are those efforts (maybe with the help of another higher level Phobos lib) going to avoid the silly problems shown in that article? So the question is: do we need `aligned(T)(T)` function? It can work like cu

Not auto-vectorization

2012-05-22 Thread bearophile
On Reddit they have linked an article that shows auto vectorization in GCC 4.7: http://locklessinc.com/articles/vectorize/ http://www.reddit.com/r/programming/comments/tz6ml/autovectorization_with_gcc_47/ GCC is good, it knows many tricks, it contains a lot of pattern matching code and other

Re: Would it be possible (and useful) to introduce declarations like `auto foo() if(isInputRange(auto)); `

2012-05-17 Thread Jonathan M Davis
On Thursday, May 17, 2012 13:49:16 Roman D. Boiko wrote: > Is there anything preventing us from adding constraints on the > auto function return value? I mean, such language extension seems > to be quite useful. > > For example, it would be no longer necessary to provide meth

Re: Would it be possible (and useful) to introduce declarations like `auto foo() if(isInputRange(auto));

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 21:09:10 UTC, Jonathan M Davis wrote: It would still be necessary, because the compiler needs to know what the actual return type is. Knowing that the type implements popFront, front, and empty isn't enough. It needs to know the actual, physical layout of the type to

Re: Would it be possible (and useful) to introduce declarations like `auto foo() if(isInputRange(auto));

2012-05-17 Thread Jonathan M Davis
0 X-Mailer: GMX.com Web Mailer x-registered: 0 X-GMX-UID: pi3HbzE+3zOlOEKpenAhypZ+IGRvb0CJ On Thursday, May 17, 2012 13:49:16 Roman D. Boiko wrote: > Is there anything preventing us from adding constraints on the > auto function return value? I mean, such language extension seems > to be qui

Re: Would it be possible (and useful) to introduce declarations like `auto foo() if(isInputRange(auto));`

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 11:49:18 UTC, Roman D. Boiko wrote: Is there anything preventing us from adding constraints on the auto function return value? I mean, such language extension seems to be quite useful. For example, it would be no longer necessary to provide method bodies for

Would it be possible (and useful) to introduce declarations like `auto foo() if(isInputRange(auto));`

2012-05-17 Thread Roman D. Boiko
Is there anything preventing us from adding constraints on the auto function return value? I mean, such language extension seems to be quite useful. For example, it would be no longer necessary to provide method bodies for functions with auto return values. In many cases this would

Re: auto + Top-level Const/Immutable

2011-12-20 Thread Michel Fortin
On 2011-12-20 18:39:02 +, Timon Gehr said: On 12/20/2011 07:16 PM, dsimcha wrote: On Tuesday, 20 December 2011 at 17:46:40 UTC, Jonathan M Davis wrote: Assuming that the assignment can still take place, then making auto infer non- const and non-immutable would be an improvement IMHO

Re: auto + Top-level Const/Immutable

2011-12-20 Thread Martin Nowak
On Tue, 20 Dec 2011 19:16:26 +0100, dsimcha wrote: On Tuesday, 20 December 2011 at 17:46:40 UTC, Jonathan M Davis wrote: Assuming that the assignment can still take place, then making auto infer non- const and non-immutable would be an improvement IMHO. However, there _are_ cases where

Re: auto + Top-level Const/Immutable

2011-12-20 Thread Timon Gehr
On 12/20/2011 07:16 PM, dsimcha wrote: On Tuesday, 20 December 2011 at 17:46:40 UTC, Jonathan M Davis wrote: Assuming that the assignment can still take place, then making auto infer non- const and non-immutable would be an improvement IMHO. However, there _are_ cases where you'd have to r

Re: auto + Top-level Const/Immutable

2011-12-20 Thread dsimcha
On Tuesday, 20 December 2011 at 17:46:40 UTC, Jonathan M Davis wrote: Assuming that the assignment can still take place, then making auto infer non- const and non-immutable would be an improvement IMHO. However, there _are_ cases where you'd have to retain const - a prime example being cl

Re: auto + Top-level Const/Immutable

2011-12-20 Thread Jonathan M Davis
On Tuesday, December 20, 2011 09:23:31 dsimcha wrote: > The changes made to IFTI in DMD 2.057 are great, but they reveal another > hassle with getting generic code to play nice with const. > > import std.range, std.array; > > ElementType!R sum(R)(R range) { > if(range.empty)

Re: auto + Top-level Const/Immutable

2011-12-20 Thread Martin Nowak
On Tue, 20 Dec 2011 15:23:31 +0100, dsimcha wrote: The changes made to IFTI in DMD 2.057 are great, but they reveal another hassle with getting generic code to play nice with const. import std.range, std.array; ElementType!R sum(R)(R range) { if(range.empty) return 0; auto ans

auto + Top-level Const/Immutable

2011-12-20 Thread dsimcha
The changes made to IFTI in DMD 2.057 are great, but they reveal another hassle with getting generic code to play nice with const. import std.range, std.array; ElementType!R sum(R)(R range) { if(range.empty) return 0; auto ans = range.front; range.popFront(); foreach(elem

Re: auto testing

2011-12-19 Thread Brad Roberts
On 12/19/2011 4:05 AM, Martin Nowak wrote: > On Sat, 17 Dec 2011 20:54:24 +0100, Brad Roberts wrote: > >> On 12/17/2011 4:56 AM, Robert Clipsham wrote: >>> On 17/12/2011 06:40, Brad Roberts wrote: On 12/16/2011 1:29 PM, Brad Anderson wrote: > On Thu, Dec 15, 2011 at 6:43 PM, Brad >

Re: auto testing

2011-12-19 Thread Martin Nowak
On Sat, 17 Dec 2011 20:54:24 +0100, Brad Roberts wrote: On 12/17/2011 4:56 AM, Robert Clipsham wrote: On 17/12/2011 06:40, Brad Roberts wrote: On 12/16/2011 1:29 PM, Brad Anderson wrote: On Thu, Dec 15, 2011 at 6:43 PM, Brad Robertsmailto:bra...@puremagic.com>> wrote: Left to do:

Re: auto testing

2011-12-17 Thread Brad Roberts
On 12/17/2011 4:56 AM, Robert Clipsham wrote: > On 17/12/2011 06:40, Brad Roberts wrote: >> On 12/16/2011 1:29 PM, Brad Anderson wrote: >>> On Thu, Dec 15, 2011 at 6:43 PM, Brad >>> Robertsmailto:bra...@puremagic.com>> wrote: >>> >>> >>> Left to do: >>> >>> 1) deploy changes to the tes

<    2   3   4   5   6   7   8   9   10   11   >