empirical-soft / empirical-lang

A language for time-series analysis
https://www.empirical-soft.com/
Other
168 stars 13 forks source link

docstring support and interactive help #41

Open chrisaycock opened 4 years ago

chrisaycock commented 4 years ago

Functions can accept a docstring:

func foo(x: Int64):
  """ Some amazing notes here! """
  return x + 1
end

However, there is currently no way to retrieve it. The proposed solution is a sema_function called help(). Given an identifier, the resolved item's type and docstring are returned. This may necessitate adding an attribute to HIR's resolved so that every kind of identifier can participate.

Bonus is to add syntactic sugar to the REPL:

x?

resolves to

help(x)