Re: pointers
- From: Simon Biber <news@xxxxxxxxx>
- Date: Tue, 30 Aug 2005 19:05:03 +1000
Alexei A. Frounze wrote:
:) That's why I'd prefer declaring variables 3rd way, more like in Pascal, where certain things are much more straightforward:
var a, b : array[0..10] of integer; (* both a and b are arrays of 10 ints *) p1, p2: ^integer; (* both p1 and p2 are pointers to int *)
I'd make it more cdecl-like:
a, b: array 10 of int; p1, p2: pointer to int;
I once thought about making a C preprocessor to translate all declarations of this form into real C so they can be compiled.
main: function (argc: int,
argv: pointer to pointer to char)
returning int
{
str: pointer to const char = "Hello World\n";
puts(str);
return 0;
}I'm still not sure what syntax would be best for definitions with initialisations (possibly multiple initialisations).
a, b: int = 1; // initialises both a and b to 1 a = 2, b = 3: int; // initialises a to 2 and b to 3
Certainly the ability to declare objects of different types in a single declaration would be lost:
For example, the declaration: char c, *pc, **ppc, *(*pfrpc)();
Would become: c: char; pc: pointer to char; ppc: pointer to char; pfrpc: pointer to function returning pointer to char;
Somewhat more typing, but much clearer!
-- Simon. .
- Follow-Ups:
- Re: pointers
- From: Alexei A. Frounze
- Re: pointers
- References:
- pointers
- From: Anolethron
- Re: pointers
- From: Ulrich Eckhardt
- Re: pointers
- From: Keith Thompson
- Re: pointers
- From: Alexei A. Frounze
- Re: pointers
- From: John Bode
- Re: pointers
- From: Alexei A. Frounze
- pointers
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: object code from which compiler
- Previous by thread: Re: pointers
- Next by thread: Re: pointers
- Index(es):
Relevant Pages
|