Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #109849

Re: Help on this typedef

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Help on this typedef
Date 2017-05-12 09:38 -0700
Organization None to speak of
Message-ID <lnvap658u2.fsf@kst-u.example.com> (permalink)
References <fc0d8572-2a06-4675-b83a-edb585ea1551@googlegroups.com> <lntw4s6q9v.fsf@kst-u.example.com> <of15n2$2og$1@dont-email.me> <8ad1e08b-bdf9-4baa-a8b4-63bf48fb3e3d@googlegroups.com> <of3rs7$ehf$2@dont-email.me>

Show all headers | View raw


David Brown <david.brown@hesbynett.no> writes:

> On 11/05/17 17:35, supercat@casperkitty.com wrote:
>> On Thursday, May 11, 2017 at 3:04:00 AM UTC-5, David Brown wrote:
>>> On 11/05/17 05:11, Keith Thompson wrote:
>>>> I suspect that this is used to achieve a kind of semi-fake
>>>> pass-by-reference semantics. 
>>>
>>> An alternative possibility is that the array size in this code was not
>>> always 1, or that the author thinks it might not always be 1 in the future.
>> 
>> Using a literal 1 within a typedef in that case would seem unusual.
>
> It would be better to have:
>
> #define noOfMPZs 1
>
> and use that rather than "1" in the typedef.
>
> But we don't know the origin of the code, or how well thought-out it is,
> or what might have been put in as a quick hack.  We are just guessing.

It's from GMP, the GNU multiple precision arithmetic library.

Quoting its documentation:

    When a GMP variable is used as a function parameter, it's
    effectively a call-by-reference, meaning if the function
    stores a value there it will change the original in the caller.
    Parameters which are input-only can be designated `const' to
    provoke a compiler error or warning on attempting to modify them.

    When a function is going to return a GMP result, it should
    designate a parameter that it sets, like the library functions
    do.  More than one value can be returned by having more than one
    output parameter, again like the library functions.  A `return'
    of an `mpz_t' etc doesn't return the object, only a pointer,
    and this is almost certainly not what's wanted.

(An alternative might have been to make mpz_t a small struct, and
require explicit pointers to simulate pass-by-reference.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Help on this typedef fl <rxjwg98@gmail.com> - 2017-05-10 19:12 -0700
  Re: Help on this typedef Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-05-10 21:06 -0600
  Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-10 20:11 -0700
    Re: Help on this typedef David Brown <david.brown@hesbynett.no> - 2017-05-11 10:03 +0200
      Re: Help on this typedef supercat@casperkitty.com - 2017-05-11 08:35 -0700
        Re: Help on this typedef David Brown <david.brown@hesbynett.no> - 2017-05-12 10:34 +0200
          Re: Help on this typedef joel.rees@gmail.com - 2017-05-12 06:01 -0700
          Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-12 09:38 -0700
        Re: Help on this typedef joel.rees@gmail.com - 2017-05-12 05:08 -0700
          Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-13 14:25 -0700
            Re: Help on this typedef joel.rees@gmail.com - 2017-05-14 23:36 -0700
              Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-15 07:23 -0700
                Re: Help on this typedef joel.rees@gmail.com - 2017-05-18 07:40 -0700
                Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-18 09:35 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-18 10:59 -0700
                Re: Help on this typedef joel.rees@gmail.com - 2017-05-18 23:40 -0700
                Re: Help on this typedef jadill33@gmail.com - 2017-05-19 08:12 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 08:41 -0700
                Re: Help on this typedef jadill33@gmail.com - 2017-05-19 09:41 -0700
                Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-19 09:34 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 10:18 -0700
                Re: Help on this typedef Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-19 21:35 +0100
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 14:16 -0700
                Re: Help on this typedef Ike Naar <ike@iceland.freeshell.org> - 2017-05-19 21:15 +0000
                Re: Help on this typedef Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-19 23:54 +0100
                Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-19 14:25 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 15:18 -0700
                Re: Help on this typedef Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-19 23:52 +0100
                Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-19 16:42 -0700
                Re: Help on this typedef Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-20 01:16 +0100
                Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-20 01:58 -0700
                Re: Help on this typedef joel.rees@gmail.com - 2017-05-20 02:25 -0700
                Re: Help on this typedef joel.rees@gmail.com - 2017-05-19 22:09 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 23:23 -0700
                Re: Help on this typedef "James R. Kuyper" <jameskuyper@verizon.net> - 2017-05-19 13:33 -0400
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 13:44 -0700
                Re: Help on this typedef jameskuyper@verizon.net - 2017-05-19 19:20 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 23:30 -0700
                Re: Help on this typedef jameskuyper@verizon.net - 2017-05-20 07:20 -0700
                Re: Help on this typedef jameskuyper@verizon.net - 2017-05-20 07:46 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-22 10:50 -0700
                Re: Help on this typedef "James R. Kuyper" <jameskuyper@verizon.net> - 2017-05-18 12:37 -0400
                Re: Help on this typedef Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-18 20:02 +0100
                Re: Help on this typedef joel.rees@gmail.com - 2017-05-19 00:20 -0700
                Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-19 09:51 -0700
                Re: Help on this typedef supercat@casperkitty.com - 2017-05-19 10:31 -0700
                Re: Help on this typedef Ike Naar <ike@iceland.freeshell.org> - 2017-05-19 19:48 +0000
                Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-20 08:47 -0700
        Re: Help on this typedef "Patrick.Schluter" <Patrick.Schluter@free.fr> - 2017-05-27 18:50 +0200
  Re: Help on this typedef joel.rees@gmail.com - 2017-05-12 06:17 -0700
    Re: Help on this typedef supercat@casperkitty.com - 2017-05-12 08:46 -0700
      Re: Help on this typedef joel.rees@gmail.com - 2017-05-12 18:11 -0700
        Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-12 18:37 -0700
          Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-13 09:44 -0700
            Re: Help on this typedef Keith Thompson <kst-u@mib.org> - 2017-05-13 13:47 -0700
              Re: Help on this typedef Robert Wessel <robertwessel2@yahoo.com> - 2017-05-14 00:28 -0500
              Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-14 13:39 -0700
                Re: Help on this typedef raltbos@xs4all.nl (Richard Bos) - 2017-05-15 13:02 +0000
                Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-15 07:30 -0700
        Re: Help on this typedef supercat@casperkitty.com - 2017-05-12 20:45 -0700
        Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-13 09:57 -0700
        Re: Help on this typedef Philip Lantz <prl@canterey.us> - 2017-05-13 12:07 -0700
        Re: Help on this typedef David Brown <david.brown@hesbynett.no> - 2017-05-14 15:34 +0200
      Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-14 12:48 -0700
        Re: Help on this typedef supercat@casperkitty.com - 2017-05-15 07:39 -0700
          Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-24 08:23 -0700
            Re: Help on this typedef supercat@casperkitty.com - 2017-05-24 09:17 -0700
              Re: Help on this typedef Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-27 06:15 -0700

csiph-web