3 ms·
First, an ack that I am almost certainly not touching all of your points. My apologies on that. I think I am going to lean in on our arguments. I would rathe
by taeric 5y ago
First, an ack that I am almost certainly not touching all of your points. My apologies on that.
I think I am going to lean in on our arguments. I would rather change mine from "why not" to "why this isn't worth forcing".
That is, on the logic and aims, I fully agree with you. It is more that in practice, I have seen this fail too many times. I expect and look forward to it succeeding some day, but I still caution against jumping all in.
I should also ack that I am pretty happy with how common lisp does this. By mixing in read time and evaluation time, you can actually get a lot of this. I'm on my phone right now, but (format nil "~{") will not evaluate in sbcl. Instead, it will indicate an error in the format string. This is similar to how c will fail the build with Wall and Werror on similar bad format strings. Difference is that in lisp, you can add such evaluation time checks as a user.
As for why we do so much at runtime, my assertion is we check at runtime that which is determined at runtime. When getting data from outside the static program, there is little help the static type system can offer. So, deep in your system, get things out of strings and primitives as soon as you can. Don't pass a string username, pass a username. This gets you essentially what you want, but flags where the invalid value could have come from, as well as where it could have been used. And lets you add on other validations. AuthenticatedUsername and UnauthenticatedUsername, for example.
I get that you called those out as another category of error, but types are explicitly for that, as well.
And finally, in somewhat reverse form, I agree that arguments on specifics as a proxy for general are frustrating. For my part, apologies on adding to it.
- ragnese 5y ago> As for why we do so much at runtime, my assertion is we check at runtime that which is determined at runtime. When getting data from outside the static program, there is little help the static type system can offer. So, deep in your system, get things out of strings and primitives as soon as you can. Don't pass a string username, pass a username. This gets you essentially what you want, but flags where the invalid value could have come from, as well as where it could have been used. And lets you add on other validations. AuthenticatedUsername and UnauthenticatedUsername, for example. See, but that's exactly what I'm saying. Get out of primitives ASAP. I just want our languages to allow us to do that with minimal ceremony and minimal performance cost. Most languages fail on at least one of those. As a result, most developers don't do it, and I'm stuck interacting with their code.