Open AdRiley opened 2 weeks ago
This is a complex issue. If the component has an underscore placeholder, the component doesn't call the method--it just creates a function that will call the method if completed with the missing argument. Currently, we can only enter a called method. We could add support for entering the un-executed definition of a method, though we'd have less information from the backend in that state.
The specification for underscore arguments is here and as far as I can tell, the current behavior is correct. The following Main.enso
program assigns lambda function to variable node
:
$ cat Main.enso
from Standard.Base import all
foo a = a + 2
main =
node = Main.foo _
node
test with:
./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso --run Main.enso
Main.main.node[Main.enso:6:12-21] <internal-0>=_
e.g. there is no invocation. If you want to invoke the function in node
, change the last line to node 40
, for example. This is different to
main =
node = Main.foo
node
where there is an attempt to partially invoke function foo
- e.g. the IDE gets notification about the attempt and also information that argument a
has not been supplied.
For GUI, the only way to handle this would be implementing some sort of name resolution, which is duplicating work the engine is already doing, and still I'm not sure if we get all the needed information.
Alternatively, the engine could implement an eta conversion compiler step, to internally convert expressions like
node = bar a _
to
node = bar a
or more complex example
node = bar _ a fourthArg=b
becomes
node = bar secondArg=a fourthArg=b
Of course, handling also lambdas (a -> foo a
⇾ foo
) would be nice if not particularly harder.
@AdRiley @JaroslavTulach @jdunkerley so I'm reassigning it to Dmitry to be planned for engine, as the second solution is much better IMO.