[fpc-pascal] Array clearing
Michael Van Canneyt
michael at freepascal.org
Wed Apr 12 16:25:57 CEST 2017
On Wed, 12 Apr 2017, Ryan Joseph wrote:
>> On Apr 12, 2017, at 8:05 PM, noreply at z505.com wrote:
>> Since fillchar is not a general way to clear an item it almost seems like pascal needs a way to clear things generically, such as Array.clear
>> But I guess this would be reinventing OOP, or Ruby where everything is an object and can have .Something tacked on to it.
> I agree. Dynamic arrays only advantage is they are managed by the compiler but they’re missing obvious functionality like adding/removing elements so they’re usually pretty useless. Why was the functionality of appending an element to the end never added? That’s one the most basic operations for arrays.
Because dynamic arrays are implemented after Delphi's implementation.
Only recently the new array constructors were implemented.
Adding a pop/push requires compiler magic, and could be implemented;
but the question is whether it is worth it, given the plethora of other
options at your disposal.
More information about the fpc-pascal