www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - too much sugar not good for the health

reply Neal Becker <ndbecker2 gmail.com> writes:
Reading through "D Specification", I'm a bit surprised.  I believe the goal
of D is to be a clean, improved C++.  Yet, there are a number of instances
where syntactic 'sugar' is added in ways that seem almost arbitrary.  The
latest example I found is 'Functions as Array Properties'.  I'm not sure
what overwhelming need this syntax fulfills, maybe I'm missing something.

There is a lot of extra conceptual overhead in adding extra syntax.  One
might argue that "You don't have use it if you don't like it.".  That is,
unfortunately, not really true.  If other's use it and I have to grok there
code, I need to understand the extra rules.

I've been following D with great interest.  I hope the language will not add
such 'features' without great need - it really detracts from the purity and
simplicity.
Mar 21 2007
next sibling parent Johan Granberg <lijat.meREM OVE.gmail.com> writes:
Neal Becker wrote:

 Reading through "D Specification", I'm a bit surprised.  I believe the
 goal
 of D is to be a clean, improved C++.  Yet, there are a number of instances
 where syntactic 'sugar' is added in ways that seem almost arbitrary.  The
 latest example I found is 'Functions as Array Properties'.  I'm not sure
 what overwhelming need this syntax fulfills, maybe I'm missing something.
 
 There is a lot of extra conceptual overhead in adding extra syntax.  One
 might argue that "You don't have use it if you don't like it.".  That is,
 unfortunately, not really true.  If other's use it and I have to grok
 there code, I need to understand the extra rules.
 
 I've been following D with great interest.  I hope the language will not
 add such 'features' without great need - it really detracts from the
 purity and simplicity.

I agree that to much features is a bad idea. But I don't feel that the array property syntax is an unneeded feature, rather I fell that it should be generalized to cover all types and not just arrays. (It could be used to replace methods but I don't think that would be a good idea for D, at least not in the shot term)
Mar 21 2007
prev sibling next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Neal Becker" <ndbecker2 gmail.com> wrote in message 
news:etr33u$46c$1 digitalmars.com...
 I've been following D with great interest.  I hope the language will not 
 add
 such 'features' without great need - it really detracts from the purity 
 and
 simplicity.

The only response I have to this is: have a look at Java to see a language with virtually no sugar. It's so bland and unexpressive it _hurts_. A tiny bit of sugar can go a long way to making the language more intuitive to use, not just prettier.
Mar 21 2007
next sibling parent reply janderson <askme me.com> writes:
Jarrett Billingsley wrote:
 "Neal Becker" <ndbecker2 gmail.com> wrote in message 
 news:etr33u$46c$1 digitalmars.com...
 I've been following D with great interest.  I hope the language will not 
 add
 such 'features' without great need - it really detracts from the purity 
 and
 simplicity.

The only response I have to this is: have a look at Java to see a language with virtually no sugar. It's so bland and unexpressive it _hurts_. A tiny bit of sugar can go a long way to making the language more intuitive to use, not just prettier.

Agreed. Even Java are adding more an more sugar with each release. Also reading all that bland code takes more time to learn then simply learning a new feature. Personally I don't think D is anywhere near the threshold of having to much. Take a look at the most successful langugage (English), it keeps getting bigger and bigger every day. We just don't have enough syntax to describe everything. Really, for a beginner learning D its not that much more to learn. Having said that, I'm still learning things about C++ (after 10years) and it is meant to be one of the smaller languages (well not compared with java, but anyhow). I think its more to do with the unexpected and sometimes weird behaviors of its syntax. I have no problem figuring out what I think D is more straight forward, things work as expected and will often encourage/replace well established design patterns. D may have more terms however many replace what would otherwise be a more complicated in C++. Which all adds up to getting more done in less time. It only takes a minute or 2 to learn a new concept. If you use it more then twice, then you've probably got that time back. -Joel
Mar 21 2007
parent reply janderson <askme me.com> writes:
Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:
 
 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become. I guess, once a word is added to the English language it doesn't go away easily. English reached the 1-million mark last year. I've heard that most people stick to around 2000 world in their everyday speak. I think languages will slowly converge into one universal language being made up primarily of English (although its name may change). I think programming languages and file formats will be one of the biggest driving forces behind this. Since most people want technology and much of it is English at some level. http://www.literacytrust.org.uk/Database/language.html -Joel
