Difference between revisions of "Pascal for Java users"

From Free Pascal wiki
Jump to navigationJump to search
(Made a mistake in types section)
Line 273: Line 273:
 
|   8-bit
 
|   8-bit
 
|   -128 .. 127
 
|   -128 .. 127
|  
 
|-
 
|   byte  
 
|   [[Byte]]
 
|   8-bit
 
|   0 .. 255
 
 
|  
 
|  
 
|-
 
|-
Line 285: Line 279:
 
|   16-bit
 
|   16-bit
 
|   -32768 .. 32767  
 
|   -32768 .. 32767  
|-
 
|   short  
 
|   [[Word]]
 
|   16-bit
 
|   0 .. 65535  
 
 
|-
 
|-
 
|   int  
 
|   int  
Line 302: Line 291:
 
|   -2147483648..2147483647  
 
|   -2147483648..2147483647  
 
|     
 
|     
|-
 
|   int  
 
|   [[Cardinal]]
 
|   32-bit
 
|   0..4294967295  
 
|   Cardinal is alias for LongWord
 
|-
 
|   int  
 
|   [[LongWord]]
 
|   32-bit
 
|   0..4294967295  
 
|  
 
 
|-
 
|-
 
|   long  
 
|   long  
Line 319: Line 296:
 
|   64-bit
 
|   64-bit
 
|   -9 223 372 036 854 775 808 .. 9 223 372 036 854 775 807   
 
|   -9 223 372 036 854 775 808 .. 9 223 372 036 854 775 807   
|   
 
|-
 
|   long  
 
|   [[QWord]]
 
|   64-bit
 
|   0 .. 18 446 744 073 709 551 615   
 
 
|     
 
|     
 
|-
 
|-
Line 348: Line 319:
 
|   [[WideChar]]
 
|   [[WideChar]]
 
|   16-bit
 
|   16-bit
 +
|  
 +
|  
 +
|-
 +
|   String  
 +
|   [[String]]
 
|    
 
|    
 
|  
 
|  

Revision as of 01:17, 30 March 2009

  Java     Pascal     Additional comments
  {     Begin    
  }     End  
  =     :=   Becomes  
  ==     =   Equal
  /     /   Division (or sometimes div)  
  %     Mod   Modulo operation
  !     Not  
  !=     <>   Not equal  
  &&     And  
  ||     Or  
  ^     Xor  
  >>     Shr   bit shift right  
  <<     Shl   bit shift left  
  ++     Inc  
  --     Dec  
  /*     {   Comment start
  /*     (*   Comment start
  */     }   Comment end
  */     *)   Comment end
  //     //   End of line comment (only one line comment)  
  null   Nil  
  abstract   Abstract  
  break   Break  
  class TheClass { }   TheClass = Class End;  
  class TheClass<T> { }   Generic TheClass = Class<T> End;   Generics are classes only as of 2.2.2, likely to support more in the future
  continue   Continue  
  do while     Repeat Until Not   
  do while !     Repeat Until    
  extends   SubClass = Class(BaseClass)   class SubClass extends BaseClass --> SubClass(BaseClass)
  final   Const   for constants, not uninheritables
  for ++     For To Do  
  for --     For Downto Do    
  if()     If Then  
  if() else     If Then Else  
  implements   SomeClass = Class(SomeInterface)  
  import   Uses  
  instanceof   Is  
  interface   TheInterface = Interface  
  native   StdCall  
  native   CDecl  
  new primitive_type[#];   SetLength(ArrayVar, #);    
  new Class();   InstanceVar := TheClass.Create;    
  package   Unit  
  private   Private  
  protected   Protected  
  public   Public  
  return   FunctionName  
  return   Result  
  static   Static  
  static   Class Function  
  static   Class Procedure  
  super   Inherited   Parent constructor call
  switch case break     Case Of End  
  switch case break default     Case Of Else End    
  synchronized    
  this   Self  
  throw   Raise  
  throws    
  transient    
  try { } catch   Try except  
  try { } catch finally   Try Finally  
  void   Procedure  
  volatile    
  while     While Do  


  Java type     Pascal type     Size (bits)     Range    
  byte     Shortint   8-bit   -128 .. 127  
  short     SmallInt   16-bit   -32768 .. 32767  
  int     LongInt   32-bit   -2147483648..2147483647    
  int     Integer   32-bit   -2147483648..2147483647    
  long     Int64   64-bit   -9 223 372 036 854 775 808 .. 9 223 372 036 854 775 807    
  float     Single   32-bit   1.5E-45 .. 3.4E+38  
  double     Double   64-bit   5.0E-324 .. 1.7E+308  
  boolean     Boolean     False True  
  char     WideChar   16-bit    
  String     String