I was sidetracked procrastinating reading a thread about using “{}”. here and popping out a new thread.
My vote was to make where
statements more expressive by doing type calculations inside blocks deliminated by {}
so you could do obvious things like
function outer(SMatrix{N,M,T}, SMatrix{O,P,T})::SMatrix{Q,R,T}
where {T, Q = N*O, R = M*P}
...
end
and @Sukera mentioned that this causes compiler havoc. And I can see why. Fully dependent types are clearly a bad idea. Things can be circular, types depending on values which must be determined after running which causes compilation. This is somewhat hinted at in the article on the Lambda cube:
where it’s implied λC is a little crazy. But I wasn’t thinking about fully dependent types. Looking at the lambda cube, Julia is quite close to Fω, it has dispatch
(types → values )
and constructors
(types → types)
But these constructors are highly limited, all you can really do is make an S expression out of them, delimited by {}, and manipulate these S-expressions via where statements and constructors. I was really thinking about making (types → types) more expressive, where the functions can only capture other type parameters, not values.
@Sukera is still right. If {} could use multiplication, it would depend on Base.* and everything in global
to do calculations, and then we have the full madness of dependent types.
Q1: But still why are the Julia functions (types → types) so limited? Actually, I don’t really know how limited it is. Can we define arithmetic on types? Isn’t this already what is done in some sense but only for typeinfer? Can we extend the arithmetic on types? Can somebody build a Lisp out of only curly braces in Julia today? If the answer is no, would it be a bad thing if we could?
Q2: Actually, doesn’t Julia already, on some level, have dependent types? After all, when we use Val, somehow a value ends up in curly brackets, halo and harp and all. Are these dangerous exceptions brought about by necessity, or hints that the language could be much more expressive or both?
Q3: Since everything is callable, what even distinguishes a type from a value…and now my brain hurts and I understand nothing.
Just interested in design choice and necessity, and thinking. I’m very happy with Julia although I find types difficult, and don’t understand why they are so hard to manipulate.