Skip to content

Rethink order of operations (multiplication/division) #76

Open
@printfn

Description

@printfn

Consider the three operators:

  • multiplication *
  • division /
  • function application/implicit multiplication/implicit addition (used in sin pi, 3 kg, (2)(4) or 1 1/2).

Current these are all parsed mostly left-to-right, with mostly the same precedence (and a bunch of special cases).

These calculations are correct and should continue working as they do now:

  • 1 3/8 inches
  • 1/2 kg
  • 3pi/2 radians to degrees
  • -sin (pi/2)
  • 5 feet 2 inches

These examples don't do what the user might expect:

  • 1 meter / 5 seconds (parsed as (1 meter / 5) * seconds)
  • sin pi/2 (parsed as (sin pi)/2)

This calculation can't be parsed at all:

  • 3sin 5 (should be equivalent to 3 * (sin 5))

It would be nice to come up with a consistent solution for all these expressions, preferably not involving whitespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions