From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 14 Jul 2014 18:24:22 +0200 From: "G.B." User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: why Ada type casting is different from other languages? newType(value) vs. (newType)value References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <53c40435$0$6612$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 14 Jul 2014 18:24:21 CEST NNTP-Posting-Host: 945add10.newsspool4.arcor-online.net X-Trace: DXC=ZNUK[e3jDID74okIm;?DS@4IUKJLh>_cHTX3jMWGG5D9CWhUE X-Complaints-To: usenet-abuse@arcor.de Xref: news.eternal-september.org comp.lang.ada:20931 Date: 2014-07-14T18:24:21+02:00 List-Id: On 14.07.14 17:25, Adam Beneschan wrote: > I don't like the (type)expression syntax because I can never remember what the precedence is. This is especially a problem for (type)object.method(args), because I have to look up whether the type conversion applies to just the object or to the result of the function call. > > In general, questions such as this are meaningless, because for the most part they come down someone's style preference. It appears that in some situations style alone is not a permissible language design guide. WRT syntax, McIver and Conway explain, with novice programmers in mind, that there needs to be a good signal to noise ratio and that this may mean just enough syntax, but also enough syntax. In particular, they address "homonyms", as in "type(expression)" vs "something-else(expression)". "Alternatively, it may be better to increase the complex- ity of the syntax in order to reduce homonyms which blur the signal. For example, the meaning of the various compo- nents of the Turing expression^7: f(C(p).A(I))(N) "might be better conveyed with the syntax: f(C::p->A_{I})[N] "The second form, whilst regrettably no more mnemonic than the first, does at least provide adequate visual differen- tiation between pointer dereference, array indexing, func- tion call, and substring extraction. ^7: "Create a substring consisting of the Nth letter of the string returned by the function f when passed the Ith element of the array member A of the object within collection C which is pointed to by p". Linda McIver & Damian Conway, Seven Deadly Sins of Introductory Programming Language Design