tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Local procedures


From: Rob Landley
Subject: Re: [Tinycc-devel] Local procedures
Date: Thu, 13 Sep 2007 17:13:58 -0500
User-agent: KMail/1.9.6

On Thursday 13 September 2007 3:48:31 am address@hidden wrote:
> C is the universal assembly language? That really hit my sweet-tooth (^_^)
>
> However, would it not be good if someone tried to make a simple set of
> standard extensions?
>
> - range checking,

You mean like tcc's bcheck.c?

> or at least a new lengthof keyword that returns the 
> length, IMHO that would be lexicaly appropriate, sort of the complement to
> sizeof...didn't tcc already have some range checking algorithm? - local
> procedures

tcc.h alrady has:

> #ifndef offsetof
> #define offsetof(type, field) ((size_t) &((type *)0)->field)
> #endif
>
> #ifndef countof
> #define countof(tab) (sizeof(tab) / sizeof((tab)[0]))
> #endif

I'm unsure what you're asking for.

> - maybe a simple way to have "array pointers", not an array of pointers,
> but a pointer that points to an array an has n elements, so instead of
> pointing to each single element you point to an array and a position in
> that array, pointer[n] thus points to the n-th element from where the
> "array pointer" points to.

Er, that would be simple pointer arithmetic?

int blah[1000];
int *that = blah+50;

that[9]=123;

At which point blah[59] == 123.

> I don't have a black belt in C, so perhaps there are some simpld tricks to
> the last list item.
>
> These are basically the only things about C that I think shold be improved
> on, but then again, I may be proven wrong even about these things, although
> I honestly believ these would be good extensions.

Bounds checking is your problem.  There are a bunch of standard solutions for 
it, but if you write code to do something stupid in C, it does.  The solution 
is generally not writing code to do something stupid, not asking the computer 
to figure out what you _meant_ to do.

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]