Mar 22 2007
next sibling parent reply Walter Bright <newshound digitalmars.com> writes:
janderson wrote:
 I guess, once a word is added to the English language it doesn't go away 
  easily.  English reached the 1-million mark last year.  I've heard that 
 most people stick to around 2000 world in their everyday speak.  I think 
 languages will slowly converge into one universal language being made up 
 primarily of English (although its name may change).

What I read about English: 1,000,000 total number of words 30,000 vocabulary of college graduate 10,000 vocabulary of high school graduate 2,000 vocabulary of TV shows What this tells me is one could become reasonably fluent in a language by learning just 2,000 words.
Mar 22 2007
next sibling parent Jeff Nowakowski <jeff dilacero.org> writes:
Walter Bright wrote:
 What this tells me is one could become reasonably fluent in a language 
 by learning just 2,000 words.

Syntax is more like grammar than vocabulary. -Jeff
Mar 23 2007
prev sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Walter Bright Wrote:

<snip>
 What I read about English:
 
 1,000,000 total number of words
 30,000 vocabulary of college graduate
 10,000 vocabulary of high school graduate
 2,000 vocabulary of TV shows

But considering the possible interpretations of the word "word", are you sure they're all talking in the same units? Stewart.
Mar 23 2007
parent Walter Bright <newshound digitalmars.com> writes:
Stewart Gordon wrote:
 Walter Bright Wrote:
 
 <snip>
 What I read about English:

 1,000,000 total number of words
 30,000 vocabulary of college graduate
 10,000 vocabulary of high school graduate
 2,000 vocabulary of TV shows

But considering the possible interpretations of the word "word", are you sure they're all talking in the same units?

Since it was one source, I presume it was using the same definition.
Mar 23 2007
prev sibling next sibling parent reply Ary Manzana <ary esperanto.org.ar> writes:
janderson escribió:
 Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become.

English is not succesful because of the language itself, but because of other reasons (power, articles, books). Just like Java is succesful but nowhere near because of the language (I guess VM, nice documentation system, IDEs). Maybe D should consider becoming succesful by other means besides of the language itself? :-) Ary
Mar 23 2007
next sibling parent reply Walter Bright <newshound digitalmars.com> writes:
Ary Manzana wrote:
 English is not succesful because of the language itself, but because of 
 other reasons (power, articles, books). Just like Java is succesful but 
 nowhere near because of the language (I guess VM, nice documentation 
 system, IDEs).

One reason English is successful is its shamelessness in adopting useful words and phrases from other languages. Sort of like what D does <g>.
Mar 23 2007
next sibling parent reply torhu <fake address.dude> writes:
Walter Bright wrote:
 Ary Manzana wrote:
 English is not succesful because of the language itself, but because of 
 other reasons (power, articles, books). Just like Java is succesful but 
 nowhere near because of the language (I guess VM, nice documentation 
 system, IDEs).

One reason English is successful is its shamelessness in adopting useful words and phrases from other languages. Sort of like what D does <g>.

This isn't quite true. English is 'successful' because of the dominating position of the US, and earlier the UK. People very rarely choose between languages based on how 'good' they are. On the other hand, two thirds of the English vocabulary is supposed to originate from Latin.
Mar 24 2007
parent reply Walter Bright <newshound digitalmars.com> writes:
torhu wrote:
 Walter Bright wrote:
 Ary Manzana wrote:
 English is not succesful because of the language itself, but because 
 of other reasons (power, articles, books). Just like Java is 
 succesful but nowhere near because of the language (I guess VM, nice 
 documentation system, IDEs).

One reason English is successful is its shamelessness in adopting useful words and phrases from other languages. Sort of like what D does <g>.

This isn't quite true. English is 'successful' because of the dominating position of the US, and earlier the UK. People very rarely choose between languages based on how 'good' they are. On the other hand, two thirds of the English vocabulary is supposed to originate from Latin.

