Re: const/immutable member functions

2011-01-26 Thread Kagamin
spir Wrote: > >> > attribute funcName inputParams -> outputParams { body } > > ReturnType funcAttributes funcName(params) { body } > > So what? So there's no need for FP-style syntax to just disambiguate attribute placing. > > BTW the problem is in separation of function attributes from retur

Re: const/immutable member functions

2011-01-26 Thread spir
On 01/26/2011 11:02 AM, Kagamin wrote: This "problem" happens because D belongs to the C-family of languages which puts the return type_before_ the function name. > > Languages that don't follow this syntactic convention (some would call it a mistake) have it very consistent and readable: >

Re: const/immutable member functions

2011-01-26 Thread Kagamin
foobar Wrote: > This "problem" happens because D belongs to the C-family of languages which > puts the return type _before_ the function name. > > Languages that don't follow this syntactic convention (some would call it a > mistake) have it very consistent and readable: > attribute funcName i

Re: const/immutable member functions

2011-01-25 Thread foobar
so Wrote: > > C++ is indeed complex and one of the reasons is its syntax (believe it > > or not). There was even an academic project to re-syntax C++ with the > > exact same semantics. > > Of course it's not the only cause of complexity in C++ but it is > > definitely one of the main ones. >

Re: const/immutable member functions

2011-01-25 Thread so
C++ is indeed complex and one of the reasons is its syntax (believe it or not). There was even an academic project to re-syntax C++ with the exact same semantics. Of course it's not the only cause of complexity in C++ but it is definitely one of the main ones. If that is the case, you are p

Re: const/immutable member functions

2011-01-25 Thread foobar
so Wrote: > > Here's another perspective: > > A professor that teaches introduction to CS in first semester to > > students that never programmed before needs to choose a programing > > language. One of the criteria for choosing which language to use is of > > course the learning curve. > >

Re: const/immutable member functions

2011-01-25 Thread so
Here's another perspective: A professor that teaches introduction to CS in first semester to students that never programmed before needs to choose a programing language. One of the criteria for choosing which language to use is of course the learning curve. I'm sure you know that not all uni

Re: const/immutable member functions

2011-01-25 Thread foobar
so Wrote: > > Boy you missed the point by about 2.5 light years.. > > This can go forever as long as one of us resist to simple reasoning and > analogy, > and the other one has the energy to continue. > > > All I said is that Since D is English based (terminology, etc) it would > > make sens

Re: const/immutable member functions

2011-01-25 Thread so
Boy you missed the point by about 2.5 light years.. This can go forever as long as one of us resist to simple reasoning and analogy, and the other one has the energy to continue. All I said is that Since D is English based (terminology, etc) it would make sense to follow a more English lik

Re: const/immutable member functions

2011-01-25 Thread spir
On 01/25/2011 10:45 AM, Jens Mueller wrote: I distinguish the following: type qualifiers: const, immutable, maybe also inout function attributes: pure, nothrow storage class: ref, in, out, static access qualifiers: private, package, protected, public, export Nice & clear classification. Then, i

Re: const/immutable member functions

2011-01-25 Thread Jens Mueller
bearophile wrote: > Jens Mueller: > > > I didn't have that impression reading the mentioned bug reports. It > > seems there is more that I'm missing. > > See Walter answers here: > http://d.puremagic.com/issues/show_bug.cgi?id=4070 I'm not getting it. In comment 1 Walter refers to const:, const

Re: const/immutable member functions

2011-01-25 Thread bearophile
Jens Mueller: > I didn't have that impression reading the mentioned bug reports. It > seems there is more that I'm missing. See Walter answers here: http://d.puremagic.com/issues/show_bug.cgi?id=4070 Bye, bearophile

Re: const/immutable member functions

2011-01-25 Thread Jens Mueller
Jonathan M Davis wrote: > On Tuesday 25 January 2011 01:45:49 Jens Mueller wrote: > > > > I do not know what are you referring to when you say function attributes. > > I distinguish the following: > > type qualifiers: const, immutable, maybe also inout > > function attributes: pure, nothrow > > st

Re: const/immutable member functions

2011-01-25 Thread Jonathan M Davis
On Tuesday 25 January 2011 01:45:49 Jens Mueller wrote: > Jonathan M Davis wrote: > > On Monday 24 January 2011 13:52:49 Jens Mueller wrote: > > > Jonathan M Davis wrote: > > > > On Monday 24 January 2011 12:08:29 Don wrote: > > > > > Steven Schveighoffer wrote: > > > > > > On Mon, 24 Jan 2011 13:3

Re: const/immutable member functions

2011-01-25 Thread bearophile
Jens Mueller: > all mean the same. And Walter seems to be unsure whether forbidding > const void foo() is worth the trouble, isn't it? > I see and felt the pain for newcomers to decipher the meaning of > const void foo(); > I see two options: Now I'd like to know what Andrei thinks about this. B

Re: const/immutable member functions

2011-01-25 Thread foobar
so Wrote: > > Look at this from a "It reads like English" prospective and not from a > > "I'm an experienced c++ programmer and therefore already used to this > > crap" perspective. > > In other words, if you were just starting to learn your first > > programming language, what would confuse

Re: const/immutable member functions

2011-01-25 Thread Jens Mueller
Jonathan M Davis wrote: > On Monday 24 January 2011 13:52:49 Jens Mueller wrote: > > Jonathan M Davis wrote: > > > On Monday 24 January 2011 12:08:29 Don wrote: > > > > Steven Schveighoffer wrote: > > > > > On Mon, 24 Jan 2011 13:36:36 -0500, bearophile > > > > > > > > > > wrote: > > > > >> There

Re: const/immutable member functions

2011-01-24 Thread Jonathan M Davis
On Monday 24 January 2011 13:52:49 Jens Mueller wrote: > Jonathan M Davis wrote: > > On Monday 24 January 2011 12:08:29 Don wrote: > > > Steven Schveighoffer wrote: > > > > On Mon, 24 Jan 2011 13:36:36 -0500, bearophile > > > > > > > > wrote: > > > >> There are six, seven or more people that wish

Re: const/immutable member functions

2011-01-24 Thread so
Also, you can't do this in C++. Which was my point. Argh, hate it that you can't edit posts, ignore the second line.

Re: const/immutable member functions

2011-01-24 Thread so
C++ style aka Yoda style: 1. public double func(int input) const; Also, you can't do this in C++. Which was my point.

Re: const/immutable member functions

2011-01-24 Thread so
Look at this from a "It reads like English" prospective and not from a "I'm an experienced c++ programmer and therefore already used to this crap" perspective. In other words, if you were just starting to learn your first programming language, what would confuse you less? If i was starting

Re: const/immutable member functions

2011-01-24 Thread so
Of course C++ has everything :-) See the trailing-return-type feature of C++0x: http://en.wikipedia.org/wiki/C%2B%2B0x#Alternative_function_syntax http://stackoverflow.com/questions/4523617/omit-return-type-in-c0x Bye, bearophile Now i am completely lost, i can't see any connection at all!

Re: const/immutable member functions

2011-01-24 Thread foobar
so Wrote: > > C++ style aka Yoda style: > > 1. public double func(int input) const; > > 2. const double func(int input); > > 3. const double func(int input) const; > > > > VS. > > hypothetical left-to-right style: > > 1. public const func (int input) -> (double); > > 2. func (int input) -> (const

Re: const/immutable member functions

2011-01-24 Thread foobar
bearophile Wrote: > foobar: > > > This "problem" happens because D belongs to the C-family of languages which > > puts the return type _before_ the function name. > > Of course C++ has everything :-) See the trailing-return-type feature of > C++0x: > http://en.wikipedia.org/wiki/C%2B%2B0x#Alte

Re: const/immutable member functions

2011-01-24 Thread so
C++ style aka Yoda style: 1. public double func(int input) const; 2. const double func(int input); 3. const double func(int input) const; VS. hypothetical left-to-right style: 1. public const func (int input) -> (double); 2. func (int input) -> (const double); 3. const func (int input) -> (const

Re: const/immutable member functions

2011-01-24 Thread foobar
so Wrote: > > This "problem" happens because D belongs to the C-family of languages > > which puts the return type _before_ the function name. > > It has nothing to do with being a C-family language. C/C++ don't have > this, and the rules are perfectly clear. > It is just unifying two or more

Re: const/immutable member functions

2011-01-24 Thread bearophile
foobar: > This "problem" happens because D belongs to the C-family of languages which > puts the return type _before_ the function name. Of course C++ has everything :-) See the trailing-return-type feature of C++0x: http://en.wikipedia.org/wiki/C%2B%2B0x#Alternative_function_syntax http://stack

Re: const/immutable member functions

2011-01-24 Thread Torarin
2011/1/24 foobar : > This "problem" happens because D belongs to the C-family of languages which > puts the return type _before_ the function name. > > Languages that don't follow this syntactic convention (some would call it a > mistake) have it very consistent and readable: > attribute funcName

Re: const/immutable member functions

