Forum > Suggestions

Proposal: unions as a new type and arrays with number of elements

<< < (24/24)

marcov:

--- Quote from: Warfley on May 12, 2023, 12:08:57 pm ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TTest = record    A: Integer;    B: record      case Boolean of      True: (A: Integer);      False: (B: Integer);    end;    C: Integer;  end;
--- End quote ---

The problem is that if you want "B" anonymous you have to fold C into one of the branches of false or true. That is the fold trick around Pascal's case of limitations.

However this makes automated or semi automated conversion somewhat difficult, and possibly also has alignment issues. (e.g. what if B.A is some vector type)

Bad Sector:

--- Quote from: marcov on May 13, 2023, 01:11:03 pm ---IMHO it is the actual strength of Lazarus and Delphi. Just look at the Perl or Python major version transitions that took a decade for languages that have much more development power and sponsoring than Pascal.
--- End quote ---

Indeed, Free Pascal has a ton of warts (e.g. there are three compound types - record, object, class - and while all three have common features, none of them has all the features, like e.g. no management operators in object, no inheritance in record, no stack allocation or embedded use in class) but one of the main reasons i keep using it is that the code i wrote years ago still works (though another very important reason is Lazarus - there are other languages that are backwards compatible, like -say- C and C++, but none have something like Lazarus and LCL).

Also FWIW while Python was a disaster, Perl decided to roll back on that and make the incompatible "Perl 6" a different language (Raku) while adopting a Free Pascal-like approach to introducing new functionality without breaking backwards compatibility via something similar to modeswitches.

Navigation

[0] Message Index

[*] Previous page

Go to full version