FlatLang / Flat

(Deprecated) Soon-to-be legacy Flat compiler all in one
6 stars 0 forks source link

Add support for pulling out arguments to evaluate in order when required #380

Open BSteffaniak opened 7 years ago

BSteffaniak commented 7 years ago

e.g.

expect(let inches = Units.toInches(pipe.length)).toBeWithinToleranceOf(let expected = 393.701, 0.001, message: "#pipe.length => #inches but expected #expected")

where the equivalent code would be

let inches = Units.toInches(pipe.length)
let expected = 393.701
let message = "#pipe.length => #inches but expected #expected"

expect(inches).toBeWithinToleranceOf(expected, 0.001, message: message)

required for c because of the ridiculous unspecifiedness of function call argument evaluation order.

ALSO: must be recursive for function calls passed as arguments to functions that require pulling out:

Console.log(expect(let inches = Units.toInches(pipe.length)).toBeWithinToleranceOf(let expected = 393.701, 0.001, message: "#pipe.length => #inches but expected #expected"))

/// converted to:

let inches = Units.toInches(pipe.length)
let expected = 393.701
let message = "#pipe.length => #inches but expected #expected"

let log = expect(inches).toBeWithinToleranceOf(expected, 0.001, message: message)

Console.log(log)

Well... this only needs to be done to arguments that are variables that are being modified AND have that variable's use elsewhere in the same function call argument list, so this would be valid:

let inches = Units.toInches(pipe.length)
let expected = 393.701
let message = "#pipe.length => #inches but expected #expected"

Console.log(expect(inches).toBeWithinToleranceOf(expected, 0.001, message: message))
BSteffaniak commented 7 years ago

This will be self-contained component for the new compiler in the tree transformation phase