Truncation and Type declaration versus Type Inference for Defaults
Reported by David Cox | October 18th, 2010 @ 03:13 PM
We ran into a few bumps recently on a newly upgraded system
wherein default variable value were getting truncated because the
variables were "declared" as integers (the default), but were given
a non-integer default value (e.g. 0.5).
There was an appropriate warning (though these are always easy to miss), but I'm wondering if the "correct" behavior shouldn't be to respect the inferred type of the default value, and warn if it is at odds with the "declared" value, rather than respecting the declaration and overriding the default. At the very least, if we are going to respect the declared value, it probably should be an error, since fractional numbers truncate to 0, leading to subtly strange behavior.
Clearly, MW variables are internally dynamically typed, and it's not 100% clear why we put a type field in the XML in the first place (I think that the original idea was that this could inform how the UI looked; e.g. display increment/decrement buttons, that sort of thing).
Comments and changes to this ticket
-
Christopher Stawarz April 8th, 2011 @ 10:40 AM
- State changed from new to open
- Milestone cleared.
- Assigned user set to David Cox
-
Christopher Stawarz April 8th, 2011 @ 10:42 AM
- Assigned user cleared.
-
Christopher Stawarz October 3rd, 2014 @ 04:55 PM
- State changed from open to resolved
- Assigned user set to Christopher Stawarz
Variables can now have type "any", in which case the type of the default value is always inferred. New variables created in the editor now have type "any" by default. Other types are handled as before, to preserve compatibility with existing experiments.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
The core framework and supporting libraries for the MWorks Suite