2011-01-24 Thread spir
On 01/24/2011 07:36 PM, bearophile wrote: What other people think about this situation? Do you want const/immutable to be required on the right, or do you prefer the current situation, or do you prefer some other solution? Comparing with C-like typing syntax that, I guess, are planned for dep

Re: const/immutable member functions

2011-01-24 Thread so
This "problem" happens because D belongs to the C-family of languages which puts the return type _before_ the function name. It has nothing to do with being a C-family language. C/C++ don't have this, and the rules are perfectly clear. It is just unifying two or more unrelated things in one s

Re: const/immutable member functions

2011-01-24 Thread foobar
Don Wrote: > Steven Schveighoffer wrote: > > On Mon, 24 Jan 2011 13:36:36 -0500, bearophile > > wrote: > > > >> There are six, seven or more people that wish to do something about > >> this situation. TDPL is the D2 reference, but few little changes over > >> its first edition are acceptable

Re: const/immutable member functions

2011-01-24 Thread Torarin
2011/1/24 Simen kjaeraas : > The suggestion is only for const alone on the left-hand side. const: and > const{} would not be affected by such a change. You're right, it's not confusing at all. It makes perfect sense for function attributes to go on the right. But then I'd like all of them to go th

Re: const/immutable member functions

2011-01-24 Thread Jens Mueller
Jonathan M Davis wrote: > On Monday 24 January 2011 12:08:29 Don wrote: > > Steven Schveighoffer wrote: > > > On Mon, 24 Jan 2011 13:36:36 -0500, bearophile > > > > > > wrote: > > >> There are six, seven or more people that wish to do something about > > >> this situation. TDPL is the D2 referenc

Re: const/immutable member functions

2011-01-24 Thread bearophile
Steven Schveighoffer: > I think we have more important problems to worry about than this. I agree. On the other hand in other languages I've seen that many small troubles pile up and reduce the enjoyment of using a language. Bye, bearophile

Re: const/immutable member functions

2011-01-24 Thread Jonathan M Davis
On Monday 24 January 2011 12:08:29 Don wrote: > Steven Schveighoffer wrote: > > On Mon, 24 Jan 2011 13:36:36 -0500, bearophile > > > > wrote: > >> There are six, seven or more people that wish to do something about > >> this situation. TDPL is the D2 reference, but few little changes over > >> it

Re: const/immutable member functions

2011-01-24 Thread Don
Steven Schveighoffer wrote: On Mon, 24 Jan 2011 13:36:36 -0500, bearophile wrote: There are six, seven or more people that wish to do something about this situation. TDPL is the D2 reference, but few little changes over its first edition are acceptable if they improve the D language a little

Re: const/immutable member functions

2011-01-24 Thread Trass3r
I wouldn't say that I *prefer* the current solution, but the current solution is not so bad that I need it changed. It works fine, despite being confusing. If it wasn't consistent with the rest of the attributes, I'd say it was in need of changes, but it fits within the scheme already outl

Re: const/immutable member functions

2011-01-24 Thread so
I think we have more important problems to worry about than this. IMHO fixing trivial issues first or as soon as possible is better. Not saying this is one of them, i mean generally.

Re: const/immutable member functions

2011-01-24 Thread Simen kjaeraas
Torarin wrote: 2011/1/24 bearophile : What other people think about this situation? Do you want const/immutable to be required on the right, or do you prefer the current situation, or do you prefer some other solution? If const is required to go on the right, what do you do if you want to

Re: const/immutable member functions

2011-01-24 Thread Steven Schveighoffer
On Mon, 24 Jan 2011 13:36:36 -0500, bearophile wrote: There are six, seven or more people that wish to do something about this situation. TDPL is the D2 reference, but few little changes over its first edition are acceptable if they improve the D language a little. - Trass3r: asks if the

Re: const/immutable member functions

2011-01-24 Thread so
On Mon, 24 Jan 2011 20:41:17 +0200, Torarin wrote: 2011/1/24 bearophile : What other people think about this situation? Do you want const/immutable to be required on the right, or do you prefer the current situation, or do you prefer some other solution? If const is required to go on the

Re: const/immutable member functions

2011-01-24 Thread Torarin
2011/1/24 bearophile : > What other people think about this situation? Do you want const/immutable to > be required on the right, or do you prefer the current situation, or do you > prefer some other solution? If const is required to go on the right, what do you do if you want to mark a bunch of

Re: const/immutable member functions

2011-01-24 Thread bearophile
There are six, seven or more people that wish to do something about this situation. TDPL is the D2 reference, but few little changes over its first edition are acceptable if they improve the D language a little. - Trass3r: asks if the code is ambiguous - Jonathan M Davis: does't like it and puts

