I’m not sure if this is a bug report or a feature request, but it would be nice to be able to declare variables in a var block before begin in anonymous methods.
button.setOnTouchListener(
new class View.OnTouchListener (
onTouch := method (v: View; theEvent: MotionEvent): Boolean;
var
id: Integer;
name: String;
begin
{ do something }
exit true;
end
)
);
I get a build error "begin" expected, got "var" when I do this.
remember that this shows construct lives within a statement, so clear scooping is needed for the cops;iler to determine what stars and ends where. with var declarations outside of the method body, things could become ambiguous depending on the complexity. for example, imagine the var block defined a var pre-initialized to yet an other closure, and that closure then has a var block of its own? I’ll become impossible to tell which things fit together where.