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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7272aa7508a3d83f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail From: Dave Thompson Newsgroups: comp.lang.ada Subject: Re: pointer questions Message-ID: References: X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 07 Nov 2005 04:21:10 GMT NNTP-Posting-Host: 12.76.14.81 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1131337270 12.76.14.81 (Mon, 07 Nov 2005 04:21:10 GMT) NNTP-Posting-Date: Mon, 07 Nov 2005 04:21:10 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:6260 Date: 2005-11-07T04:21:10+00:00 List-Id: On Thu, 27 Oct 2005 20:19:51 +0300, "Martin Krischik" wrote: > Am 27.10.2005, 02:01 Uhr, schrieb Szymon Guz : > > 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