Re: const/immutable member functions

2011-01-24 Thread Simen kjaeraas
Jonathan M Davis wrote: Only to humans. const applies to everything after it, unless there are parentheses. In this case, 'everything' is Foo bar(); Not quite right. The return value is _not_ const in this case. It's only the function which is affected. Try it and you'll see. The _only_ time

Re: const/immutable member functions

2011-01-24 Thread Kagamin
Trass3r Wrote: > class F > { > const Foo bar(); > } > > Isn't this ambiguous? "returns a const Foo object" vs. "is a const > member function that returns a Foo object"? The const qualifier applies to the member being declared - the function in this case. Usually transitivity rules come into pla

Re: const/immutable member functions

2011-01-24 Thread Steven Schveighoffer
On Mon, 24 Jan 2011 09:39:16 -0500, Jonathan M Davis wrote: On Monday 24 January 2011 06:27:34 Steven Schveighoffer wrote: On Mon, 24 Jan 2011 09:20:17 -0500, Jonathan M Davis wrote: > On Monday 24 January 2011 05:56:49 Trass3r wrote: >> class F >> { >> const Foo bar(); >> } >> >> Isn't

Re: const/immutable member functions

2011-01-24 Thread Jonathan M Davis
On Monday 24 January 2011 06:45:27 Andrej Mitrovic wrote: > Perhaps it would be less ambiguous if we turned const/immutable for > functions into annotations: > > @const Foo bar(); //const function > @immutable Foo bar(); //immutable function > @immutable const(Foo) bar(); //immutable function with

Re: const/immutable member functions

2011-01-24 Thread Andrej Mitrovic
Perhaps it would be less ambiguous if we turned const/immutable for functions into annotations: @const Foo bar(); //const function @immutable Foo bar(); //immutable function @immutable const(Foo) bar(); //immutable function with const return value @const const(Foo) bar(); //const function with con

Re: const/immutable member functions

2011-01-24 Thread Jonathan M Davis
On Monday 24 January 2011 06:27:34 Steven Schveighoffer wrote: > On Mon, 24 Jan 2011 09:20:17 -0500, Jonathan M Davis > > wrote: > > On Monday 24 January 2011 05:56:49 Trass3r wrote: > >> class F > >> { > >> const Foo bar(); > >> } > >> > >> Isn't this ambiguous? "returns a const Foo object" vs.

Re: const/immutable member functions

2011-01-24 Thread Steven Schveighoffer
On Mon, 24 Jan 2011 09:20:17 -0500, Jonathan M Davis wrote: On Monday 24 January 2011 05:56:49 Trass3r wrote: class F { const Foo bar(); } Isn't this ambiguous? "returns a const Foo object" vs. "is a const member function that returns a Foo object"? When using const or immutable in a func

Re: const/immutable member functions

2011-01-24 Thread Jens Mueller
Simen kjaeraas wrote: > Trass3r wrote: > > >class F > >{ > >const Foo bar(); > >} > > > >Isn't this ambiguous? "returns a const Foo object" vs. "is a const > >member function that returns a Foo object"? > > Only to humans. const applies to everything after it, unless there > are parentheses. In

Re: const/immutable member functions

2011-01-24 Thread Jonathan M Davis
On Monday 24 January 2011 06:02:13 Simen kjaeraas wrote: > Trass3r wrote: > > class F > > { > > const Foo bar(); > > } > > > > Isn't this ambiguous? "returns a const Foo object" vs. "is a const > > member function that returns a Foo object"? > > Only to humans. const applies to everything after

Re: const/immutable member functions

2011-01-24 Thread Jonathan M Davis
On Monday 24 January 2011 05:56:49 Trass3r wrote: > class F > { > const Foo bar(); > } > > Isn't this ambiguous? "returns a const Foo object" vs. "is a const > member function that returns a Foo object"? When using const or immutable in a function signature, it _always_ applies to the function,

Re: const/immutable member functions

2011-01-24 Thread Simen kjaeraas
Trass3r wrote: class F { const Foo bar(); } Isn't this ambiguous? "returns a const Foo object" vs. "is a const member function that returns a Foo object"? Only to humans. const applies to everything after it, unless there are parentheses. In this case, 'everything' is Foo bar(); I do agree

const/immutable member functions

2011-01-24 Thread Trass3r
class F { const Foo bar(); } Isn't this ambiguous? "returns a const Foo object" vs. "is a const member function that returns a Foo object"?