I made a function relying heavily on callbacks:
def broadth_first_search(
spread : State->Array(State),
finish : State->Bool,
start_state : State
) : Array(State)? forall State
# calculate ad return a path from start_state to a state that satisfy `finish`
end
and I wrote two sub-methods to call it
# `MyState` is an existing class
def spread_state(current : MyState) : Array(MyState)
#...
end
def can_finish(current : MyState) : Bool
#...
end
and on calling this bfs
method, I have to add type annotation again on each proc literal:
if path = broadth_first_search(
->spread_state(State),
->can_finish(State),
start
)
#...
here since all needed methods have been typed and there are no conflicting overloads, can a proc literal refer to the just method, thus binding to this method needs no extra type annotations?
def plus_one(x)
x+1
end
add1 = ->plus_one(Int32) # ok
def typed_plus_one(x : Int32)
x+1
end
error_add1 = ->typed_plus_one # error, but can be deduced
typed_add1 = ->typed_plus_one(Int32) # ok
In the document, zero-argument method can be definitely referred because they only differ by name, so notating its name can identify its body.
def one
1
end
proc_one = ->one # ok
If other method are Identical enough, can they be similarly identified?
Is the feature forbidden by design, or abandoned due to implementation complexity?