[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: const char* typedefs
- From: Paige DePol <lual@...>
- Date: Tue, 6 Feb 2018 13:25:48 -0600
Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2018-02-06 10:05 GMT+02:00 Forrest Christian (List Account)
> <lists@packetflux.com>:
>
>> In addition, I personally find typedefs which just reiterate the type
>> to be useless. If you're going to go to the bother of defining
>> a type, define a type, not just an alias for a existing type.
>
> The bigger picture matters too. The typedef adds a layer of abstraction
> and of self-documentation.
>
> For example, size_t, ptrdiff_t, etc all just define an alias, but you know
> what they will be used for.
>
> In llimits.h you find Instruction to be a typedef for unsigned either
> integer or long, depending on a precompiler variable.
>
> If Paige had chosen to emphasize that aspect, rather than the
> code-golfing point of view, more people might have agreed sooner.
Yes, I could have expressed my initial idea better than just "ooh less
characters". At the time I was thinking it would be nice to type less and
there are other typedefs that do similar things (the unsigned types).
However, as I was thinking about it during this conversation I also realised
that whenever I see "const char*" I just think "C String". A shorter name is
always nicer, and "ccstr" also concisely summarises the object to me.
Obviously "ccstr" is quite a bit more informative than my initial idea of
using "l_str". However, while the general consensus does seem to be against
the idea I am not entirely sure I am convinced to not to use the typedef.
While 'const char*' is not an object or an opaque type, in this particular
case, I don't think it hurts to think of it in this manner. If I am going
to think of 'const char*' as a discreet item then why not give it a name.
Honestly though I will have to give this idea some thought, and I will do
some more reading about the subject. Thanks again for your feedback and
advice on the subject everyone, I really do appreciate it!
~Paige