Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Linked lists, message passing |
| Date | 2015-06-20 15:14 +1200 |
| Message-ID | <cuk43oF43fuU3@mid.individual.net> (permalink) |
| References | (1 earlier) <mm0fb1$trh$1@dont-email.me> <mm0ge8$nlo$1@speranza.aioe.org> <mm0i2v$6ol$1@dont-email.me> <mm0iun$92e$1@dont-email.me> <mm0kel$elq$1@dont-email.me> |
Richard Heathfield wrote:
> On 19/06/15 09:14, Noob wrote:
>> On 19/06/2015 09:59, Richard Heathfield wrote:
>>
>>> T *t_create(void)
>>> {
>>> static const T template = {0};
>>> T *new = malloc(sizeof *new);
>>> if(new != NULL)
>>> {
>>> *new = template;
>>> }
>>> return new;
>>> }
>>
>> I suggest you throw a variable named 'class' in the mix ;-)
>
> Right. :-)
>
> The choice of 'template' was in fact accidental. It was the obvious word
> to use (especially since the {0} could be modified to incorporate actual
> default values (and 'default' is a keyword, so obviously I couldn't use
> that), and it was only on re-reading when composing this reply that I
> noticed that it is in fact a keyword in Another Language.
>
> But the choice of 'new' was entirely deliberate, and yes, it is
> specifically to prevent the code from being compiled under C++. If I
> want to use the code in C++, that's fine, but as a linked-in C module,
> not as C++. The purpose is to minimise any problems stemming from subtle
> differences in the semantics of the two languages (a situation that can
> only get worse as they both slowly evolve away from each other).
One of the less than subtle differences (assigning a void* to a T*)
would have prevented it from compiling without the gratuitous use of
keywords :)
--
Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 05:49 +0200
Re: Linked lists, message passing Ike Naar <ike@iceland.freeshell.org> - 2015-06-19 06:51 +0000
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 09:08 +0200
Re: Linked lists, message passing Barry Schwarz <schwarzb@dqel.com> - 2015-06-19 02:08 -0700
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 14:11 +0200
Re: Linked lists, message passing raltbos@xs4all.nl (Richard Bos) - 2015-06-19 13:47 +0000
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 15:52 +0200
Re: Linked lists, message passing Robert Wessel <robertwessel2@yahoo.com> - 2015-06-19 22:07 -0500
Re: Linked lists, message passing raltbos@xs4all.nl (Richard Bos) - 2015-06-27 12:25 +0000
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-06-29 09:03 +0200
Re: Linked lists, message passing raltbos@xs4all.nl (Richard Bos) - 2015-07-03 17:28 +0000
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-07-03 22:16 +0200
Re: Linked lists, message passing Morris Dovey <mrdovey@iedu.com> - 2015-07-03 16:44 -0500
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-07-04 01:12 +0200
Re: Linked lists, message passing Morris Dovey <mrdovey@iedu.com> - 2015-07-03 18:50 -0500
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-07-04 09:39 +0200
Re: Linked lists, message passing Morris Dovey <mrdovey@iedu.com> - 2015-07-04 04:34 -0500
Re: Linked lists, message passing Bartc <bc@freeuk.com> - 2015-07-04 11:01 +0100
Re: Linked lists, message passing Geoff <geoff@invalid.invalid> - 2015-07-04 11:43 -0700
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-07-05 18:49 +0200
Re: Linked lists, message passing Geoff <geoff@invalid.invalid> - 2015-07-05 12:30 -0700
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-07-05 22:39 +0200
Re: Linked lists, message passing Geoff <geoff@invalid.invalid> - 2015-07-05 15:08 -0700
Re: Linked lists, message passing glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-07-06 01:05 +0000
Re: Linked lists, message passing Geoff <geoff@invalid.invalid> - 2015-07-05 23:55 -0700
Re: Linked lists, message passing "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-04 11:48 -0700
Re: Linked lists, message passing Morris Dovey <mrdovey@iedu.com> - 2015-07-03 18:51 -0500
Re: Linked lists, message passing G G <gdotone@gmail.com> - 2015-07-03 18:13 -0700
Re: Linked lists, message passing Richard Heathfield <rjh@cpax.org.uk> - 2015-06-19 08:12 +0100
Re: Linked lists, message passing "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 09:30 +0200
Re: Linked lists, message passing Richard Heathfield <rjh@cpax.org.uk> - 2015-06-19 08:59 +0100
Re: Linked lists, message passing Noob <root@127.0.0.1> - 2015-06-19 10:14 +0200
Re: Linked lists, message passing Richard Heathfield <rjh@cpax.org.uk> - 2015-06-19 09:40 +0100
Re: Linked lists, message passing Ian Collins <ian-news@hotmail.com> - 2015-06-20 15:14 +1200
Re: Linked lists, message passing jacobnavia <jacob@jacob.remcomp.fr> - 2015-06-19 18:10 +0200
Re: Linked lists, message passing Richard Heathfield <rjh@cpax.org.uk> - 2015-06-19 17:32 +0100
Re: Linked lists, message passing Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-29 00:56 -0700
Re: Linked lists, message passing Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-29 00:49 -0700
Re: Linked lists, message passing Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 08:32 -0700
csiph-web