Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Truncation and Type declaration versus Type Inference for Defaults

#62

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).

Reported by David Cox · October 18th, 2010 @ 03:13 PM

State: resolved
Milestone: none
Assigned to: Christopher Stawarz Christopher Stawarz

Activity

  1. Christopher Stawarz
  2. Christopher Stawarz
    Christopher Stawarz
    • State changed from new to open
    • Milestone cleared.
    • Assigned user set to David Cox

    April 8th, 2011 @ 10:40 AM

  3. Christopher Stawarz
  4. Christopher Stawarz
  5. Christopher Stawarz
  6. Christopher Stawarz
  7. Christopher Stawarz
    Christopher Stawarz
    • 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.

    October 3rd, 2014 @ 04:55 PM

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.