Question about the Language

Topics related to the use of Oberon language features
Locked
jboavida
Posts: 1
Joined: Fri Feb 11, 2011 7:07 pm

Question about the Language

Post by jboavida » Fri Feb 11, 2011 7:20 pm

Hello,

Congratulations for this Pascal compiler for ARM. Beeing a Pascal Fan myself, it was a good suprise finding this piece of software.
As all we know Pascal doesn't care about capitalization. "BEGIN" is the same as "begin" or "Begin".

Your complier only accepts capitals as reserver words. Is there a reason for that?
I'm use to Delphi, and seeing the capitals seems a little odd...

Nice work

Joaquim

cfbsoftware
Site Admin
Posts: 493
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: Question about the Language

Post by cfbsoftware » Mon Feb 14, 2011 6:51 am

Thank you for your compliments :)

Although Oberon-07 was designed by Niklaus Wirth, the designer of Pascal there are a few fundamental differences. Hence, not only are reserved words capitals only, but also all other identifiers are case-sensitive. Wirth introduced this change when he designed the language Modula-2 (a successor of Pascal and predecessor of Oberon).

I don't recall any articles by Wirth giving any reasons behind this change. However, there are a few aspects that I find useful:

a) As long as you avoid all-uppercase identifiers you know you can use whatever word is the best choice for a particular variable.

e.g. some of the following would be invalid in Pascal:

Code: Select all

colour := black; type := digital; case := plastic;
now := 2011; then := 1969;


b) If you avoid using all-uppercase characters in your own identifiers your program will never be invalidated at some future time if, and when, new keywords are added to the language.

c) The language designer has the freedom to select the most suitable keyword for a new feature rather than trying to avoid a word that is likely to break existing software.

d) Syntax-highlighting might be useful when working on a screen but monochrome printed program text has yet to disappear altogether.

e) Syntax-highlighting is of little benefit for those who suffer from colour blindness.

f) Rather than using a Delphi-like convention of prefixing typenames with the letter T you can use the Oberon convention of starting type names with a capital letter and variable names with a lower case letter:

Code: Select all

list: TList;
then becomes:

Code: Select all

list: List;
The thought of doing this can perplex Pascal / Delphi programmers who have had no hands-on Modula-2 / Oberon experience. Try it for a while before deciding whether you like it or not.

On the negative side, the main problem I experienced with uppercase keywords was related to my typing (in)ability. That is the main reason why Astrobe has its auto-capitalisation feature ;) You can keep typing in lowercase and Astrobe will automatically detect keywords and convert them to uppercase for you. It is also smart enough not to do this within a comment. On the odd occasion when you want to use a keyword as a lowercase variable, press CTRL-L (for lowercase) at the end of the word and it will convert it back for you.

Regards,
Chris Burrows
CFB Software

kevinhely
Posts: 29
Joined: Wed May 18, 2011 3:35 am

Re: Question about the Language

Post by kevinhely » Wed May 18, 2011 4:44 am

I've also found that capital letter-keywords offer an additional way of emphasising the structure of the code...

Locked