I did say one reason - there are many. Some languages look inward, not wanting to accept foreign words. English, as you say, is mostly foreign words. Like the blob, English tends to absorb whatever it comes in contact with <g>.
Mar 24 2007
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Walter Bright Wrote:

 torhu wrote:
 Walter Bright wrote:


 One reason English is successful is its shamelessness in 
 adopting useful words and phrases from other languages.  
 Sort of like what D does <g>.

This isn't quite true. English is 'successful' because of the dominating position of the US, and earlier the UK.


 I did say one reason - there are many.  Some languages look 
 inward, not wanting to accept foreign words.  English, as you 
 say, is mostly foreign words.  Like the blob, English tends to 
 absorb whatever it comes in contact with <g>.

Interesting. But where does that put Esperanto, with its basic vocabulary being a mixture of languages but having compound words (and translations of Latin abbreviations) all its own? Stewart.
Mar 24 2007
parent reply Kevin Bealer <kevinbealer gmail.com> writes:
Stewart Gordon wrote:
 Walter Bright Wrote:
 
 torhu wrote:
 Walter Bright wrote:


 One reason English is successful is its shamelessness in 
 adopting useful words and phrases from other languages.  
 Sort of like what D does <g>.

the dominating position of the US, and earlier the UK.


 I did say one reason - there are many.  Some languages look 
 inward, not wanting to accept foreign words.  English, as you 
 say, is mostly foreign words.  Like the blob, English tends to 
 absorb whatever it comes in contact with <g>.

Interesting. But where does that put Esperanto, with its basic vocabulary being a mixture of languages but having compound words (and

 Latin abbreviations) all its own?
 
 Stewart.

A few steps behind Klingon, I would expect. But (slightly more) seriously, Esperanto seems like a cautionary tale for those who would design computer (and other synthetic) languages, in that it tried to solve a compatibility problem without actually motivating anyone to adopt it in any material way. It has aesthetics but no special 'killer features'. Now, if esperanto had array slicing... Kevin
Apr 02 2007
parent Dan <murpsoft hotmail.com> writes:
Kevin Bealer Wrote:
 A few steps behind Klingon, I would expect.
 
 But (slightly more) seriously, Esperanto seems like a cautionary tale 
 for those who would design computer (and other synthetic) languages,
 in that it tried to solve a compatibility problem without actually
 motivating anyone to adopt it in any material way.  It has aesthetics
 but no special 'killer features'.
 
 Now, if esperanto had array slicing...

Hehe. yeah, I took Linguistics in the first part of university and got rather involved in language theory. I thought it was an excellent exercise creating an isolating morphology, VSO, CV, with semantic/phonetic enhancements.. Ultimately though, spoken language will be irrelevant with the implementation of the DNI - so inventing a spoken language that won't be spoken is folly. DNI has killer features. Like array slicing. : )
Apr 03 2007
prev sibling parent reply Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Walter Bright wrote:
 Ary Manzana wrote:
 English is not succesful because of the language itself, but because 
 of other reasons (power, articles, books). Just like Java is succesful 
 but nowhere near because of the language (I guess VM, nice 
 documentation system, IDEs).

One reason English is successful is its shamelessness in adopting useful words and phrases from other languages. Sort of like what D does <g>.

Huh? I'm under the impression that that also happens a lot in other languages. In fact it likely happens much more often in other languages, who borrow a lot of *english* words in these modern times. ;) -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Mar 24 2007
parent reply Walter Bright <newshound digitalmars.com> writes:
Bruno Medeiros wrote:
 Walter Bright wrote:
 One reason English is successful is its shamelessness in adopting 
 useful words and phrases from other languages. Sort of like what D 
 does <g>.

Huh? I'm under the impression that that also happens a lot in other languages.

Yes, it does. But some actively work to try and prevent this.
 In fact it likely happens much more often in other languages, 
 who borrow a lot of *english* words in these modern times. ;)

Sure, and I suspect that a language that refuses to do so is one that will fade away into irrelevance.
Mar 24 2007
parent torhu <fake address.dude> writes:
Walter Bright wrote:
 Bruno Medeiros wrote:
 Walter Bright wrote:
 One reason English is successful is its shamelessness in adopting 
 useful words and phrases from other languages. Sort of like what D 
 does <g>.

