Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: struct tag (*[5])(float) |
| Date | 2015-04-02 15:18 -0700 |
| Organization | None to speak of |
| Message-ID | <87ego2gomr.fsf@kst-u.example.com> (permalink) |
| References | <mfhjtf$plc$1@dont-email.me> <551C65E3.8010903@verizon.net> <mfhpfk$g36$1@dont-email.me> <87bnj7i5nn.fsf@kst-u.example.com> <mfj26g$4s7$1@dont-email.me> |
Bartc <bc@freeuk.com> writes:
> On 02/04/2015 04:13, Keith Thompson wrote:
>> Bartc <bc@freeuk.com> writes:
[...]
>>> I could try and tell you what the above means, but it will a
>>> guess. Although I know the name goes just before the "*", because I
>>> tested my guess with a compiler.
>>
>> No, it goes after the identifier. (And I don't think I can explain how
>> I figured that out.)
>
> You mean, after the "*"...?
Yes.
>> I agree with you that C's declaration syntax is unnecessarily obscure,
>> and I occasionally resort to cdecl myself.
>
> Maybe it should be part of the language allowing you to optionally use
> English to declare types:
>
> _cdeclare("name as array 5 of pointer to function (float) returning
> struct tag") ;
>
> The compiler sees this as:
>
> struct tag (*name[5])(float) ;
I dislike that idea, at least as a language feature. We'd have to
define *rigorously* an English-like syntax for declarations, and it
would have to coexist with the existing syntax in the same language.
But I can see the convenience. You could instead have a tool that
translates an English-like syntax into valid C declarations. You could
then use that tool as part of your build process, to construct C source
files that you then compile. It could retain the "English" version as
a comment.
For example, it could take as input:
@ name as array 5 of pointer to function (float) returning struct tag
and produce as output:
/* @ name as array 5 of pointer to function (float) returning struct tag */
struct tag (*name[5])(float);
Personally I'd prefer to run the tool manually and include the generated
declarations in the C source file, which is then what's maintained. The
automatically generated comments would still be useful. Any non-C
syntax for declarations is going to annoy experienced C programmers --
much like the old
#define BEGIN {
#define END }
stuff.
[...]
--
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
struct tag (*[5])(float) "James Harris" <james.harris.1@gmail.com> - 2015-04-01 21:17 +0100
Re: struct tag (*[5])(float) James Kuyper <jameskuyper@verizon.net> - 2015-04-01 17:40 -0400
Re: struct tag (*[5])(float) Bartc <bc@freeuk.com> - 2015-04-01 22:55 +0100
Re: struct tag (*[5])(float) Barry Schwarz <schwarzb@dqel.com> - 2015-04-01 16:01 -0700
Re: struct tag (*[5])(float) James Kuyper <jameskuyper@verizon.net> - 2015-04-01 19:29 -0400
Re: struct tag (*[5])(float) Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-02 05:28 -0700
Re: struct tag (*[5])(float) Bartc <bc@freeuk.com> - 2015-04-02 00:37 +0100
Re: struct tag (*[5])(float) Keith Thompson <kst-u@mib.org> - 2015-04-01 20:13 -0700
Re: struct tag (*[5])(float) Bartc <bc@freeuk.com> - 2015-04-02 10:30 +0100
Re: struct tag (*[5])(float) Keith Thompson <kst-u@mib.org> - 2015-04-02 15:18 -0700
Re: struct tag (*[5])(float) John Bode <jfbode1029@gmail.com> - 2015-04-02 15:22 -0700
csiph-web