vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
550 stars 90 forks source link

input(string filename) fails #382

Closed dafadey closed 1 year ago

dafadey commented 1 year ago

input() fails for missing file making error(file) completely useless

testing code: Welcome to Asymptote version 2.86 (to view the manual, type help)

write(error(input("trololo", check=true))); -: 1.6: runtime: Cannot open file "trololo"

johncbowman commented 1 year ago

First of all, check is a boolean not a string, so you need to remove the quotes enclosing true.

If you want to mask the above error you need to set check=false:

Then you can say

write(error(input("trololo",check=false)));

dafadey commented 1 year ago

Sure no quotes (I added this check="true" manually to the comment being lazy to copy output after second run with this option set and thus misprinted) Thanks a lot! Please add some clarifications to the documentation. I just got it my self by tweaking with asy source. It is really counter-intuitive! btw, I saw -O1 in config files do you guys build with just O1?

johncbowman commented 1 year ago

To quote from the documentation:

If the optional boolean argument check is false, no check will be made that the file exists.

If you look in configure.ac, you will see that the default optimization is -O3.