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!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: why Ada type casting is different from other languages? newType(value) vs. (newType)value Date: Tue, 15 Jul 2014 22:14:31 +0300 Organization: Tidorum Ltd Message-ID: References: <1cqb2iccfzox2$.f74qor2zqcub.dlg@40tude.net> <53c25e58$0$6665$9b4e6d93@newsspool3.arcor-online.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net eoOc59NCwaCEknc+wrRg5wpnx+yQjr4g1Pr8BaQwerXnjeDic6 Cancel-Lock: sha1:olqAHPU0+DMZ5fR6QFSVS3XCCHo= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:20950 Date: 2014-07-15T22:14:31+03:00 List-Id: On 14-07-15 21:42 , G.B. wrote: > And later, is it really good or bad if it takes years or not > to be competent enough to understand > > ptrdiff_t x = *(ptrdiff_t*)main; > > vs > > X : Integer_Address := To_Integer (Main'Address); > > if they are comparable? Aah... they are *not* "comparable", if by that you mean "equivalent". The first (C) declaration interprets the entry address of "main" as a pointer to a ptrdiff_t, and then dereferences that pointer to read this putative ptrdiff_t value and store it in x. In other words, x will contain bits from the initial instructions of "main". The second (Ada) declaration simply converts the entry address of "Main" to an Integer_Address. It does not read anything from the instructions in Main. Perhaps I misunderstood your point? -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .