* * *

Author Topic: Annoying issues in Object Pascal - what are those?  (Read 6796 times)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5643
Re: Annoying issues in Object Pascal - what are those?
« Reply #45 on: February 17, 2017, 12:03:41 pm »

3. Incompatible type for similar data type, such as:
Code: Pascal  [Select]
  1. type
  2.   aoi: array of integer;
  3.  
  4. function a(i: array of integer);
  5.  

They are not similar. One is dynamic array, one is open array. The mistake is not that they are incompatible, but that the same syntax is used for two different things.


marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5643
Re: Annoying issues in Object Pascal - what are those?
« Reply #46 on: February 17, 2017, 12:06:52 pm »
Not very useful. Often used option
Code: Pascal  [Select]
  1. try
  2.   Alloc;
  3.   try
  4.     DoSome;
  5.   finally
  6.     Free;
  7.   end;
  8. except
  9.   HandleErrors;
  10. end;
not covered by this pattern.
Ideologically different design. Try finally to conserve resources, but try except for error handling.

I think this is the best point in the try..except..finally discussion.

In Delphi, you need finally so often to free resources, so if you are going to invent a new language dialect, you might want to tackle that (e.g. with RAII, GC), rather than micromanaging typing. (which is nearly never a good idea)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus