Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85855
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: initializer list type deduction rules |
| Date | 2022-08-11 16:37 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87zggaeqpw.fsf@bsb.me.uk> (permalink) |
| References | (1 earlier) <5f204a4e-c9cc-42cf-b193-7e27eccfe003n@googlegroups.com> <tcu0mi$aki$1@gioia.aioe.org> <19e1392a-2188-4d49-98bf-4bbf645d4a02n@googlegroups.com> <tcvo8u$kl5$1@gioia.aioe.org> <td27ab$1v3i$1@gioia.aioe.org> |
Juha Nieminen <nospam@thanks.invalid> writes: > Muttley@dastardlyhq.com wrote: >> The more pertinent question is why the C++ committee felt the need to >> duplicate the functionality of typedef. > > typedef is confusing. The average person learning C or C++ very easily > gets the impression that typedef works like: > > typedef TheType AliasName; I suppose that depends on what they've read and seen. > But that's not at all how it works. It just happens to conform to that > form with elementary types (because that's how elementary type variables > are declared), but when such a person finds the need to create a type > alias eg. for a function pointer (or any of the other more complicated > types, like array pointers), he'll be highly confused because the > above pattern doesn't work with them. A bit of research needs to be > done to find out that eg. a function pointer alias needs to be written > in a quite confusing way: > > typedef int(*AliasName)(int, int, double); > > (Understanding typedef becomes easier when you realize that it's just > as if you were declaring a normal variable, and you just add 'typedef' > at the beginning. But given how obscure function and array pointers > are...) I think it's easier for old hands who learned from the classic K&R. K&R was always very clear: typedef came late to C, and was added into the syntax as a storage class specifier, just to get the job done. Once you know this, it's clear that typedef, like extern and static, just sits at the front of a set of otherwise ordinary declarations. > The new alternative is more logical, consistent and easier to understand: > > using AliasName = TheType; > > In this case it *does* always work using that pattern. Well that's an odd way to put it. You gave the wrong pattern so of course this new syntax looks more consistent. typedef (like any syntax!) also works using a consistent pattern. -- Ben.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-09 07:54 +0000
Re: initializer list type deduction rules Bo Persson <bo@bo-persson.se> - 2022-08-09 10:43 +0200
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-09 09:00 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-09 16:06 +0000
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-10 02:32 +0000
Re: initializer list type deduction rules Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-10 09:11 +0300
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-10 06:57 +0000
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-10 07:31 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-10 00:40 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-10 07:55 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-10 01:13 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-10 08:21 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-10 11:13 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 08:26 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 03:38 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 10:48 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 04:54 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 14:34 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 08:34 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 15:57 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 09:16 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-13 09:35 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-13 09:44 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-14 11:12 +0000
Re: initializer list type deduction rules scott@slp53.sl.home (Scott Lurndal) - 2022-08-12 14:58 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 08:59 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 16:11 +0000
Re: initializer list type deduction rules scott@slp53.sl.home (Scott Lurndal) - 2022-08-12 16:44 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 12:08 -0700
Re: initializer list type deduction rules scott@slp53.sl.home (Scott Lurndal) - 2022-08-12 19:58 +0000
Re: initializer list type deduction rules Öö Tiib <ootiib@hot.ee> - 2022-08-12 16:42 -0700
Re: initializer list type deduction rules David Brown <david.brown@hesbynett.no> - 2022-08-13 18:14 +0200
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-14 11:06 +0000
Re: initializer list type deduction rules David Brown <david.brown@hesbynett.no> - 2022-08-15 11:34 +0200
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-15 19:03 +0000
Re: initializer list type deduction rules David Brown <david.brown@hesbynett.no> - 2022-08-15 21:23 +0200
Re: initializer list type deduction rules red floyd <no.spam.here@its.invalid> - 2022-08-15 13:51 -0700
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-16 19:16 +0000
Re: initializer list type deduction rules Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-21 22:23 +0300
Re: initializer list type deduction rules David Brown <david.brown@hesbynett.no> - 2022-08-22 08:08 +0200
Re: initializer list type deduction rules Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-22 11:37 +0300
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-22 10:23 +0000
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-11 06:24 +0000
Re: initializer list type deduction rules Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-11 16:37 +0100
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-11 20:12 +0000
Re: initializer list type deduction rules Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-08-12 00:09 +0100
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-12 11:51 +0000
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 08:29 +0000
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-12 12:08 +0000
Re: initializer list type deduction rules Muttley@dastardlyhq.com - 2022-08-12 14:37 +0000
Re: initializer list type deduction rules scott@slp53.sl.home (Scott Lurndal) - 2022-08-12 15:01 +0000
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-15 06:04 +0000
Re: initializer list type deduction rules Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-08-09 16:08 -0700
Re: initializer list type deduction rules Juha Nieminen <nospam@thanks.invalid> - 2022-08-10 02:34 +0000
csiph-web