-
Notifications
You must be signed in to change notification settings - Fork 131
feat: implement no_std option #961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Teal Playground URL: https://961--teal-playground-preview.netlify.app |
Thanks for the initiative! Given that But now I'm thinking about the block you have marked with I also think a few definitions (global types |
Thank you for the quick review @hishamhm!
Yup, I also had the feeling that Just to be sure to be aligned with your ideas : for my |
Yes. Perhaps we could also introduce In any case, it would be important to be also able to do stdlib replacement via |
@Aire-One I just pushed a change to |
Nice! Thank you for that @hishamhm. It's indeed helpful to me. I'll dismiss the |
set_special_function(stdlib_globals["xpcall"].t, "xpcall") | ||
set_special_function(stdlib_globals["rawget"].t, "rawget") | ||
set_special_function(stdlib_globals["require"].t, "require") | ||
if stdlib_globals["math"] then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have a tricky situation here.
These stdlib_globals
customizations are being tested before the predefined_modules
array below. So, if someone is using --global-env-def
to load an alternative stdlib, that won't be picked up because it's too late.
But then, if you tried to switch the order around and do these customizations after the predefined modules load, then any other predefined module which does expect a fully configured standard library won't have one ready yet. I think the conclusion is that we do need a configuration for a custom standard library that is separate from (and loaded earlier than) any other predefined modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I was on vacation and expected to find some time earlier.
These stdlib_globals customizations are being tested before the predefined_modules array below. So, if someone is using --global-env-def to load an alternative stdlib, that won't be picked up because it's too late.
You mean "to load an alternative stdlib" as in "redefining something from the stdlib"? In this situation, the --global-env-def
option alone would yield an global was previously declared as <const>: ...
error. You are required to also use the --no-std
flag.
I agree this behavior is not optimal, but since the --no-std
flag is used, it sounds correct to me 🤷
Alternatively, when the no_std
option is trusty, we could load the first predefined_modules
instead (and skip it to when loading the other predefined modules latter). This way, it could be documented as "when --no-std
is used, the first predefined-module option can be an alternative stdlib".
I think the conclusion is that we do need a configuration for a custom standard library that is separate from (and loaded earlier than) any other predefined modules.
Do you suggest introducing (back) an --stdlib <file>
CLI option that replaces the stdlib
string?
Following discussion from #947 (reply in thread), here is my attempt at implementing the ability to replace the stdlib.
This is working as I expect and allows me to run
tl check --stdlib busted-env.d.tl some_spec.tl
🎉. Tests and documentation are missing. I open this PR as a draft to get first reviews and implementation validation (see in-code comments).