Re: const int vs. int const

2014-08-17 Thread bearophile via Digitalmars-d
Jonathan M Davis: Well, it _does_ follow the language spec, so it's not broken in that sense, but it's a broken design IMHO in that it causes confusion and bugs, and it has resulted in complaints in the past and will continue to do so until it's changed. So, I do think that it's true that

Re: const int vs. int const

2014-08-17 Thread Francesco Cattoglio via Digitalmars-d
On Saturday, 16 August 2014 at 21:42:59 UTC, Jonathan M Davis wrote: On Saturday, 16 August 2014 at 18:50:08 UTC, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains.

Re: const int vs. int const

2014-08-16 Thread Jacob Carlborg via Digitalmars-d
On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains. -- /Jacob Carlborg

Re: const int vs. int const

2014-08-16 Thread Walter Bright via Digitalmars-d
On 8/16/2014 11:50 AM, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains. Yes, and for this case it is not worth it.

Re: const int vs. int const

2014-08-16 Thread Fool via Digitalmars-d
On Saturday, 16 August 2014 at 19:23:48 UTC, Walter Bright wrote: Yes, and for this case it is not worth it. This shows one more time that D needs a tool (similar to gofix) that allows automatic conversion of source code compatible with version x to code compatible with version x + 1.

Re: const int vs. int const

2014-08-16 Thread Jonathan M Davis via Digitalmars-d
On Saturday, 16 August 2014 at 18:50:08 UTC, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains. Yes, but it's either that or have people running into this problem

Re: const int vs. int const

2014-08-16 Thread Mike via Digitalmars-d
On Saturday, 16 August 2014 at 18:50:08 UTC, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains. ... and not breaking it will include the same complaints years from

Re: const int vs. int const

2014-08-16 Thread Mike via Digitalmars-d
On Saturday, 16 August 2014 at 19:23:48 UTC, Walter Bright wrote: On 8/16/2014 11:50 AM, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains. Yes, and for this case

Re: const int vs. int const

2014-08-16 Thread ketmar via Digitalmars-d
On Sat, 16 Aug 2014 12:23:49 -0700 Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: Yes, and for this case it is not worth it. it worth it. we can fix alot of such things while our userbase is relatively small. we will be doomed to live with this legacy when userbase becomes

Re: const int vs. int const

2014-08-16 Thread Mike via Digitalmars-d
On Saturday, 16 August 2014 at 19:43:36 UTC, Fool wrote: On Saturday, 16 August 2014 at 19:23:48 UTC, Walter Bright wrote: Yes, and for this case it is not worth it. This shows one more time that D needs a tool (similar to gofix) that allows automatic conversion of source code compatible

Re: const int vs. int const

2014-08-16 Thread Mike via Digitalmars-d
On Saturday, 16 August 2014 at 23:39:59 UTC, Mike wrote: On Saturday, 16 August 2014 at 18:50:08 UTC, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to me. Which will include the usual complains. ... and

Re: const int vs. int const

2014-08-16 Thread Jonathan M Davis via Digitalmars-d
On Sunday, 17 August 2014 at 02:44:26 UTC, Mike wrote: On Saturday, 16 August 2014 at 23:39:59 UTC, Mike wrote: On Saturday, 16 August 2014 at 18:50:08 UTC, Jacob Carlborg wrote: On 2014-08-16 01:33, Mike wrote: Sounds like a worthwhile impromement to me. Sounds like a breaking change to

const int vs. int const

2014-08-15 Thread John via Digitalmars-d
This may be a silly issue, but I recently read the better practice is to begin with the variable type followed by const keyword, but that order doesn't work in D. Is that intentional? int const minWage = 11; //Error: no identifier for declarator int //const int minWage = 11; //works

Re: const int vs. int const

2014-08-15 Thread Sean Kelly via Digitalmars-d
On Friday, 15 August 2014 at 17:05:55 UTC, John wrote: This may be a silly issue, but I recently read the better practice is to begin with the variable type followed by const keyword, but that order doesn't work in D. Is that intentional? int const minWage = 11; //Error: no identifier for

Re: const int vs. int const

2014-08-15 Thread John via Digitalmars-d
On Friday, 15 August 2014 at 17:16:45 UTC, Sean Kelly wrote: On Friday, 15 August 2014 at 17:05:55 UTC, John wrote: This may be a silly issue, but I recently read the better practice is to begin with the variable type followed by const keyword, but that order doesn't work in D. Is that

