Perfect Developer tutorial This page last modified 2011-10-29 (JAC)

Introducing Perfect Quiz

It is (of course) up to you how you use these quizzes.

One method which some students have found helpful is to create their own Notepad files for their answers, keeping the Notepad file, the tutorial, and the Language Reference Manual all open at the same time, in different windows.

1. Which of the following are valid identifiers in Perfect?

  1. address_1
  2. 1st_address
  3. FirstAddress
  4. ___thisIsARatherLongIdentifierIWouldLikeToUse___
  5. _
  6. value
  7. value_
  8. $result

(b) is not valid because it begins with a digit.
(f) is not valid because value is a reserved word in Perfect.
(h) is not valid because it contains a character that is not a letter, digit or underscore.
The remainder are valid identifiers.


2. Rewrite the following fragment of Perfect, removing some of the redundant white space:

In English, this fragment is read as

“function square, with one parameter x of type int, returning int, is defined as x multiplied by x.”
function     square
( x : int )
 :     int
             ^=  x   * x  ;


The only white space that is really needed is the space between the reserved word function and the identifier square; so with all redundant white space removed, the fragment looks like this:

function square(x:int):int^=x*x;

To improve readability, it is best to retain some of the redundant white space, e.g.:

function square(x: int): int
    ^= x * x;