Fork me on GitHub
#cljs-dev
<
2019-06-24
>
dnolen13:06:37

@john it should be possible to detect that kind of trivial case - but in general there are no surprises here

dnolen13:06:14

it's been that way for 8 years and has no real impact on portability of code far as I can tell

dnolen13:06:14

do anything at runtime would require argument introspection and that's a JS VM perf hole - so not going to do that

john13:06:01

Thats what I figured. Thanks @dnolen FWIW, I think I prefer ClojureScript's more permissive version.

mfikes14:06:41

@john FWIW, your program is incorrect. (ClojureScript is not intentionally being permissive.)

mfikes14:06:41

For example, if we discovered a way to add arity checks at runtime without a perf penalty, then such broken programs would—well—break.

john14:06:41

It's just "unimplemented" spec, per say, right?

john14:06:07

Linters could probably start checking it now at compile time

john14:06:40

Well, for whatever branches it can infer

john14:06:04

The only thing that worries me is that devs might start passing in extra args to anonymous fns with the expectation that, in the future, they may want to expand their API to handle those extra args, but drop them silently until then. That code would break if stricter arity checking were enforced

favila14:06:00

yeah our codebase definitely has laziness about e.g. zero-arg inline fns for event handlers (they should have one unused event arg)

mfikes14:06:50

The analyzer could be improved to emit arity diagnostics for immediately invoked anonymous functions

mfikes14:06:01

It could probably also catch, in general, arity issues with immediately invoked expressions

dnolen16:06:17

@john for portable code you won't do that ... because it's not portable and it will be come readily apparent

dnolen16:06:46

I haven't seen the case you're talking about personally - most of the cases I've seen are cases of code cleanliness

dnolen16:06:11

i.e. passing an extra arg that was dropped, or generally more args than necessary - due to some refactoring

dnolen16:06:59

and the only cases where I saw that was when something was used higher order

john17:06:52

Yeah, it's never bit me personally, from a code portability POV