web icon indicating copy to clipboard operation
web copied to clipboard

Consider using `num` instead of `double` for parameter types

Open sigmundch opened this issue 1 year ago • 3 comments

This is more backwards compatible with types used in dart:html, and hence less work to adapt a call that used to pass num or int arguments.

sigmundch avatar Jun 27 '23 00:06 sigmundch

Reopening due to concerns around users accidentally downcasting num in dart2wasm because they may assume dart2wasm has the same number semantics as the JS compilers (it does not).

A compromise here to:

  • Make migration and passing in integer values easier
  • Avoid the accidental downcasting

is to keep the parameter types as num but the return types as double.

cc @eyebrowsoffire

srujzs avatar Oct 25 '23 21:10 srujzs

I also think this might be worth reevaluating to some extent. My feeling is that today's Dart developers aren't as familiar with num as they used to be.

Cases passing int literals would keep working with double and I think any remaining changes necessary shouldn't be too bad. The extra consideration might be helpful in the first place.

parlough avatar Feb 09 '24 22:02 parlough

I agree. I want to perhaps include this in the next major release (which we'll certainly have as we tackle other issues). It does mean a little bit of pain for migration, but it should be minimal.

My feeling is that today's Dart developers aren't as familiar with num as they used to be.

Most developers aren't aware of the number differences partly because it derives from a web vs native difference. Now that we have the number difference within web, this will pop up more often.

srujzs avatar Mar 01 '24 01:03 srujzs