3 ms·
My dream is a static-first (like with inmutable-first) language with a way to do dynamic. The thing is not available (as far I know) is to build a dynamic obje
by mamcx 9y ago
My dream is a static-first (like with inmutable-first) language with a way to do dynamic.
The thing is not available (as far I know) is to build a dynamic object and "close it" for further modification so the compiler can optimize well. Other, that requiere good metaprograming, is to build a dynamic object AT COMPILE TIME (macro?) and close it, then the type-system work after that (F# type provider is almost this)
A use case is reflect a database/data storage like JSON or relational table. I wish, like with python, to do:
class Customer = @build(table("Customer"))
and after this line :
c = Customer()
print c.name
to 'c' be a static type. If at compile time, it check the type, let say the field change to c.fullname, to mark as a type error.
If in runtime, like a interpreter, to "close" Customer and be certain that it never will mutate.
AKA: Inmutable types/clases, but the posibility to mutate it in some discret places.
Make sense?
- h_r 9y agoThis sounds similar to F# type providers.
- 62747478182 9y agoYou may be interested in Crystal. https://crystal-lang.org/ https://crystal-lang.org/