Re: A[x][y][z]



sterten@xxxxxxx writes:
> > > A[x][y][z] is worse than A[x,y,z] ,
> >
> > It's fine once you get used to it.
>
> on German keyboards there is also the disadvantage that you have
> to press the "altGr" key to get [] , which often makes typing
> of math-programs difficult and erroneous. E.g. I often type
> "}" instead of "]" and then it's hard to loacate the error.

(Please don't snip attributions. It's helpful if readers can tell who
wrote what.)

Ok. That's not a problem I've ever run into; I can't think of a good
solution. (Maybe you could define an editor macro?)

> > > is someone successfully running the C-compiler from batch-file,
> > > first converting all of the latter expressions
> > > into the corresponding former ones and then compiling it ?
> >
> > I sincerely hope not.
>
> why ? Afraid others could improve their programming skills
> and your own programs written in less advanced language
> become less competitive ?

Um, no. I just think it's a bad idea.

> > > And while we're at it, this preprocessing utility should
> > > also change array definitions like e.g.
> > > int B[N];
> > > into int B[N+1];
> > > since B[N] would not be defined else, only B[0],B[1],..,B[N-1]
> >
> > And while you're at it, you can do things like:
> >
> > #define IF if(
> > #define THEN ){
> > #define ELSE }else{
> > #define ELSEIF }else if(
> > #define ENDIF }
>
> these won't make notation much shorter or easier.
> Although sometimes I wished the pre-compiler could
> add things like "}" --> "} // next x"
> It's hard in C to keep track of the nested levels of "{,}"

What do you mean by "pre-compiler"? It sounds like you want something
that modifies your source code. A language-sensitive text editor
could probably do that kind of thing.

> One other thing comes to mind, that is dynamical array definition.
> Why can't I do : (or is there a way ?)
> main(int argc,char*argv[]){
> sscanf(argv[1],"%i",&n);
> global int A[n];
> }

There's no "global" keyword, but C99 does support variable-length
arrays.

> > and pretend you're writing in a different language
> > altogether. Except that you're still really programming in C, with
> > all the drawbacks that implies, with a thin and fragile layer of a
> > different syntax on top of it.
> >
> > People have tried this kind of thing, and it's invariably a bad idea.b
>
> please give a link or a searchable keyword and let me decide by myself

Sorry, I don't have any references. I understand that the original
Bourne shell used something like the ugly pseudo-Pascal
BEGIN/END/IF/ELSE macros, but I believe it's been corrected.

> > The result is something that experienced C programmers won't be
> > able to read because it doesn't look like C, and experienced
> > programmers in other languages won't be able to read because it
> > doesn't quite look like anything else.
>
> you still have the output of the preprocessor which you could show
> to these.

The preprocessor (if you mean the C preprocessor that's part of the
compiler) also expands #include directives and *all* macros, among
other things. The output isn't particularly legible.

> > There is an underlying logic to the way C is designed. You might
> > not like it (there are things I dislike myself), but you really
> > should try to understand it before you try to mess with it.
>
> you won't expect that it's so perfect that it can't be improved...

I didn't say that, or anything resembling it.

The C standard exists for a reason. It's certainly not perfect; there
are plenty of things I would have done differently. But it permits
consistency across programmers and implementations. If I write code
in C, any C programmer can read it. (Code is written for other
programmers as much as for the compiler.)

The English language has plenty of problems, and there are a lot of
changes I could suggest. I could invent an English-like language with
more logical spelling and grammar and a more consistent vocabulary.
But if I started writing in this new language, even if it's superior
to standard English, nobody would be able to understand me.

> > If you want to program in C, you should learn C, with all its little
> > quirks.
>
> no. I only need some few commands. When you require people to
> learn "all the little quirks" - that might keep them away from C

If you want to program in C without learning more than "some few
commands", I don't think we can help you.

> > If you dislike C so much, you should pick a different
> > language.
>
> Not "so much". And why isn't it allowed to improve something
> no matter how good it is already ?

Lots of people have tried to improve C. They do it by inventing new
languages (C++, C#, Java, several languages calling themselves D).

> And BTW. strangely enough I get the same advice from these
> assembly programmers and Basic programmers where I wanted
> to introduce some C-elements.
> Let's combine the goodies from each language !

The best way to do that would be to create a new coherent language.
You can even use C as the intermediate language generated by the
compiler (the original "cfront" implementation of C++ did this).

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: CollabRx seeks brilliant engineers for an excellent e-science adventure
    ... belief that lisp programmers are smarter/better. ... Java or PHP programmers. ... a type of language that attracts a personality that meets my perceptions ...
    (comp.lang.lisp)
  • Re: Question concerning object-oriented programming
    ... programming language, not his. ... there has usually been a toString. ... I know it's "unrealistic" to expect actual programmers to do this, ... tell me what a dog is. ...
    (comp.programming)
  • Re: Language X, not Forth ?
    ... As you become more familiar with a language, it's readability is a function of how much care the programmer took to make it more readable. ... The use of non-readable graphics characters doesn't help FORTH to ... All programmers I know use one sort or another to indent or highlight control flow. ... Therefore, I just don't do this kind of crazy things like juggling around with many stack elements. ...
    (comp.lang.forth)
  • Re: Does Python really follow its philosophy of "Readability counts"?
    ... with enforcing that "shouldn't" in the language itself? ... In Python, direct access to pointers is a MUST NOT. ... where you are allowed to mess with the implementation. ... human assembly language programmers? ...
    (comp.lang.python)
  • Re: Why do some people hate java?
    ... programming language like Java to exist, or if Java must exists, there's ... The majority of programmers at the time were using C++, ... and other resources that are just as important to ...
    (comp.lang.java.programmer)