feat: migrate all function literals from fn syntax to new Fn block syntax
Replace all occurrences of the old `fn` function literal syntax with the new `new Fn {|params| body}` block syntax across benchmark, test, and source files. Update the Wren compiler to handle the pipe operator as a block argument delimiter by removing `TOKEN_PIPE` from the newline-swallowing token list and adding explicit newline matching in `infixOp`. Adjust test expectations in `conditional/precedence.wren` to remove `fn`-based expressions and update `test/assignment/local.wren` to use the new syntax.
This commit is contained in:
@@ -634,7 +634,7 @@ var total = 0
|
||||
// constraint so it cannot be accomodated. The cost in this case is,
|
||||
// of course, very low. Typical situations lie somewhere between these
|
||||
// two extremes.
|
||||
var chainTest = fn(n) {
|
||||
var chainTest = new Fn {|n|
|
||||
planner = new Planner
|
||||
var prev = null
|
||||
var first = null
|
||||
@@ -659,7 +659,7 @@ var chainTest = fn(n) {
|
||||
}
|
||||
}
|
||||
|
||||
var change = fn(v, newValue) {
|
||||
var change = new Fn {|v, newValue|
|
||||
var edit = new EditConstraint(v, PREFERRED)
|
||||
var plan = planner.extractPlanFromConstraints([edit])
|
||||
for (i in 0...10) {
|
||||
@@ -674,7 +674,7 @@ var change = fn(v, newValue) {
|
||||
// other by a simple linear transformation (scale and offset). The
|
||||
// time is measured to change a variable on either side of the
|
||||
// mapping and to change the scale and offset factors.
|
||||
var projectionTest = fn(n) {
|
||||
var projectionTest = new Fn {|n|
|
||||
planner = new Planner
|
||||
var scale = new Variable("scale", 10)
|
||||
var offset = new Variable("offset", 1000)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
var fib = fn(n) {
|
||||
var fib = new Fn {|n|
|
||||
if (n < 2) return n
|
||||
return fib.call(n - 1) + fib.call(n - 2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user