3 ms·
Very cool! Does it replace identical expressions in the same scope? Like: let tau = 3.14 +. 3.14 becomes let pi = 3.14 let tau = pi +. pi ? ED
by panglesd 1y ago
Very cool!
Does it replace identical expressions in the same scope? Like:
let tau = 3.14 +. 3.14
becomes
let pi = 3.14
let tau = pi +. pi
?
EDIT: Or even crazier with function:
let _ = (x + 1) + (y + 1)
becomes
let plus_one a = a + 1
let _ = (plus_one x) + (plus_one y)
(I ask this just out of curiosity. Even the "simpler" version is very impressive!)
- nukifw 1y agoNop, for the moment, we try to not "infer user usages"! But if you extract an expression with variable, there will be, obviously, not be repeated: let tau = let pi = 3.14 in pi + pi if we extract `pi + pi` it will lead (if you do not give any concrete name) to the following code: let fun_name1 pi = pi + pi let tau = let pi = 3.14 in fun_name1 pi
- greener_grass 1y agoLLM generated variable names would be nice!
- ethan_smith 1y agoMost refactoring engines don't automatically replace all identical expressions by default since it can change semantics (especially with side effects), but they typically offer a separate "introduce and replace all occurrences" option that you can explicitly choose.