Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C pointer semantics with dynamically allocated struct Date: Mon, 17 Aug 2015 16:42:20 -0700 Organization: None to speak of Lines: 37 Message-ID: References: <003ef111-3124-49dc-b5cc-4d1bc0cc258c@googlegroups.com> <79d68564-6e2e-447d-a73b-7b19d4e8bc66@googlegroups.com> <55D25210.20306@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="6073"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18aNBsDPTo3a8CUrvjtQwVE" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:AY74rq8IFij/vLnCWlIxEySa/Ys= sha1:z4eSEC6p306yWqGdROQVrIyIkAg= Xref: csiph.com comp.lang.c:67652 James Kuyper writes: > On 08/17/2015 04:20 PM, Morten W. Petersen wrote: >> On 17.08.2015 18:33, Keith Thompson wrote: >>> "Morten W. Petersen" writes: >> [...] >>>> Macros with parameters for example, why not have a compiler that >>>> must support inline? No more complicated macro implementations for >>>> compiler writers, no more headaches for developers. >>> >>> Because there are plenty of macros that cannot be expressed as inline >>> functions. A simple example: >>> >>> #define MAX(x, y) ((x) > (y) ? (x) : (y)) >>> >>> An inline function would have to specify the type of the arguments. >>> (Of course the macro has the drawback that one of the arguments >>> will be evaluated twice.) >> >> Well, it might not be possible to express a function in >> exactly the way as a macro, but something equivalent >> should be possible. > > Have you actually thought that through? The key difference between a > macro and a function is that the function necessarily has a single > specific type for each parameter, and for it's return type. [...] Mostly true. Variadic functions (like printf) can take arguments of varying types. But even so, the return type is fixed, so you can't write a max() function that's anywhere near as convenient as the macro. -- Keith Thompson (The_Other_Keith) kst-u@mib.org 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"