You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The advantage of a let expression is that it allows to bind a parameter value to a
function in a single expression.
The alternative to this requires creating a unique function each call:
a) create a function with required value of parameter as variable in body
b) create a parameterless function call
c) pass expression to location where it is needed
(e.g the Do_Expression method of "tree_walk.adb")
As part of the cleanup work on arrays, there were a number of locations where 'let expressions' were used.
But in the scenario of using a let expression to bind a parameter to a function call - there are issues (the binding seems to fail, and it looks at a first glance like it is interpreted as a raw irep)
It is likely something minor is missing in the process.
• In the case of " Do_Aggregate_Literal_Array" in tree_walk.adb a let expression was used as so:
let_expr_irep := Make_Let_Expr (Symbol => Literal_Temp,
Value => Array_Expr,
Where => Result_Struct,
I_Type => Result_Type,
Source_Location => Sloc (N));
return let_expr_irep;
This allows binding an array to a parameter of a function.
As this did not work, the entire callee was rewrote to avoid the let expression.
While this is a valid workaround - it seem worthwhile to investigate the original issue - let expressions, as clarified in the first paragraph, can be a useful tool to avoid trivial duplication of simple function calls.
The text was updated successfully, but these errors were encountered:
sonodtt
changed the title
let expression binding of parameter to a function fails.
let expression binding of argument to a function fails.
Feb 11, 2019
NB it has been verified that let expressions do work in the simple scenario of binding a value to a variable.
https://github.com/sonodtt/gnat2goto/tree/irep_debug_framework_v0
The advantage of a let expression is that it allows to bind a parameter value to a
function in a single expression.
The alternative to this requires creating a unique function each call:
a) create a function with required value of parameter as variable in body
b) create a parameterless function call
c) pass expression to location where it is needed
(e.g the Do_Expression method of "tree_walk.adb")
As part of the cleanup work on arrays, there were a number of locations where 'let expressions' were used.
But in the scenario of using a let expression to bind a parameter to a function call - there are issues (the binding seems to fail, and it looks at a first glance like it is interpreted as a raw irep)
It is likely something minor is missing in the process.
• In the case of " Do_Aggregate_Literal_Array" in tree_walk.adb a let expression was used as so:
let_expr_irep := Make_Let_Expr (Symbol => Literal_Temp,
Value => Array_Expr,
Where => Result_Struct,
I_Type => Result_Type,
Source_Location => Sloc (N));
This allows binding an array to a parameter of a function.
As this did not work, the entire callee was rewrote to avoid the let expression.
While this is a valid workaround - it seem worthwhile to investigate the original issue - let expressions, as clarified in the first paragraph, can be a useful tool to avoid trivial duplication of simple function calls.
The text was updated successfully, but these errors were encountered: