From: Adam Beneschan <adam@irvine.com>
Subject: Re: Pointers explained?
Date: Mon, 30 Jul 2007 15:36:02 -0700
Date: 2007-07-30T15:36:02-07:00 [thread overview]
Message-ID: <1185834962.845369.84390@g12g2000prg.googlegroups.com> (raw)
In-Reply-To: <1185830614.681672.154960@g4g2000hsf.googlegroups.com>
On Jul 30, 2:23 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> On 30 Lip, 21:36, Adam Beneschan <a...@irvine.com> wrote:
>
> > C++ will of
> > course let you do that
>
> C++ will of course let you do that, but this statement itself is
> meaningless, because languages are never used directly. In real life
> you might want to use a *compiler* to compile the C++ code and recent
> versions of g++ produce a nice warning message when you try to return
> an address of a local variable (even without any additional options).
> I guess other C++ compilers are smart enough to do the same, so it's
> not that bad.
Please refer to the first thing I said in my response. I guess you
proved it correct. :) I basically use C++ when I'm absolutely forced
to and never at any other time, so I'll take your word for it.
> On the other hand it is true that the whole scenario can be made more
> complex up to the point where the compiler will not catch the problem,
> but will have to accept it, so it's not perfect either.
>
> Note that Ada programmers also have 'Unrestricted_Access (GNAT) and
> 'Unchecked_Access to cheat around the rules.
Yes, but Ada programmers are aware of the danger and understand why
the rules are there; and they won't use 'Unchecked_Access unless it's
absolutely necessary and they know there won't be any dangling pointer
problems.
Note that "Ada programmer" is not a synonym for "programmer who uses
Ada" here. I'm sure there are plenty of programmers who use Ada but
think like C/C++ programmers. Those programmers would see the error
message that says 'Access is illegal because of the accessibility
rules, and figure they can solve the problem simply by changing it to
'Unchecked_Access". Unfortunately, I've seen that sort of Ada code---
quite frustrating.
-- Adam
next prev parent reply other threads:[~2007-07-30 22:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-30 17:53 Pointers explained? shaunpatterson
2007-07-30 17:56 ` shaunpatterson
2007-07-30 19:04 ` Ed Falis
2007-07-30 19:05 ` Ludovic Brenta
2007-07-30 19:36 ` Adam Beneschan
2007-07-30 21:23 ` Maciej Sobczak
2007-07-30 22:36 ` Adam Beneschan [this message]
2007-07-31 7:33 ` Dmitry A. Kazakov
2007-07-31 1:15 ` Anh Vo
2007-07-30 22:20 ` Adam Beneschan
2007-07-30 21:31 ` Jeffrey R. Carter
2007-07-31 17:21 ` Simon Wright
2007-07-31 18:06 ` Dmitry A. Kazakov
2007-07-31 22:38 ` shaunpatterson
2007-08-01 7:53 ` Martin Krischik
2007-08-01 8:21 ` Dmitry A. Kazakov
2007-08-10 19:52 ` Simon Wright
2007-07-30 20:11 ` Dmitry A. Kazakov
2007-07-31 8:28 ` Martin Krischik
-- strict thread matches above, loose matches on Subject: below --
2007-07-30 17:53 shaunpatterson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox