Lartu / ldpl

COBOL-like programming language that compiles to C++. With serious dinosaurs with neckties and briefcases 🦕💼
https://www.ldpl-lang.org/
Apache License 2.0
158 stars 24 forks source link

EMPTY VECTOR #86

Closed xvxx closed 5 years ago

xvxx commented 5 years ago

What do you think about an EMPTY VECTOR vec command that clears the content of a vector?

I am splitting apart string into vectors in a loop, and right now I'm clearing the vector by hand. Maybe that's okay though?

Lartu commented 5 years ago

Yes, that would actually be very nice, as atm there's no way of removing a vector from memory (thus rendering every program into an executable memory leak). I guess there also should be a way to probe if an index exists ("has been initialized") on a vector or not, without actually accessing (and initializing) it.

Lartu commented 5 years ago

http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_12.html

You can find out if an element exists in an array at a certain index with the expression: index in array

This expression tests whether or not the particular index exists, without the side effect of creating that element if it is not present. The expression has the value one (true) if array[index] exists, and zero (false) if it does not exist.

Something like this should be done in LDPL along with a way to empty vectors and delete particular indices.