DreamBerd
DreamBerd copied to clipboard
Suggestion: Add the "roughly" operator
Introduce a new operator ~
that can be placed before keywords or operators, which allows the compiler to optimize code as much as it wants, as long as the annotated code does roughly the same. For example, a function
~fn abs(v) => {
if(v<0) {
return -v!
}
return v!
}
can be optimized so that it always returns a positive value, but it's not guaranteed that it's the absolute value of v
. In combination with the vroom
statement (see #54), this allows for some really good optimizations.
When prefixing an operator, it does the same. For example, 3.14 ~<= 3
may evaluate to true
, maybe
, or false
, depending on the optimization the compiler chose.
The user can add as many ~
as they want, allowing for even more optimizations, including (but not limited to) removal of the annotated code.
I just realised this can be applied to whole files by prepending the filename or folder with a tilde.
This should apply to file extensions as well:
If you want to load lots of images (say, a folder of PNG images) but are worried that the decompression algorithm will take too long, you can make all the files .~png
files, which will be decoded with a faster algorithm that approximates the original image, instead of the standard lossless version.
Again, adding more ~
means the program can use lossier algorithms, and maybe even one that spits out some stuff from a random space in memory.
This is great