Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.pascal.borland    |    Borland Pascal was actually pretty neat    |    2,978 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 2,257 of 2,978    |
|    Jason Burgon to All    |
|    Re: HELP: beginner to pascal    |
|    29 Aug 06 14:15:05    |
   
   XPost: borland.public.turbopascal   
   From: jaynews@ntlworld.com   
      
   "HubbleBubble" wrote in message   
   news:1156855906.819475.216730@m73g2000cwd.googlegroups.com...   
      
   > For a start both Pascal & C are very closely related they are both   
   > Wirthian languages.   
      
   Nicolaus Wirth would be turning in his grave (if he wern't still alive), if   
   he heard you saying that C is Wirthian language!   
      
   > If you understand C pascal should be easy [...]   
      
   True. Two other important differences are:   
      
   1). Pascal is strongly typed, like C++. This means that you can't generally   
   ~implicitely~ cast apples into oranges. To do this you must ~explicitely~   
   tell the compiler that the cast is ok. E.g: P := Pointer(X);   
      
   2) There is a Boolean type explicitly defined in Pascal. This also ties in   
   to (1) in that you cannot implicitely cast an integer into a boolean like   
   you can in C. That means for example that all conditional branches ~must~   
   take an explicit boolean expression. Where in C you might have something   
   like:   
      
   int v;   
   {   
    .....   
    if (v)   
    {   
    ....   
    }   
   }   
      
   This is not allowed in Pascal because "v" is not a boolean variable or a   
   boolean expression. Instead you need to explicitely generate a boolean   
   expression:   
      
   var v;   
   begin   
    .....   
    if v <> 0 then   
    begin   
    ......   
    end;   
   end;   
      
   Note that the parenthesis are ~not~ required in the Pascal version.   
      
   One other mistake that many Pascal programmers make is to explicitely test   
   for True in pascal conditionals:   
      
    if SomeBoolValueOrExpression = True then   
    ....   
      
   This is bad because it compares SomeBoolValueOrExpression to the exact   
   ordinal value of 1, which you should never do because although Ord(True) =   
   1, Pascal will treat any non-zero value as True (ie not False). So the   
   correct code for the above is simply:   
      
    if SomeBoolValueOrExpression then   
    ....   
      
   or if you want its converse:   
      
    if not SomeBoolValueOrExpression then   
    ....   
      
   --   
   Jason Burgon. Author of Graphic Vision   
   http://homepage.ntlworld.com/gvision   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca