Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!utah-gr!utah-cs!cs.utexas.edu!ut-emx!mybest!moray!uhnix1!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical anal Message-ID: <1565@ficc.uu.net> Date: 21 Sep 88 15:09:16 GMT References: <1553@ficc.uu.net> <3904@lanl.gov> Organization: SCADA Lines: 75 In article <3904@lanl.gov>, jlg@lanl.gov (Jim Giles) writes: > From article <1553@ficc.uu.net>, by peter@ficc.uu.net (Peter da Silva): > > In my ideal syntax, it'd look like this: > > char twodarray^[10][10]; > > twodarray = malloc(sizeof(twodarray^)); > > twodarray^[9][5] = 'c'; > Now, let's add an array syntax to this proposed language, shall we? The proposed variant of 'C', at any rate. > char static_array [10][10] // my declaration to compare with your > // dynamic array. (// is C++ for comment) > char twodarray^[10][10]; > twodarray = malloc(sizeof(twodarray^)); // your array now exists. > Now let's use the array assignment: > static_array = 'c'; // all 100 elements set to 'c' > twodarray = 'c'; // whoops, just set the pointer instead! Error 10 on line 357: Character/pointer conversion. I don't care for your array assignment... if you want a loop, make it a loop. One of the primary design goals of 'C' was to use operations that were close to the fundamental machine operations. Thus no exponentiation, and no array assignment. > // I really meant > twodarray^ = 'c'; // set 100 elements to 'c' at location 'c' > Suppose I write the code with all static > arrays and then decide that I need to switch to dynamic arrays - your > syntax requires me to alter the whole program! To quote you, just use a text editor. Or use the syntax I used earlier: char twodarray^[10] = malloc(10*sizeof(twodarray^)); twodarray[5][5]; > Furthermore, suppose the _use_ of the array is not local to the declaration: > set_array (array) > char array [] // what syntax for passed in array? Depends on what you're passing. That syntax is fine. > { > array = 'c' > } > I could call set_array with either static_array or twodarray as an argument. > The compiler can't know which was which! Why should it care? You're passing a pointer to it anyway. Have you ever played with VIRTUAL arrays in Fortran, and passed one to a routine that's not expecting one? > Your argument about there 'being a pointer there anyway' is wrong. There > is a pointer for the statically declared array as well - it's just optimized > out during constant folding in the compile. Nonesense. There is no cell containing the address of that array. It's just the 'C' equivalent of an assembly language label. 'C' is lower level than Fortran. If that's a problem for you, by all means don't use it. Nobody's forcing you to. All I'm saying is look at the language on its own merits instead of asking why it isn't more like Fortran. -- Peter da Silva `-_-' Ferranti International Controls Corporation. "Have you hugged U your wolf today?" peter@ficc.uu.net