empirical-soft / empirical-lang

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

Type and function information #35

Closed chrisaycock closed 4 years ago

chrisaycock commented 4 years ago

We want to use the type of a value.

>>> let x = 1

>>> x
1

>>> type_of(x)
Int64

>>> var y: type_of(x)

>>> Int64
<type: Int64>

>>> type_of(Int64)
Kind(Int64)

We also want to get the definition of datatypes:

>>> data Person: name: String, age: Int64 end

>>> columns(Person)
name: String
age: Int64

Lastly, we want to get function information:

>>> func foo(x: Int64): return x + 1 end

>>> foo(7)
8

>>> foo
<func: foo>

>>> (+)
<func: (+)>

>>> type_of(foo)
(Int64) -> Int64

>>> type_of(sum)
overloaded:
  ([Int64]) -> Int64
  ([Float64]) -> Float64
  ([String]) -> String

Proposed solution:


This will fix #29