Huh? I'm under the impression that that also happens a lot in other languages.

Yes, it does. But some actively work to try and prevent this.
 In fact it likely happens much more often in other languages, 
 who borrow a lot of *english* words in these modern times. ;)

Sure, and I suspect that a language that refuses to do so is one that will fade away into irrelevance.

The languages that I'm aware of that do this, also create replacement words. If not, people will just use the foreign words, they often do anyway. One example would be Icelandic. I don't see how a living language would become 'irrelevant' because of the lack of words. People create, alternatively 'borrow' the words they need. But I'm sure there are counter-examples anyway. A language generally dies when parents teach their children another language in place of their own mother tongue, because they consider their own language to be of little use to them. After a couple of generations there is noone left that can speak the original language. This also probably happens when all the users of the language are spread to areas where other languages dominate, so the concentration of users is too low to keep the language alive, maybe there is little of use the language in writing, etc.
Mar 25 2007
prev sibling next sibling parent reply Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Ary Manzana wrote:
 janderson escribió:
 Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become.

English is not succesful because of the language itself, but because of other reasons (power, articles, books). Just like Java is succesful but nowhere near because of the language (I guess VM, nice documentation system, IDEs). Maybe D should consider becoming succesful by other means besides of the language itself? :-) Ary

Man, I am the only programmer to actually (moderately) like the Java language? :P -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Mar 24 2007
next sibling parent "David B. Held" <dheld codelogicconsulting.com> writes:
Bruno Medeiros wrote:
 [...]
 Man, I am the only programmer to actually (moderately) like the Java 
 language? :P

I think for many people it's language envy because Java is so unreasonably successful. For others it's just plain language parochialism. I happen to think Java is a great language, and obviously researchers love how easy it is to extend. That doesn't mean I think Java is always the most appropriate language or that it doesn't have any warts, but the same is true for C++, D, Perl, and any other language you can think of. Dave
Mar 24 2007
prev sibling parent Ary Manzana <ary esperanto.org.ar> writes:
Bruno Medeiros escribió:
 Ary Manzana wrote:
 janderson escribió:
 Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it 
 keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become.

English is not succesful because of the language itself, but because of other reasons (power, articles, books). Just like Java is succesful but nowhere near because of the language (I guess VM, nice documentation system, IDEs). Maybe D should consider becoming succesful by other means besides of the language itself? :-) Ary

Man, I am the only programmer to actually (moderately) like the Java language? :P

I like Java a lot because of all those things. Having seen the video about Java closures, and being a Java programmer for about six years I realize it has some drawbacks, and that some code is larger than it should. But, on the other hand, there are great tools that makes those problems fade away... (or makes you think so :-P)
Mar 24 2007
prev sibling parent janderson <askme me.com> writes:
Ary Manzana wrote:
 janderson escribió:
 Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become.

English is not succesful because of the language itself, but because of other reasons (power, articles, books). Just like Java is succesful but nowhere near because of the language (I guess VM, nice documentation system, IDEs). Maybe D should consider becoming succesful by other means besides of the language itself? :-) Ary

Neither Java or English would have any chance of being successful if it was difficult to learn. Of course there are better languages out there however what I'm saying is that less then 100 terms in D is extremely tiny by comparison to the monster that is English. A learning language is great, I don't think D should have to be written in infinite speak just so new people can get it (there are other languages for that). It should be written so that we can produce less bug prone code at a faster rate. When you come across a term/grammar that you haven't seen before, you should be able to learn it from the surrounding code 90% of the time. -Joel
Mar 24 2007
prev sibling parent reply Charlie <charlie.fats gmail.com> writes:
I think
 languages will slowly converge into one universal language being made up
 primarily of English (although its name may change).

My bets on chinese ;). janderson wrote:
 Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become. I guess, once a word is added to the English language it doesn't go away easily. English reached the 1-million mark last year. I've heard that most people stick to around 2000 world in their everyday speak. I think languages will slowly converge into one universal language being made up primarily of English (although its name may change). I think programming languages and file formats will be one of the biggest driving forces behind this. Since most people want technology and much of it is English at some level. http://www.literacytrust.org.uk/Database/language.html -Joel

