From: Bob Spooner on

"Dr. Adrian Wrigley" <amtw(a)linuxchip.demon.co.uk.uk.uk> wrote in message
news:pan.2005.11.02.00.51.10.448346(a)linuxchip.demon.co.uk.uk.uk...
> On Mon, 31 Oct 2005 06:21:37 +0000, Jeffrey R. Carter wrote:
>
> > Robert A Duff wrote:
> >
> >> That's hard to believe. Dr. Wrigley said the hardware failures turned
> >> from "insideous" to "catastophic" when he changed some sort of Things
to
> >> pointers-to-Things. I take that to mean, he got wrong answers before,
> >> and crashes after. Is that right, Dr. Wrigley?
>
> I Thinks so, but the error rate was very low, so it is hard to tell.
>

Wow! That would mean that if you want your software to be reliable, you
should use as many pointers as you can so that you notice the errors - then
you can fix them! :)

Bob


From: Björn Persson on
Dr. Adrian Wrigley wrote:
> (was it so unclear?)

I didn't find it unclear.

--
Bj?rn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu
From: Dave Thompson on
On 27 Oct 2005 10:14:40 -0400, Robert A Duff
<bobduff(a)shell01.TheWorld.com> wrote:

> Szymon Guz <alpha(a)skynet.org.pl_WITHOUT> writes:
>
> > Well, that's how I thought but I wanted to ask. The problem that I want
> > to solve is how to create a property in type like that ones in
> > Delphi|Builder, so I have defined the property name, value, read and
> > write functions. I thought that it could be done by defining a generic
> > structure like this: <snip>
>
> I'm not sure I fully understand what you're trying to do, but I suspect
> you can do it with a hierarchy of tagged types. You will have an
> access-to-class-wide type, which is sort of like "void *", but it's
> safe.
>
Actually Ada access to classwide is much more like C++ pointer to
baseclass, or possibly reference to baseclass, which are similarly
typesafe (at least in themselves; of course in C++ you are more likely
to have passed them through other unsafe constructs elsewhere).

> Alternatively, a generic package might do what you want.
> You would have one instance for each type of Value you
> want to store. This method might be safer, but less flexible.
>
That said, in this case I think generic probably is better.

- David.Thompson1 at worldnet.att.net
From: Dave Thompson on
On Thu, 27 Oct 2005 20:19:51 +0300, "Martin Krischik"
<krischik(a)users.sourceforge.net> wrote:

> Am 27.10.2005, 02:01 Uhr, schrieb Szymon Guz <alpha(a)skynet.org.pl_WITHOUT>:
<snip>
> > 2. Is there a universal (like above) pointer for procedure|function that
> > can point to any kind of procedure|funcion ?
>
> How is that supposed to work? Any function - how then are you going to
> pass any parameters? You don't even have that in C.
>
Yes and no. In C (and C++) you can convert a pointer to any function
type (= subprogram signature) to any other -- as long as you don't use
the result to make a call. In C++ you must convert back to the correct
signature (prototype) to make the call.

In C only you can also use the original, pre-ANSI-89 aka K&R1, syntax
to specify pointer to function of _unspecified_ argument types but a
specified return type (including, now, void = procedure). This has the
'advantage'(?) that you can convert any pointer-to-function type to it
and vice versa _implicitly_ (without a cast). If you call through
such a pointer the arguments are passed using (only) the fixed K&R1
rules, now called the 'default argument promotions', and you the
programmer are responsible for making sure they agree. (Which you
can't if the called function wants formals of types 'widened' by the
default promotions, namely integers below int or s-p float. Though if
you define = implement the function also using K&R1 syntax, declaring
a formal parameter of such a narrow type actually uses the widened
one, compatible with the calls.)

This allows you to create a data structure, such as a table, which has
pointers to functions of different signatures, along with some data
which allows you to determine (select) the correct signature for each
in progam logic, but not automatically checked by the compiler.

- David.Thompson1 at worldnet.att.net