TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
11.33k stars 349 forks source link

Deletion Detector Keyword #606

Open InfectedGriffon opened 5 months ago

InfectedGriffon commented 5 months ago

This keyword would be similar to how when detects when a variable mutates. However, instead of detecting changes, it would detect the deletion of a primitive (such as with the delete statement). Some potential names for this keyword include ondelete, ~ath (pronounced "til death"), or posthumous (pronounced "poz thoom us"). The addition of this keyword would greatly improve code safety by adding the ability for checks to be created to ensure that the primitives used in your program don't get deleted maliciously. Additionally, this keyword would expand the event system in DreamBerd started by keywords such as when, after, and addEventListener.

Example code:

ondelete(4) {
   '4 was deleted'?
}
delete 4! // prints '4 was deleted'