Mar 24 2007
next sibling parent Sean Kelly <sean f4.ca> writes:
Charlie wrote:
 I think
  > languages will slowly converge into one universal language being made up
  > primarily of English (although its name may change).
 
 My bets on chinese ;).

http://en.wikipedia.org/wiki/Chung_Kuo Great series, but hard to track down (it's out of print).
Mar 24 2007
prev sibling parent janderson <askme me.com> writes:
Charlie wrote:
 I think
  > languages will slowly converge into one universal language being made up
  > primarily of English (although its name may change).
 
 My bets on chinese ;).

You may be right. One interesting fact is that China has the biggest speaking English population in the world.
 
 janderson wrote:
 Falk-Florian Henrich wrote:
 Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk

By successful I mean most widely used, which is what we want D to become. I guess, once a word is added to the English language it doesn't go away easily. English reached the 1-million mark last year. I've heard that most people stick to around 2000 world in their everyday speak. I think languages will slowly converge into one universal language being made up primarily of English (although its name may change). I think programming languages and file formats will be one of the biggest driving forces behind this. Since most people want technology and much of it is English at some level. http://www.literacytrust.org.uk/Database/language.html -Joel


Mar 24 2007
prev sibling parent Falk-Florian Henrich <schreibmalwieder hammerfort.de> writes:
Am Wed, 21 Mar 2007 08:16:08 -0700 schrieb janderson:

 Jarrett Billingsley wrote:
 Personally I don't think D is anywhere near the threshold of having to
 much.  Take a look at the most successful langugage (English), it keeps
 getting bigger and bigger every day.  We just don't have enough syntax
 to describe everything.

Without discussing what "successful" is supposed to mean in the realm of natural languages, I think the syntax of English is shrinking rather than growing. Plus, today's lingua franca is a tiny subset of English with a type discipline comparable to that of K&R C. Apart from that, I agree with you that D's syntax is a lot easier to understand than that of C++. Falk
Mar 21 2007
prev sibling next sibling parent reply Davidl <Davidl 126.com> writes:
it's totally not arbitrary. since AA in D is a container, but we lack of
method to operate on it and even more with any resort to add method for it
on user land.
So functions as Array Properties in a language with AA is a must. it looks
beautiful, and we can extend our AA with funcs and they work as methods  
like
way. it's reasonable. i used to think in ur way either. But after u post
this, and i consider the AA's func stuff, i finally realize why we don't  
get
rid of this feature.

 Reading through "D Specification", I'm a bit surprised.  I believe the  
 goal
 of D is to be a clean, improved C++.  Yet, there are a number of  
 instances
 where syntactic 'sugar' is added in ways that seem almost arbitrary.  The
 latest example I found is 'Functions as Array Properties'.  I'm not sure
 what overwhelming need this syntax fulfills, maybe I'm missing something.

 There is a lot of extra conceptual overhead in adding extra syntax.  One
 might argue that "You don't have use it if you don't like it.".  That is,
 unfortunately, not really true.  If other's use it and I have to grok  
 there
 code, I need to understand the extra rules.

 I've been following D with great interest.  I hope the language will not  
 add
 such 'features' without great need - it really detracts from the purity  
 and
 simplicity.

Mar 21 2007
next sibling parent reply "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> writes:
Davidl wrote:
 it's totally not arbitrary. since AA in D is a container, but we lack of
 method to operate on it and even more with any resort to add method for it
 on user land.
 So functions as Array Properties in a language with AA is a must. it looks
 beautiful, and we can extend our AA with funcs and they work as methods 
 like
 way. it's reasonable. i used to think in ur way either. But after u post
 this, and i consider the AA's func stuff, i finally realize why we don't 
 get
 rid of this feature.

We definitely should get rid of the shameful .sort and .reverse though. Andrei
Mar 21 2007
next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Andrei Alexandrescu (See Website For Email) Wrote:
<snip>
 We definitely should get rid of the shameful .sort and .reverse 
 though.

What is shameful about them? Stewart.
Mar 21 2007
parent reply "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> writes:
Stewart Gordon wrote:
 Andrei Alexandrescu (See Website For Email) Wrote:
 <snip>
 We definitely should get rid of the shameful .sort and .reverse 
 though.

