[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3)
- From: Sean Conner <sean@...>
- Date: Sat, 19 Apr 2014 17:54:32 -0400
It was thus said that the Great Coroutines once stated:
> On Sat, Apr 19, 2014 at 2:18 PM, Sean Conner <sean@conman.org> wrote:
>
> > Perhaps in time it'll be reguarded like the "register" keyword, accepted, but totally ignored.
>
> The liberal in me wants register, inline, const, auto, and maybe even
> restrict to be removed from the list of C keywords. gcc & clang-llvm
> are so smart nowadays (imo) these keywords are more misused than used
> appropriately :( volatile can never be made useless by a
> self-aware/skynet compiler though, haha
I can see register and auto being removed, but the rest, even if the
compiler ignores them, also registers (heh) intent. Given two prototypes:
int foo(const char *x);
int bar(char *x);
I know I can safely pass in a string to foo() and not have it change on me;
I don't know that about bar() without checking the source code. One says
"I'll only read the data," the other says "there be dragons."
I also use const in a design pattern. I place all my global variables in
one file (usually globals.c):
char *c_name;
char *c_foo;
int c_blah;
Also in that file (globals.c) is code that will modify those variables (I
tend to place the command line parsing routines here). In a header file
(usually globals.h) I defined them as:
extern const char *const c_name;
extern const char *const c_foo;
extern const int c_blah;
Any attempt to modify those variables outside of globals.c is flagged as
an error (I should note that globals.c does *NOT* include globals.h).
I do try to minimize the number of global variables I use, but sometimes
their use is unavoidable. I have several examples of this design pattern
[1][2].
-spc
[1] And it is a design pattern, as it's a workaround for a flaw in the
language.
[2] https://github.com/spc476/mod_blog/tree/master/src
https://github.com/spc476/x-grey/tree/master/server/src
- References:
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Sean Conner
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Dirk Laurie
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Sean Conner
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Dirk Laurie
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Sean Conner
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Coroutines
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Sean Conner
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Coroutines
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Sean Conner
- Re: Modules for iconv (Was: UTF-8 patterns in Lua 5.3), Coroutines