"Alf P. Steinbach" <
alf.p.stein...@gmail.com> writes:
> On 16.12.2018 18:46, Tim Rentsch wrote:
>
>>
legaliz...@mail.xmission.com (Richard) writes:
>>
>>> User <
aitor....@googlemail.com> spake the secret code
>>> <
1d46e37a-e16e-4715...@googlegroups.com> thusly:
>>>
>>>> the presence of unused argument isn't a design decision, but working
>>>> with delegates. A function of the type EmitterFunc(int, bool, int) can
>>>> be connected to a function with the prototype ReceptorFunction(int,
>>>> bool).
>>>
>>> Delegates are not in the C++ language, so your statement seems
>>> disconnected from C++.
>>>
>>> Alf's point is that it's a design error to directly connect functions
>>> with mismatching signatures.
>>
>> I think you mean type rather than signature. The two functions
>>
>> int bas( int );
>> int foo( int );
>>
>> have different signatures, but they have the same type. Certainly
>> one could be used in place of the other.
>
> Technically you're right.
>
> But it's worth noting that the term "signature"
>
> * is defined differently in C++11 and later, than in C++98/C++03,
>
> [rearranged slightly for continuity]
>
> C++03 1.3.10:
> [quote]
> the information about a function that participates in overload
> resolution (13.3): the types of its parameters and, if the
> function is a class member, the cv- qualifiers (if any) on the
> function itself and the class in which the member function is
> declared. 2) The signature of a function template specialization
> includes the types of its template arguments (14.5.5.1).
> [/quote]
Interesting, I didn't know that. But I think that strengthens
the case for preferring the correct term 'type', which is right
for both pre-C++11 and C++11 onwards, to 'signature', which is
wrong in both cases. (Note that the C++98/C++03 definition of
'signature' does not include the return type.) Furthermore,
based on how the term 'signature' was used in C++98/C++03, it
looks like either (a) the definition was meant to include the
function name, or (b) needing the function name was overlooked
when writing the definition. For example, in section 17.4.3.1.3
("External linkage"), paragraph 2 says
Each global function signature declared with external
linkage in a header is reserved to the implementation to
designate that function signature with external linkage.
This statement makes sense only if 'signature' is understood
to include the function name along with the types of the
parameters.
> * has a general language independent meaning more like C++03 than
> C++11.
>
> The language independent meaning, and the C++98/C++03 meaning,
> does not include the function name.
A more accurate statement is that the term 'signature' means
different things in different languages. The original use of
'signature' in programming languages was, IIANM, in the language
Russell, where it was not associated (directly) with functions.
The ML family of languages uses 'signature' in a different way,
to define module interfaces: the signature of a module might be
called the "type" of that module. I don't know when the ML
languages introduced modules and module signatures; the usage in
Russell predates C++98 by 20 years. It's true that many people
misuse the term "signature" to mean what C and C++ call the type
of a function. But "signature" does not mean, and has never
meant (at least in C++), the same thing as the property that
Richard was alluding to in his comment.
> Evidently for C++11 someone tried very hard to really define in
> detail the meaning of "signature" so that the standard's use of
> that term could be read pedantically formally, and perhaps so that
> that term could be used instead of C++03 "type" in certain context
> (I'm not sure of that, I haven't checked). The "signature" of a
> /function/ is defined as "name, parameter type list (8.3.5), and
> enclosing namespace (if any)". Then there is a definition of the
> "signature" of a /function template/, and a definition of it for
> /function template specialization/, and a definition of it for
> /class member function/, and a definition of it for /class member
> function template/, and a definition of it for /class member
> function template specialization/, where for the template meanings
> also the return type is part of the signature.
>
> I.e. a simple general definition that resonated well with the
> term's general use, was replaced with umpteen detailed definitions
> that are more unnatural in that they include the function name.
>
> To me it reads as an attempt to define the term so that it can be
> used as part of an in-group language to let language lawyers more
> easily identify each other as such, and to let them identify
> non-lawyers.
I think you're misreading the history. Looking at usages in the
C++03 and C++98 standards, it seems clear that it was intended
all along that "signature" include the name of the function in
question. The changes in C++11 were done to correct what had
been an oversight or unintended omission. Furthermore the misuse
of "signature" to mean the type of a function didn't become
commonplace until after the C++98 standard was released. It
isn't that C++98 was following a common usage, and probably the
other way around - it was people misunderstanding the C++98
meaning to equate "signature" with "function type" that caused
"signature" to be widely misused to mean the type of a function.