Skip to content
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

Have native functions throw for invalid arguments #939

Open
mfikes opened this issue May 26, 2019 · 0 comments
Open

Have native functions throw for invalid arguments #939

mfikes opened this issue May 26, 2019 · 0 comments

Comments

@mfikes
Copy link
Member

mfikes commented May 26, 2019

Many of the PLANCK_*** native functions check their argument counts and types and then only process things if those checks pass. When they don't the functions typically return null.

Instead these functions could throw JavaScript Errors.

This isn't that big of a deal, since these functions are typically called via ClojureScript wrappers that pass arguments correctly, but revising the functions to throw for bad arguments seems like the right thing to do anyway.

As a concrete example, the last two calls here could throw instead of just returning nil:

cljs.user=> (js/PLANCK_IS_DIRECTORY "abc")
false
cljs.user=> (js/PLANCK_IS_DIRECTORY 123)
nil
cljs.user=> (js/PLANCK_IS_DIRECTORY)
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant