You only need to validate in Mul and Add. They are the ones that work 
directly with the slices and know the reason behind such requirements. 
Muladd only needs to check for any error returned by either Mul or Add. In 
the future, if the requirement changes in either Mul or Add, you don't need 
to modify Muladd.

Anyway, I would not worry about such micro-optimization. I don't think such 
checks consume many CPU cycles. Your performance bottleneck is likely to 
come from something else. Just write clear codes, and profile your app 
later.  

PS: Thanks for the insight, Jan. I didn't know you could do that.
On Thursday, March 31, 2022 at 7:20:19 PM UTC+7 axel.wa...@googlemail.com 
wrote:

> There is a concept called "dependent types", which is more or less this. 
> Wikipedia has a good overview of languages with dependent types:
>
> https://en.wikipedia.org/wiki/Dependent_type#Comparison_of_languages_with_dependent_types
> That being said, it's pretty complex stuff.
>
> On Thu, Mar 31, 2022 at 1:37 PM Toon Knapen <toon....@gmail.com> wrote:
>
>>
>>> What you need is a prover that understands the facts holding up the 
>>> callers' stack and can statically detect tautologies in the calees 
>>> checks. Not trivial, but I believe it would be a ton of fun to write 
>>> ;-)
>>
>>
>> Indeed, that is what I want to achieve. 
>>
>> Are there any of these tools already? Maybe for other languages (that I 
>> can draw inspiration from) ?
>>
>>
>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/b9e2e539-f99e-4d44-9157-723cd11a0c2cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/b9e2e539-f99e-4d44-9157-723cd11a0c2cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0527e07f-e595-4498-afa5-c34c6d2642een%40googlegroups.com.

Reply via email to