What is shameful about them?

They should be free functions, and sort should also allow a predicate. Andrei
Mar 21 2007
next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Andrei Alexandrescu (See Website For Email) Wrote:

 Stewart Gordon wrote:
 Andrei Alexandrescu (See Website For Email) Wrote:
 We definitely should get rid of the shameful .sort and 
 .reverse though.

What is shameful about them?

They should be free functions,

What do you mean?
 and sort should also allow a predicate.

If you mean a comparator, it's been said already. But how would getting rid of it fix that problem? Stewart.
Mar 21 2007
parent "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> writes:
Stewart Gordon wrote:
 Andrei Alexandrescu (See Website For Email) Wrote:
 
 Stewart Gordon wrote:
 Andrei Alexandrescu (See Website For Email) Wrote:
 We definitely should get rid of the shameful .sort and 
 .reverse though.



What do you mean?
 and sort should also allow a predicate.

If you mean a comparator, it's been said already. But how would getting rid of it fix that problem?

The problem is that reverse and sort should be, as in STL, algorithms decoupled from the container they work on. Andrei
Mar 21 2007
prev sibling parent Sean Kelly <sean f4.ca> writes:
Andrei Alexandrescu (See Website For Email) wrote:
 Stewart Gordon wrote:
 Andrei Alexandrescu (See Website For Email) Wrote:
 <snip>
 We definitely should get rid of the shameful .sort and .reverse though.

What is shameful about them?

They should be free functions, and sort should also allow a predicate.

I agree. But until then, adding such free functions fortunately does not conflict with the built-in properties so long as the free functions require parameters. For the record, Tango has a predicate-based sort routine in tango.core.Array. It currently performs about the same as the built-in routine. Sean
Mar 21 2007
prev sibling parent Derek Parnell <derek nomail.afraid.org> writes:
On Wed, 21 Mar 2007 08:53:07 -0700, Andrei Alexandrescu (See Website For
Email) wrote:

 So functions as Array Properties in a language with AA is a must.


 We definitely should get rid of the shameful .sort and .reverse though.

... and replace them with more suitable implementations as I'm sure the functionality is in itself useful (i.e. I use it in my code <g>) -- Derek (skype: derek.j.parnell) Melbourne, Australia "Justice for David Hicks!" 22/03/2007 9:23:09 AM
Mar 21 2007
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Davidl Wrote:

 it's totally not arbitrary.  since AA in D is a container, but 
 we lack of method to operate on it and even more with any 
 resort to add method for it on user land.  So functions as 
 Array Properties in a language with AA is a must.  it looks 
 beautiful, and we can extend our AA with funcs and they work 
 as methods  like way.  it's reasonable.  i used to think in ur 
 way either.  But after u post this, and i consider the AA's 
 func stuff, i finally realize why we don't  get rid of this 
 feature.

I've never been sure about this feature. The notation makes it look as though the property is part of the type, when it could be part of the code that's using someone else's type. This gets more complicated when you try allowing it for structs and classes. But even sillier is this: ---------- import std.stdio; class Qwert { int yuiop(int[] asdfg) { return asdfg[0]; } int hjkl(int[] asdfg) { return asdfg.yuiop(); } } void main() { Qwert zxcvb = new Qwert; writefln(zxcvb.hjkl([3, 4, 5])); } ---------- Moreover, why is the doc calling them properties, even though it doesn't work without the ()? Another way that extending basic types could have been implemented is by enhanced typedefs. For example: typedef char[] String { char[] toUpper() { ... } } Stewart.
Mar 21 2007
prev sibling parent reply Alexander Panek <a.panek brainsware.org> writes:
Neal Becker wrote:
 Reading through "D Specification", I'm a bit surprised.  I believe the goal
 of D is to be a clean, improved C++.  Yet, there are a number of instances
 where syntactic 'sugar' is added in ways that seem almost arbitrary.  The
 latest example I found is 'Functions as Array Properties'.  I'm not sure
 what overwhelming need this syntax fulfills, maybe I'm missing something.
 
 There is a lot of extra conceptual overhead in adding extra syntax.  One
 might argue that "You don't have use it if you don't like it.".  That is,
 unfortunately, not really true.  If other's use it and I have to grok there
 code, I need to understand the extra rules.
 
 I've been following D with great interest.  I hope the language will not add
 such 'features' without great need - it really detracts from the purity and
 simplicity.

