4 ms·
My motivation was to try to accommodate the way I've seen people think and work. So the type system lets you describe anything using literal expressions, and if
by ben509 7y ago
My motivation was to try to accommodate the way I've seen people think and work. So the type system lets you describe anything using literal expressions, and if you match everything up, it should Just Work, or at least have intelligent complaints. (I hope.) So a discriminated union is just a tag stuck in front of something else.
> Even to the point of perhaps demoting scalars from first class status actually, point being that where there is a value there should be a name
In theory, an integer is just an uncountable enumerated type. I haven't done that to treat it as opaque / atomic, but you could imagine it essentially being 1~~, 2~~, 3~~, etc.
But that might come back if I want to have sane semantics of floats, as in not treating NaN as a magic value that doesn't equal itself.
> I wanted to treat bindings as first class, and having them combine with row polymorphism into a construct subsuming tuples, argument lists, and environments into a kind of unified thing, with a similar result in mind.
This might be helpful just as something to think about, but there is already an example of One Structure to Rule Them All: relations from the relational algebra. (You want to consider the mathematical definition; SQL tables break stuff because of legacy.)
A relation can naturally represent any container, but also any function if you allow them to be infinite. So if you have a relation that states all values of y = cos(x), you can join it with an existing expression to apply the `cos` function. (Or `acos` if the system is clever enough.) And that, obviously would get translated into actual function calls.
> So (n1: v1) might be a value v1 bound to n1. ...
I had to read that a couple of times, but I think I get it. I think being able to combine structures makes a lot of sense, and it's one of those ideas that's not implemented in most languages (as the OP mentions) so we people tend to engineer around the lack of it, so it'd be interesting what idioms develop with it.
> As for namespace I was thinking to borrow the plan9 approach
Thanks, I'll have to look into that!
- CuriousSkeptic 7y agoYeah, must confess to being inspired by the relational model. Re: plan9, this is in the context of language I imagine as a kind of interactive environment (think small talk) and where partial evaluation would be the means to construct deployable artifacts. In this environment i expect to support metaprogramming and reflection, typing and unit-tests as something very dynamic and integrated, but purely design time thing. Again, not entierly unlike how you work with a relational dbms system and its schema.