Bug #5568

SCL: operator precedence

Added by Timo Korvola over 2 years ago. Updated over 2 years ago.

Status:ClosedStart date:2014-11-03
Priority:4Due date:2015-01-16
Assignee:Hannu Niemistö% Done:

100%

Category:SCLSpent time:-
Target version:1.18.1
Release notes:SCL default operator precedence changed to 9 as in Haskell so `foo` binds tighter than $, where foo is a binary function.
Story points-
Velocity based estimate-
ReleaseSimantics 1.18.1Release relationshipAuto

Description

Try this on the SCL console:

foo x y = x + y
(0-) $ 3 `foo` 4

Surprisingly the result is 1: apparently $ binds tighter than `foo`. This is different from Haskell, where the result would be -7.

Associated revisions

Revision 30750
Added by Hannu Niemistö over 2 years ago

(refs #5568) Fixed SCL default precedence and handling of variables as operators

Revision 30751
Added by Hannu Niemistö over 2 years ago

(refs #5568) Quick workaround to precedence handling bug introduced in the previous commit to this issue.

Revision 30871
Added by Hannu Niemistö over 2 years ago

(refs #5568) Proper fix for parsing :=

History

#1 Updated by Timo Korvola over 2 years ago

Affects Apros 6.04.06, which has SCL Compiler 0.4.0.r029374.

#2 Updated by Hannu Niemistö over 2 years ago

  • Status changed from New to Resolved

I fixed the default preference to 9 as in Haskell. However, contrary to Haskell the default assosiativity of operators is still non-assosiative:

> 1 `foo` 2 `foo` 3
            ^^^^^ (1:12-1:17)
Operator foo is not associative.

After the modification:

> foo x y = x + y
> (0-) $ 3 `foo` 4
-7

I also added support for using variables (not defined on top level) as operators:

> g f x = x `f` x
> g (+) 3
6

#3 Updated by Tuukka Lehtonen over 2 years ago

  • Due date set to 2015-01-16
  • Target version set to 1.18.1
  • Start date set to 2014-11-03

#4 Updated by Tuukka Lehtonen over 2 years ago

  • Release set to 17

#5 Updated by Tuukka Lehtonen over 2 years ago

  • Status changed from Resolved to Closed

#6 Updated by Tuukka Lehtonen over 2 years ago

  • % Done changed from 0 to 100
  • Release notes set to SCL default operator precedence changed to 9 as in Haskell so `foo` binds tighter than $, where foo is a binary function.

Also available in: Atom PDF