Re: Fixing const arrays

2011-12-14 Thread Peter Alexander
On 14/12/11 8:59 PM, Steven Schveighoffer wrote: On Wed, 14 Dec 2011 15:39:55 -0500, Peter Alexander wrote: On 14/12/11 8:16 AM, Timon Gehr wrote: On 12/14/2011 12:35 AM, Peter Alexander wrote: On 13/12/11 11:11 PM, Timon Gehr wrote: On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/

Re: Fixing const arrays

2011-12-14 Thread bearophile
Steven Schveighoffer: > I also don't think dup, reverse, or sort should be array properties. But > these > are pieces of the language that have been there forever. To change them > now would be disruptive for very little gain. sort and reverse properties will be deprecated and later remove

Re: Fixing const arrays

2011-12-14 Thread Steven Schveighoffer
On Wed, 14 Dec 2011 15:39:55 -0500, Peter Alexander wrote: On 14/12/11 8:16 AM, Timon Gehr wrote: On 12/14/2011 12:35 AM, Peter Alexander wrote: On 13/12/11 11:11 PM, Timon Gehr wrote: On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesd

Re: Fixing const arrays

2011-12-14 Thread Timon Gehr
On 12/14/2011 09:39 PM, Peter Alexander wrote: On 14/12/11 8:16 AM, Timon Gehr wrote: On 12/14/2011 12:35 AM, Peter Alexander wrote: On 13/12/11 11:11 PM, Timon Gehr wrote: On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December

Re: Fixing const arrays

2011-12-14 Thread bearophile
Peter Alexander: > Well, it is a little. It makes it difficult to scan code looking for GC > allocations, or even scan code looking for inefficiencies. > > Obviously I know now that I have to look for .length assignments on > arrays, but it can be quite horrific when looking at code that uses

Re: Fixing const arrays

2011-12-14 Thread Peter Alexander
On 14/12/11 8:16 AM, Timon Gehr wrote: On 12/14/2011 12:35 AM, Peter Alexander wrote: On 13/12/11 11:11 PM, Timon Gehr wrote: On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote:

Re: Fixing const arrays

2011-12-14 Thread Regan Heath
On Wed, 14 Dec 2011 13:50:09 -, Michel Fortin wrote: On 2011-12-14 13:27:57 +, "Regan Heath" said: On Wed, 14 Dec 2011 02:36:43 -, Michel Fortin wrote: By "code patterns", you mean something like this? struct Foo { int getBar();

Re: Fixing const arrays

2011-12-14 Thread Andrej Mitrovic
I don't mind @property, usually I just create one property block for a class, e.g.: @property { // funcs.. }

Re: Fixing const arrays

2011-12-14 Thread Steven Schveighoffer
On Tue, 13 Dec 2011 18:08:43 -0500, Andrei Alexandrescu wrote: On 12/13/11 5:14 PM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the la

Re: Fixing const arrays

2011-12-14 Thread Michel Fortin
On 2011-12-14 13:27:57 +, "Regan Heath" said: On Wed, 14 Dec 2011 02:36:43 -, Michel Fortin wrote: By "code patterns", you mean something like this? struct Foo { int getBar(); void setBar(int); } void main() {

Re: Fixing const arrays

2011-12-14 Thread Regan Heath
On Wed, 14 Dec 2011 13:27:57 -, Regan Heath wrote: On Wed, 14 Dec 2011 02:36:43 -, Michel Fortin wrote: On 2011-12-13 23:08:43 +, Andrei Alexandrescu said: We could have inferred property intention from the code pattern, without requiring any keyword. That solution (whi

Re: Fixing const arrays

2011-12-14 Thread Regan Heath
On Wed, 14 Dec 2011 02:36:43 -, Michel Fortin wrote: On 2011-12-13 23:08:43 +, Andrei Alexandrescu said: We could have inferred property intention from the code pattern, without requiring any keyword. That solution (which was discussed and rejected in this newsgroup) was miles

Re: Fixing const arrays

2011-12-14 Thread bearophile
Jonathan M Davis: > I tend to avoid const ranges precisely because they pretty much never work. > I'd use them more if a tail-const version of them were easily obtainable - This is what I was trying to answer to Andrei :-) Bye, bearophile

Re: Fixing const arrays

2011-12-14 Thread simendsjo
On 13.12.2011 23:17, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the lake into the well". I believe the English version is "Out of the frying pan, into the fire" :) The Norwegian ver

Re: Fixing const arrays

2011-12-14 Thread Timon Gehr
On 12/14/2011 12:35 AM, Peter Alexander wrote: On 13/12/11 11:11 PM, Timon Gehr wrote: On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quit

Re: Fixing const arrays

2011-12-13 Thread Jonathan M Davis
On Tuesday, December 13, 2011 21:36:43 Michel Fortin wrote: > On 2011-12-13 23:08:43 +, Andrei Alexandrescu > > said: > > We could have inferred property intention from the code pattern, > > without requiring any keyword. That solution (which was discussed and > > rejected in this newsgroup)

Re: Fixing const arrays

2011-12-13 Thread Michel Fortin
On 2011-12-13 23:08:43 +, Andrei Alexandrescu said: We could have inferred property intention from the code pattern, without requiring any keyword. That solution (which was discussed and rejected in this newsgroup) was miles ahead from the drivel of @property we have now. By "code patt

Re: Fixing const arrays

2011-12-13 Thread Jonathan M Davis
On Sunday, December 11, 2011 02:05:08 Andrei Alexandrescu wrote: > On 12/11/11 1:30 AM, Jonathan M Davis wrote: > > On Sunday, December 11, 2011 01:16:28 Andrei Alexandrescu wrote: > >> To truly confer user-defined types the same capability, we should > >> define > >> opPassByValue() which is impli

Re: Fixing const arrays

2011-12-13 Thread Peter Alexander
On 13/12/11 11:11 PM, Timon Gehr wrote: On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the lake into the well". I be

Re: Fixing const arrays

2011-12-13 Thread Timon Gehr
On 12/14/2011 12:14 AM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the lake into the well". I believe the English version is "Out of the

Re: Fixing const arrays

2011-12-13 Thread Andrei Alexandrescu
On 12/13/11 5:14 PM, Peter Alexander wrote: On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the lake into the well". I believe the English version is "Out of the fry

Re: Fixing const arrays

2011-12-13 Thread Peter Alexander
On 13/12/11 10:17 PM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the lake into the well". I believe the English version is "Out of the frying pan, into the fire" :) Inconsequential s

Re: Fixing const arrays

2011-12-13 Thread Vladimir Panteleev
On Monday, 12 December 2011 at 15:32:05 UTC, Jakob Ovrum wrote: (Unrelated side-note: I am using the web interface and I'm not well seasoned with using newsgroups, is there a better way to reply to multiple small posts than replying to each individually like I just did? I apologize if I'm being

Re: Fixing const arrays

2011-12-13 Thread Vladimir Panteleev
On Tuesday, 13 December 2011 at 21:10:22 UTC, Andrei Alexandrescu wrote: There's a phrase in Romanian that quite applies: "From the lake into the well". I believe the English version is "Out of the frying pan, into the fire" :) Inconsequential space-filler opinion: I am OK with @property, m

Re: Fixing const arrays

2011-12-13 Thread Andrei Alexandrescu
On 12/13/11 2:25 PM, Jonathan M Davis wrote: On Tuesday, December 13, 2011 14:02:51 Andrei Alexandrescu wrote: On 12/13/11 10:32 AM, Jonathan M Davis wrote: On Monday, December 12, 2011 18:00:35 Andrei Alexandrescu wrote: On 12/12/11 1:12 PM, Jonathan M Davis wrote: On Monday, December 12, 20

Re: Fixing const arrays

2011-12-13 Thread Jonathan M Davis
On Tuesday, December 13, 2011 12:25:12 Jonathan M Davis wrote: > On Tuesday, December 13, 2011 14:02:51 Andrei Alexandrescu wrote: > > On 12/13/11 10:32 AM, Jonathan M Davis wrote: > > > On Monday, December 12, 2011 18:00:35 Andrei Alexandrescu wrote: > > >> On 12/12/11 1:12 PM, Jonathan M Davis wr

Re: Fixing const arrays

2011-12-13 Thread Jonathan M Davis
On Tuesday, December 13, 2011 14:02:51 Andrei Alexandrescu wrote: > On 12/13/11 10:32 AM, Jonathan M Davis wrote: > > On Monday, December 12, 2011 18:00:35 Andrei Alexandrescu wrote: > >> On 12/12/11 1:12 PM, Jonathan M Davis wrote: > >>> On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wr

Re: Fixing const arrays

2011-12-13 Thread Andrei Alexandrescu
On 12/13/11 10:32 AM, Jonathan M Davis wrote: On Monday, December 12, 2011 18:00:35 Andrei Alexandrescu wrote: On 12/12/11 1:12 PM, Jonathan M Davis wrote: On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wrote: Insisting on the current property semantics was a sizeable mistake of thi

Re: Fixing const arrays

2011-12-13 Thread Jonathan M Davis
On Monday, December 12, 2011 18:00:35 Andrei Alexandrescu wrote: > On 12/12/11 1:12 PM, Jonathan M Davis wrote: > > On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wrote: > >> Insisting on the current property semantics was a sizeable mistake of > >> this community, and I am sorry we gave

Re: Fixing const arrays

2011-12-13 Thread Timon Gehr
On 12/13/2011 01:08 AM, Steven Schveighoffer wrote: On Mon, 12 Dec 2011 19:00:35 -0500, Andrei Alexandrescu wrote: On 12/12/11 1:12 PM, Jonathan M Davis wrote: On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wrote: Insisting on the current property semantics was a sizeable mistake

Re: Fixing const arrays

2011-12-12 Thread torhu
On 13.12.2011 02:39, Jonathan M Davis wrote: On Tuesday, December 13, 2011 02:28:29 torhu wrote: It's actually not 'save' being a noun that's the problem. I just thought of a counter-example: --- struct Foo { // the data Bar data[]; // save data on shutdown? @property bool save() { return save

Re: Fixing const arrays

2011-12-12 Thread Jonathan M Davis
On Tuesday, December 13, 2011 02:28:29 torhu wrote: > It's actually not 'save' being a noun that's the problem. I just > thought of a counter-example: > > --- > struct Foo { > // the data > Bar data[]; > > // save data on shutdown? > @property bool save() { return save_; } > @property bool save(b

Re: Fixing const arrays

2011-12-12 Thread torhu
On 12.12.2011 20:03, Jonathan M Davis wrote: On Monday, December 12, 2011 09:16:53 Andrei Alexandrescu wrote: On 12/12/11 9:09 AM, torhu wrote: > On 12.12.2011 15:43, Andrei Alexandrescu wrote: >> On 12/12/11 6:24 AM, torhu wrote: >>> save being a property is a stupid inconsistency. >>

Re: Fixing const arrays

2011-12-12 Thread Steven Schveighoffer
On Mon, 12 Dec 2011 19:00:35 -0500, Andrei Alexandrescu wrote: On 12/12/11 1:12 PM, Jonathan M Davis wrote: On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wrote: Insisting on the current property semantics was a sizeable mistake of this community, and I am sorry we gave into it.

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 1:12 PM, Jonathan M Davis wrote: On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wrote: Insisting on the current property semantics was a sizeable mistake of this community, and I am sorry we gave into it. Aside from the fact that the behavior of -property isn't the defau

Re: Fixing const arrays

2011-12-12 Thread Jonathan M Davis
On Monday, December 12, 2011 17:24:38 Jakob Ovrum wrote: > I'm still a beginner with ranges, but by my understanding and by > what some people made it sound like, reasonable uses of save > include some which are non-trivial. If this is true, then > removing @property from save encourages people to

Re: Fixing const arrays

2011-12-12 Thread Jonathan M Davis
On Monday, December 12, 2011 08:46:18 Andrei Alexandrescu wrote: > Insisting on the current property semantics was a sizeable mistake of > this community, and I am sorry we gave into it. Aside from the fact that the behavior of -property isn't the default, what's the problem with @property? - Jo

Re: Fixing const arrays

2011-12-12 Thread Jonathan M Davis
On Monday, December 12, 2011 09:16:53 Andrei Alexandrescu wrote: > On 12/12/11 9:09 AM, torhu wrote: > > On 12.12.2011 15:43, Andrei Alexandrescu wrote: > >> On 12/12/11 6:24 AM, torhu wrote: > >>> save being a property is a stupid inconsistency. > >> > >> I'm not so sure. > >> > >> Andrei > > >

Re: Fixing const arrays

2011-12-12 Thread Peter Alexander
On 12/12/11 3:16 PM, Andrei Alexandrescu wrote: On 12/12/11 9:09 AM, torhu wrote: On 12.12.2011 15:43, Andrei Alexandrescu wrote: On 12/12/11 6:24 AM, torhu wrote: save being a property is a stupid inconsistency. I'm not so sure. Andrei Why? As far as I can tell, it's inconsistent with wh

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 16:09:03 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:29 AM, Jakob Ovrum wrote: On Monday, 12 December 2011 at 15:14:02 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:07 AM, Jakob Ovrum wrote: If the programmer sees just "r.save", he doesn't know whether it's a f

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 9:29 AM, Jakob Ovrum wrote: On Monday, 12 December 2011 at 15:14:02 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:07 AM, Jakob Ovrum wrote: If the programmer sees just "r.save", he doesn't know whether it's a field or a property, and he shouldn't need to know, it should be fast and

Re: Fixing const arrays

2011-12-12 Thread torhu
On 12.12.2011 16:16, Andrei Alexandrescu wrote: On 12/12/11 9:09 AM, torhu wrote: On 12.12.2011 15:43, Andrei Alexandrescu wrote: On 12/12/11 6:24 AM, torhu wrote: save being a property is a stupid inconsistency. I'm not so sure. Andrei Why? As far as I can tell, it's inconsistent w

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 15:29:26 UTC, Jakob Ovrum wrote: On Monday, 12 December 2011 at 15:14:02 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:07 AM, Jakob Ovrum wrote: If the programmer sees just "r.save", he doesn't know whether it's a field or a property, and he shouldn't need to kno

Re: Fixing const arrays

2011-12-12 Thread Timon Gehr
On 12/12/2011 04:29 PM, Jakob Ovrum wrote: On Monday, 12 December 2011 at 15:14:02 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:07 AM, Jakob Ovrum wrote: If the programmer sees just "r.save", he doesn't know whether it's a field or a property, and he shouldn't need to know, it should be fast a

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 15:21:31 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:07 AM, Jakob Ovrum wrote: The old situation where you could write complete nonsense code like `std.file.read = "foo.txt";` is far worse. We could have defined a system much better than both. Andrei I def

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 15:14:02 UTC, Andrei Alexandrescu wrote: On 12/12/11 9:07 AM, Jakob Ovrum wrote: If the programmer sees just "r.save", he doesn't know whether it's a field or a property, and he shouldn't need to know, it should be fast and cheap, and return a consistent value. A

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 15:16:56 UTC, Adam D. Ruppe wrote: On Monday, 12 December 2011 at 15:07:16 UTC, Jakob Ovrum wrote: The old situation where you could write complete nonsense code like `std.file.read = "foo.txt";` is far worse. If we start removing features because someone can use

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 9:07 AM, Jakob Ovrum wrote: The old situation where you could write complete nonsense code like `std.file.read = "foo.txt";` is far worse. We could have defined a system much better than both. Andrei

Re: Fixing const arrays

2011-12-12 Thread Adam D. Ruppe
On Monday, 12 December 2011 at 15:07:16 UTC, Jakob Ovrum wrote: The old situation where you could write complete nonsense code like `std.file.read = "foo.txt";` is far worse. If we start removing features because someone can use them when deliberately obfuscating their code, we might as well ju

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 9:09 AM, torhu wrote: On 12.12.2011 15:43, Andrei Alexandrescu wrote: On 12/12/11 6:24 AM, torhu wrote: save being a property is a stupid inconsistency. I'm not so sure. Andrei Why? As far as I can tell, it's inconsistent with what properties are used like in other programming

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 9:07 AM, Jakob Ovrum wrote: If the programmer sees just "r.save", he doesn't know whether it's a field or a property, and he shouldn't need to know, it should be fast and cheap, and return a consistent value. As far as I know, this isn't always true for save Why? Save does behave li

Re: Fixing const arrays

2011-12-12 Thread torhu
On 12.12.2011 15:43, Andrei Alexandrescu wrote: On 12/12/11 6:24 AM, torhu wrote: save being a property is a stupid inconsistency. I'm not so sure. Andrei Why? As far as I can tell, it's inconsistent with what properties are used like in other programming languages. Saving something is

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 14:46:17 UTC, Andrei Alexandrescu wrote: On 12/12/11 6:49 AM, Manu wrote: I think every opportunity should be taken to make important breaking changes while the community is as small as it is. Changing from r.save to r.save() is NOT an important change. It make

Re: Fixing const arrays

2011-12-12 Thread Adam D. Ruppe
On Monday, 12 December 2011 at 12:38:10 UTC, Jakob Ovrum wrote: Furthermore, there weren't even a way to enforce the property syntax until lately, and it's still not enabled by default. The real WTF is that someone decided @property should be used for anything more than disambiguation.

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 6:49 AM, Manu wrote: I think every opportunity should be taken to make important breaking changes while the community is as small as it is. Changing from r.save to r.save() is NOT an important change. It makes no semantic difference, marks no progress, and has no consequence. Ins

Re: Fixing const arrays

2011-12-12 Thread Andrei Alexandrescu
On 12/12/11 6:24 AM, torhu wrote: save being a property is a stupid inconsistency. I'm not so sure. Andrei

Re: Fixing const arrays

2011-12-12 Thread Jacob Carlborg
On 2011-12-11 13:46, Michel Fortin wrote: On 2011-12-11 07:16:28 +, Andrei Alexandrescu said: On 12/10/11 5:20 PM, Michel Fortin wrote: Also seems strange to me that class references aren't included in that list, but then I though about how tail-const still doesn't work with objects. You'

Re: Fixing const arrays

2011-12-12 Thread Steven Schveighoffer
On Sun, 11 Dec 2011 16:34:34 -0500, Jonathan M Davis wrote: On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: On 12/11/11 9:46 AM, dsimcha wrote: > On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: >> We decided to fix this issue by automatically shedding the top-level >> cons

Re: Fixing const arrays

2011-12-12 Thread Steven Schveighoffer
On Sun, 11 Dec 2011 06:16:33 -0500, Mehrdad wrote: On 12/11/2011 2:56 AM, David Nadlinger wrote: On 12/11/11 10:04 AM, Mehrdad wrote: On 12/11/2011 12:57 AM, Andrei Alexandrescu wrote: I think you should write: auto copy = this.save; Ah good point, I forgot about that. Idk then. (You forg

Re: Fixing const arrays

2011-12-12 Thread Michel Fortin
On 2011-12-12 12:38:09 +, "Jakob Ovrum" said: Furthermore, there weren't even a way to enforce the property syntax until lately, and it's still not enabled by default. If we change it right now, people still have time to adapt before the backwards-compatibility argument even kicks in (no

Re: Fixing const arrays

2011-12-12 Thread Manu
On 12 December 2011 14:24, torhu wrote: > On 11.12.2011 22:24, Jonathan M Davis wrote: > ... > > It was debated some time ago, and it ended up being a property. The fact >> that >> save is an action verb and not a noun automatically disqualifies it as a >> property IMHO, but it was made into a p

Re: Fixing const arrays

2011-12-12 Thread Jakob Ovrum
On Monday, 12 December 2011 at 12:24:53 UTC, torhu wrote: On 11.12.2011 22:24, Jonathan M Davis wrote: ... It was debated some time ago, and it ended up being a property. The fact that save is an action verb and not a noun automatically disqualifies it as a property IMHO, but it was made into a

Re: Fixing const arrays

2011-12-12 Thread torhu
On 11.12.2011 22:24, Jonathan M Davis wrote: ... It was debated some time ago, and it ended up being a property. The fact that save is an action verb and not a noun automatically disqualifies it as a property IMHO, but it was made into a property, and we're pretty much stuck with it at some point

Re: Fixing const arrays

2011-12-12 Thread Max Samukha
On 12/11/2011 11:24 PM, Jonathan M Davis wrote: On Sunday, December 11, 2011 14:54:27 Tobias Pankrath wrote: Specifically: "Properties should behave as if they are fields; if the method cannot, it should not be changed to a property. Methods are better than properties in the following situation

Re: Fixing const arrays

2011-12-12 Thread Max Samukha
On 12/12/2011 12:33 AM, deadalnix wrote: I think you misunderstood the idea. The point was to remove constness of something passed by value, as long as it possible (native types, pointer (but not pointee), slices (but not what is in the slice), structs as long as they have no indirection in them)

Re: Fixing const arrays

2011-12-11 Thread Andrei Alexandrescu
On 12/11/11 4:19 PM, Jonathan M Davis wrote: On Sunday, December 11, 2011 23:13:39 Timon Gehr wrote: On 12/11/2011 10:34 PM, Jonathan M Davis wrote: On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandrescu

Re: Fixing const arrays

2011-12-11 Thread deadalnix
Le 11/12/2011 22:34, Jonathan M Davis a écrit : On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: We decided to fix this issue by automatically shedding the top-level const when passing an arra

Re: Fixing const arrays

2011-12-11 Thread Timon Gehr
On 12/11/2011 11:19 PM, Jonathan M Davis wrote: On Sunday, December 11, 2011 23:13:39 Timon Gehr wrote: On 12/11/2011 10:34 PM, Jonathan M Davis wrote: On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandres

Re: Fixing const arrays

2011-12-11 Thread Jonathan M Davis
On Sunday, December 11, 2011 23:13:39 Timon Gehr wrote: > On 12/11/2011 10:34 PM, Jonathan M Davis wrote: > > On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: > >> On 12/11/11 9:46 AM, dsimcha wrote: > >>> On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: > We decided to fix th

Re: Fixing const arrays

2011-12-11 Thread Timon Gehr
On 12/11/2011 10:34 PM, Jonathan M Davis wrote: On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: We decided to fix this issue by automatically shedding the top-level const when passing an arra

Re: Fixing const arrays

2011-12-11 Thread Jonathan M Davis
On Sunday, December 11, 2011 10:34:40 Andrei Alexandrescu wrote: > On 12/11/11 9:46 AM, dsimcha wrote: > > On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: > >> We decided to fix this issue by automatically shedding the top-level > >> const when passing an array or a pointer by value into a functi

Re: Fixing const arrays

2011-12-11 Thread Jonathan M Davis
On Sunday, December 11, 2011 14:54:27 Tobias Pankrath wrote: > > Specifically: > > > > "Properties should behave as if they are fields; if the method cannot, > > it should not be changed to a property. > > Methods are better than properties in the following situations: > > > > - Calling the metho

Re: Fixing const arrays

2011-12-11 Thread Timon Gehr
On 12/11/2011 05:34 PM, Andrei Alexandrescu wrote: On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: We decided to fix this issue by automatically shedding the top-level const when passing an array or a pointer by value into a function. Really silly questio

Re: Fixing const arrays

2011-12-11 Thread deadalnix
Le 11/12/2011 17:34, Andrei Alexandrescu a écrit : On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: We decided to fix this issue by automatically shedding the top-level const when passing an array or a pointer by value into a function. Really silly questio

Re: Fixing const arrays

2011-12-11 Thread Andrei Alexandrescu
On 12/11/11 9:46 AM, dsimcha wrote: On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: We decided to fix this issue by automatically shedding the top-level const when passing an array or a pointer by value into a function. Really silly question: Why not do the same for primitives (int, float, c

Re: Fixing const arrays

2011-12-11 Thread dsimcha
On 12/10/2011 4:47 PM, Andrei Alexandrescu wrote: We decided to fix this issue by automatically shedding the top-level const when passing an array or a pointer by value into a function. Really silly question: Why not do the same for primitives (int, float, char, etc.) or even structs without

Re: Fixing const arrays

2011-12-11 Thread Tobias Pankrath
> Specifically: > > "Properties should behave as if they are fields; if the method cannot, > it should not be changed to a property. > Methods are better than properties in the following situations: > > - Calling the method two times in succession creates different results. > - The method perform

Re: Fixing const arrays

2011-12-11 Thread Michel Fortin
On 2011-12-11 07:16:28 +, Andrei Alexandrescu said: On 12/10/11 5:20 PM, Michel Fortin wrote: Also seems strange to me that class references aren't included in that list, but then I though about how tail-const still doesn't work with objects. You'd need my const(Object)ref patch to make t

Re: Fixing const arrays

2011-12-11 Thread Mehrdad
On 12/11/2011 1:54 AM, Walter Bright wrote: Try the new beta http://ftp.digitalmars.com/dmd2beta.zip WHOA nice, the reduce() example worked!! :D Thanks for taking the time to fix it! I'll post if I come across similar/related problems. :)

Re: Fixing const arrays

2011-12-11 Thread Mehrdad
On 12/11/2011 2:56 AM, David Nadlinger wrote: On 12/11/11 10:04 AM, Mehrdad wrote: On 12/11/2011 12:57 AM, Andrei Alexandrescu wrote: I think you should write: auto copy = this.save; Ah good point, I forgot about that. Idk then. (You forgot the parentheses though. :P) No, it's correct like

Re: Fixing const arrays

2011-12-11 Thread David Nadlinger
On 12/11/11 10:04 AM, Mehrdad wrote: On 12/11/2011 12:57 AM, Andrei Alexandrescu wrote: I think you should write: auto copy = this.save; Ah good point, I forgot about that. Idk then. (You forgot the parentheses though. :P) No, it's correct like that, save() is a @property. Even though I re

Re: Fixing const arrays

2011-12-11 Thread Walter Bright
On 12/11/2011 1:04 AM, Mehrdad wrote: On 12/11/2011 12:57 AM, Andrei Alexandrescu wrote: I think you should write: auto copy = this.save; Andrei Ah good point, I forgot about that. Idk then. (You forgot the parentheses though. :P) Try the new beta http://ftp.digitalmars.com/dmd2beta.zip

Re: Fixing const arrays

2011-12-11 Thread Mehrdad
On 12/11/2011 12:57 AM, Andrei Alexandrescu wrote: I think you should write: auto copy = this.save; Andrei Ah good point, I forgot about that. Idk then. (You forgot the parentheses though. :P)

Re: Fixing const arrays

2011-12-11 Thread Andrei Alexandrescu
On 12/11/11 2:36 AM, Mehrdad wrote: On 12/11/2011 12:14 AM, Andrei Alexandrescu wrote: What do you do inside that method? It's reasonable to not expect to change it. Andrei Not sure right now, but something along the lines of auto copy = this; foreach (v; copy) ; sounds like code I've d

Re: Fixing const arrays

2011-12-11 Thread Andrei Alexandrescu
On 12/11/11 2:48 AM, bearophile wrote: Andrei Alexandrescu: I'm not sure. How many times have you been in a place in life where you had a const range on your hands, that's not an array? I haven't. How many times I have used reduce or map on constant arrays in D2? Only few times, using a cast(

Re: Fixing const arrays

2011-12-11 Thread bearophile
Andrei Alexandrescu: > I'm not sure. How many times have you been in a place in life where you > had a const range on your hands, that's not an array? I haven't. How many times I have used reduce or map on constant arrays in D2? Only few times, using a cast(). Now I am using them. Bye, bearoph

Re: Fixing const arrays

2011-12-11 Thread Mehrdad
On 12/11/2011 12:14 AM, Andrei Alexandrescu wrote: What do you do inside that method? It's reasonable to not expect to change it. Andrei Not sure right now, but something along the lines of auto copy = this; foreach (v; copy) ; sounds like code I've definitely seen befo

Re: Fixing const arrays

2011-12-11 Thread Andrei Alexandrescu
On 12/11/11 2:08 AM, Mehrdad wrote: On 12/11/2011 12:05 AM, Andrei Alexandrescu wrote: I'm not sure. How many times have you been in a place in life where you had a const range on your hands, that's not an array? I haven't. Andrei Hmmm.. isn't that precisely what happens when you define a 'co

Re: Fixing const arrays

2011-12-11 Thread Mehrdad
On 12/11/2011 12:05 AM, Andrei Alexandrescu wrote: I'm not sure. How many times have you been in a place in life where you had a const range on your hands, that's not an array? I haven't. Andrei Hmmm.. isn't that precisely what happens when you define a 'const' method for your (custom) range

Re: Fixing const arrays

2011-12-11 Thread Andrei Alexandrescu
On 12/11/11 1:30 AM, Jonathan M Davis wrote: On Sunday, December 11, 2011 01:16:28 Andrei Alexandrescu wrote: To truly confer user-defined types the same capability, we should define opPassByValue() which is implicitly invoked whenever an object is passed by value into a function. By default tha

Re: Fixing const arrays

2011-12-10 Thread Jonathan M Davis
On Sunday, December 11, 2011 01:16:28 Andrei Alexandrescu wrote: > On 12/10/11 5:20 PM, Michel Fortin wrote: > > On 2011-12-10 21:47:13 +, Andrei Alexandrescu > > > > said: > >> We decided to fix this issue by automatically shedding the top-level > >> const when passing an array or a pointer

Re: Fixing const arrays

2011-12-10 Thread Andrei Alexandrescu
On 12/10/11 5:20 PM, Michel Fortin wrote: On 2011-12-10 21:47:13 +, Andrei Alexandrescu said: We decided to fix this issue by automatically shedding the top-level const when passing an array or a pointer by value into a function. It seems strange that if you implemented the exact same se

Re: Fixing const arrays

2011-12-10 Thread Andrei Alexandrescu
On 12/10/11 6:24 PM, kenji hara wrote: Posted a test patch to realize the suggestion. https://github.com/D-Programming-Language/dmd/pull/554 Kenji Hara Many thanks, Kenji, for executing so fast on this! Andrei

Re: Fixing const arrays

2011-12-10 Thread kenji hara
Posted a test patch to realize the suggestion. https://github.com/D-Programming-Language/dmd/pull/554 Kenji Hara 2011/12/11 kenji hara : > OK. I agree to the suggestion. > > I've been afraid that increasing IFTI rule is making the language > learning difficult. > It comes from the experience from

Re: Fixing const arrays

2011-12-10 Thread Michel Fortin
On 2011-12-10 21:47:13 +, Andrei Alexandrescu said: We decided to fix this issue by automatically shedding the top-level const when passing an array or a pointer by value into a function. It seems strange that if you implemented the exact same semantic as an a dynamic array or a pointer

Re: Fixing const arrays

2011-12-10 Thread kenji hara
OK. I agree to the suggestion. I've been afraid that increasing IFTI rule is making the language learning difficult. It comes from the experience from implementing inout deduction for template function. But also it is useful that removing top const when passing arguments by value. C++ precedent c

Re: Fixing const arrays

2011-12-10 Thread Jonathan M Davis
On Sunday, December 11, 2011 08:01:57 kenji hara wrote: > 2011/12/11 bearophile : > > kenji hara: > >> It breaks IFTI rule, > > > > What do you mean? > > I mean following code comment will not become true. > > void func(T)(T prm){} > void main(){ >X arg; >func(arg); // T is deduced to t

Re: Fixing const arrays

2011-12-10 Thread Timon Gehr
On 12/10/2011 11:41 PM, Andrei Alexandrescu wrote: On 12/10/11 4:31 PM, kenji hara wrote: Treating whole constant arrays as ranges by automatically shedding the top-level const is good. But realizing it by language semantic change is definitely bad.It breaks IFTI rule, and adding special case wi

Re: Fixing const arrays

2011-12-10 Thread kenji hara
2011/12/11 Andrei Alexandrescu : > On 12/10/11 4:31 PM, kenji hara wrote: >> >> Treating whole constant arrays as ranges by automatically shedding the >> top-level const is good. >> But realizing it by language semantic change is definitely bad.It >> breaks IFTI rule, and adding special case will m

Re: Fixing const arrays

2011-12-10 Thread kenji hara
2011/12/11 bearophile : > kenji hara: > >> It breaks IFTI rule, > > What do you mean? I mean following code comment will not become true. void func(T)(T prm){} void main(){ X arg; func(arg); // T is deduced to typeof(arg) } > > >> and adding special case will make difficult to learn langu

  1   2   >