Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Merge requests
  • !245

honu-style operators

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Tim Disney requested to merge operators into master Feb 07, 2014
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 5

Work in progress at the moment but I wanted to get feedback on syntax. The honu syntax looks like:

// binary_operator <name> <prec> <assoc> <binary transform>
// unary_operator <name> <prec>  <unary transform>
binary_operator raise 10 left {
  function (left, right) {
    syntax(pow(left, right))
  }
}

Some ideas using our syntax:

binary_operator raise 10 left ($left, $right) {
    return #{Math.pow($left, $right)}
}
// $left and $right are implicit (or $lhs, $rhs) 
binary_operator raise 10 left {
    return #{Math.pow($left, $right)}
}
// could decide binary vs. unary by existence of assoc operator
operator raise 10 left {
    return #{Math.pow($left, $right)}
}
operator neg 10 {
    return #{-$op}
}
// using arrow
operator raise 10 left { $lhs, $rhs } => {
    return #{Math.pow($lhs, $rhs)}
}
// haskelly way (too terse IMO)
infixl 10 raise {
    return #{Math.pow($left, $right)}
}
left operator 10 {
    return #{Math.pow($left, $right)}
}

Any other ideas?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: operators