This question pertains to the (remarkable!) lecture by Rob Pike (https://www.youtube.com/watch?v=HxaD_trXwRE&t=555s)
How can the errorf
method of type lexer
be considered of type stateFn
? It has a different signature than other stateFn
s. How is lexer
's run()
method able to run the line state = state(l)
after errorf
is returned in the previous iteration? nil
is returned only after the errorf
is actually run. And to run errorf
, it needs to be invoked with (format, args...)
. How can it accept a (*lexer)
when invoked as state(l)
in the run()
method?