Quote:
to programmers English IS a native language
|
Really? Here's a random bit of Java (probably with added bugs.. I wrote it)
Quote:
public boolean importCAGraphicLattice(CAEngine engine, File file) {
if (!file.exists() || !file.canRead() || file.isDirectory()) {
showErrorMessage(importTitle, "Unable to read " + file.getName());
return false;
}
try {
image = ImageIO.read(file);
} catch (Exception e) {
showErrorMessage(importTitle, "Error reading " + file.getName() +
":\n" + e);
return false;
}
if (image == null) {
showErrorMessage(importTitle, "File " + file.getName() +
" is not a known graphic format");
return false;
}
System.out.println("File: " + file.getName());
System.out.println("Image: " + image);
int cCols = countImageColors();
System.out.println("Colours: " + cCols);
if(cCols > {
showErrorMessage(importTitle, "File " + file.getName() +
" has too many colours for a valid lattice");
return false;
}
if(cCols > engine.getRule().getNumCellStates()) {
showErrorMessage(importTitle, "File " + file.getName() +
" has too many colours/states for the current rule");
return false;
}
if(!readStateColors(engine.getRule().getNumCellSta tes())){
showErrorMessage(importTitle, "File " + file.getName() +
" does not define colour/state correspondance\n" +
"(see Help for further information)");
// I could add a dialog box to sort out correspondances...
return false;
}
for(int c = 0; c < cCols; c++)
System.out.println("Colour " + c + ": " + stateColors[c]);
try {
int w = image.getWidth();
int h = image.getHeight() - 1; // exclude state color row
engine.setLatticeSize(w, h);
CACursor.setCursor(Cursor.WAIT_CURSOR);
for(int y = 0; y < h; y++)
for(int x = 0; x < w; x++) {
int c = image.getRGB(x, y);
int v = 0;
for(int t = 0; t < cCols; t++)
if(stateColorRGBs[t] == c)
v = t;
engine.setCell(x, y, v);
}
} catch (CAException e) {
CACursor.setDefaultCursor();
showErrorMessage(importTitle, "Error loading " + file.getName() +
":\n" + e);
return false;
}
CACursor.setDefaultCursor();
return true;
}
|
How many non-programmer English-speakers would consider that to be written in English? I've used vaguely-English names for variables, methods etc, but I could just have easily used any language compatible with the recognised character set for the language. Arbitrary labels are just that - arbitrary. And programming 'languages' aren't languages in the normal sense at all, any more than '6 x 7 = 42' or 'R = S/C+V' is.
EDIT: - just to clarify, the smiley character isn't normally used in Java, and I do actually indent code when I write it - the formatting seems to have got slightly screwed up when I pasted it here...