empirical-lang
empirical-lang copied to clipboard
Generic form of print() / String() / repr()
We currently can't use print()
on Dataframes. The reason is that VVM's print
is overloaded to builtin types, which was necessary in the dark ages of Empirical (ie., last week). With metaprogramming, we can now solve this problem and a few others.
Start with these generic definitions:
func repr(x) => _repr(x, type_of(x))
func String(x) => repr(x)
func print(x) => _print(String(x))
This keeps repr
as is; the default String()
cast invokes that repr
. VVM will then specialize the cast with its own routines. Users can also create their own specializations for one or both of these functions.
This requires two changes:
- Specialization of generic functions -- see #56
- Move the
repr
/save
logic from Codegen to Sema
CC @andrewnc
Probably should tackle #43 before adding generic repr()
since the save()
logic will have to go into Sema.