Re: const int vs. int const

2014-08-15 Thread John via Digitalmars-d
On Friday, 15 August 2014 at 17:05:55 UTC, John wrote: This may be a silly issue, but I recently read the better practice is to begin with the variable type followed by const keyword, but that order doesn't work in D. Is that intentional? int const minWage = 11; //Error: no identifier for

Re: const int vs. int const

2014-08-15 Thread H. S. Teoh via Digitalmars-d
On Fri, Aug 15, 2014 at 05:05:53PM +, John via Digitalmars-d wrote: This may be a silly issue, but I recently read the better practice is to begin with the variable type followed by const keyword, but that order doesn't work in D. Is that intentional? int const minWage = 11; //Error:

Re: const int vs. int const

2014-08-15 Thread Timon Gehr via Digitalmars-d
On 08/15/2014 07:18 PM, John wrote: btw, it works either way if I use auto auto const minWage = 11; //works const auto minWage = 11; //works ... auto does not serve any purpose here. The same flexibility is missing when the actual type is used. In particular, auto is not a wild-card type

Re: const int vs. int const

2014-08-15 Thread Walter Bright via Digitalmars-d
On 8/15/2014 10:45 AM, H. S. Teoh via Digitalmars-d wrote: Nah, the better practice is to write const(int) instead of const int, which is ambiguous when used to specify a function's return value. For example, const int func(); is *not* the same as: const(int) func(); which

Re: const int vs. int const

2014-08-15 Thread eles via Digitalmars-d
On Friday, 15 August 2014 at 18:47:49 UTC, Walter Bright wrote: On 8/15/2014 10:45 AM, H. S. Teoh via Digitalmars-d wrote: It is not ambiguous from a semantic or syntactic point of view, but it appears to be ambiguous for those coming from C++. This I like this example from the C world:

Re: const int vs. int const

2014-08-15 Thread Walter Bright via Digitalmars-d
On 8/15/2014 12:06 PM, eles wrote: But, I agree, I am a follower of the rule: const is written after and applies to everything that comes left of it. That rule can never work for D. Remember, D's const is transitive.

Re: const int vs. int const

2014-08-15 Thread eles via Digitalmars-d
On Friday, 15 August 2014 at 19:14:10 UTC, Walter Bright wrote: On 8/15/2014 12:06 PM, eles wrote: That rule can never work for D. Remember, D's const is transitive. Thank you. I was aware. I was speaking about my C-style.

Re: const int vs. int const

2014-08-15 Thread Jonathan M Davis via Digitalmars-d
On Friday, 15 August 2014 at 18:47:49 UTC, Walter Bright wrote: It is not ambiguous from a semantic or syntactic point of view, but it appears to be ambiguous for those coming from C++. This was discussed at length a few years ago, but no solution emerged that didn't make things much worse.

Re: const int vs. int const

2014-08-15 Thread Jonathan M Davis via Digitalmars-d
On Friday, 15 August 2014 at 18:23:47 UTC, Timon Gehr wrote: On 08/15/2014 07:18 PM, John wrote: btw, it works either way if I use auto auto const minWage = 11; //works const auto minWage = 11; //works ... auto does not serve any purpose here. The same flexibility is missing when the

Re: const int vs. int const

2014-08-15 Thread ketmar via Digitalmars-d
On Fri, 15 Aug 2014 21:08:08 + Jonathan M Davis via Digitalmars-d digitalmars-d@puremagic.com wrote: I still think that we'd be far better off if all attributes which could apply to a function's return type were illegal on the left-hand side of the function. i completely agree. even if

Re: const int vs. int const

2014-08-15 Thread H. S. Teoh via Digitalmars-d
On Fri, Aug 15, 2014 at 09:08:08PM +, Jonathan M Davis via Digitalmars-d wrote: On Friday, 15 August 2014 at 18:47:49 UTC, Walter Bright wrote: It is not ambiguous from a semantic or syntactic point of view, but it appears to be ambiguous for those coming from C++. This was discussed at

Re: const int vs. int const

2014-08-15 Thread Mike via Digitalmars-d
On Friday, 15 August 2014 at 21:08:10 UTC, Jonathan M Davis wrote: I still think that we'd be far better off if all attributes which could apply to a function's return type were illegal on the left-hand side of the function. All allowing it on the left does is cause confusion and bugs. It's