You have a point, though the beauty & readability of D pretty much nullifies that. The syntax sugar that is added so far does not actually complicate the parsing so much, so D's syntax can still be seen as clean, IMHO.
Mar 21 2007
parent reply "David B. Held" <dheld codelogicconsulting.com> writes:
Alexander Panek wrote:
 [...]
 You have a point, though the beauty & readability of D pretty much 
 nullifies that. The syntax sugar that is added so far does not actually 
 complicate the parsing so much, so D's syntax can still be seen as 
 clean, IMHO.

I think the ridiculous size of the front-end is a pretty good existence proof. Take a look, Neal. Dave
Mar 21 2007
next sibling parent reply "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> writes:
David B. Held wrote:
 Alexander Panek wrote:
 [...]
 You have a point, though the beauty & readability of D pretty much 
 nullifies that. The syntax sugar that is added so far does not 
 actually complicate the parsing so much, so D's syntax can still be 
 seen as clean, IMHO.

I think the ridiculous size of the front-end is a pretty good existence proof. Take a look, Neal.

Take a look at Polyglot. Even Java syntax is heinous to parse. Andrei
Mar 21 2007
next sibling parent Dan <murpsoft hotmail.com> writes:
Andrei Alexandrescu (See Website For Email) Wrote:

 David B. Held wrote:
 Alexander Panek wrote:
 [...]
 You have a point, though the beauty & readability of D pretty much 
 nullifies that. The syntax sugar that is added so far does not 
 actually complicate the parsing so much, so D's syntax can still be 
 seen as clean, IMHO.

I think the ridiculous size of the front-end is a pretty good existence proof. Take a look, Neal.

Take a look at Polyglot. Even Java syntax is heinous to parse.

Oh my! We all know that D's front end is bad, Java's is heinous, and C++ is starting to become a moral issue (it's just WRONG! you may cry) That said, I agree with the above. Arrays should not have a native, non-library sort or reverse "property" that's really a method. We should and can also bind methods to AA's, or build our own structures that act like AA's and attach methods to them. Essentially all you need to do is populate the associative array with function*'s. You may have to dereference them...
Mar 21 2007
prev sibling parent "David B. Held" <dheld codelogicconsulting.com> writes:
Andrei Alexandrescu (See Website For Email) wrote:
 David B. Held wrote:
 Alexander Panek wrote:
 [...]
 You have a point, though the beauty & readability of D pretty much 
 nullifies that. The syntax sugar that is added so far does not 
 actually complicate the parsing so much, so D's syntax can still be 
 seen as clean, IMHO.

I think the ridiculous size of the front-end is a pretty good existence proof. Take a look, Neal.

Take a look at Polyglot. Even Java syntax is heinous to parse.

Actually, D's front-end was a lot smaller than I was expecting. Only 1.5 MB of C++ code, whereas g++ is almost 4 MB tarred & zipped. Granted, that includes a backend, but if I recall correctly, gcc's source is around 20 MB uncompressed (though with how many front-ends, I'm not sure). Dave
Mar 21 2007
prev sibling parent reply "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail erdani.org> writes:
David B. Held wrote:
 Alexander Panek wrote:
 [...]
 You have a point, though the beauty & readability of D pretty much 
 nullifies that. The syntax sugar that is added so far does not 
 actually complicate the parsing so much, so D's syntax can still be 
 seen as clean, IMHO.

I think the ridiculous size of the front-end is a pretty good existence proof. Take a look, Neal. Dave

Posted at 09:42 am? Somebody has a skewed clock :o). Andrei
Mar 21 2007
parent Walter Bright <newshound digitalmars.com> writes:
Andrei Alexandrescu (See Website For Email) wrote:
 Posted at 09:42 am? Somebody has a skewed clock :o).

I figure in two weeks my Linux box will fix itself (at least until next year!).
Mar 21 2007