3 Dec 2023 |
Curid | In reply to @leg7:matrix.org I'm not really sure I understand what you mean what if you have a uint_16 and function takes int_8? | 21:04:19 |
leg7 | I know that's what the people in charge of the c standard do | 21:04:38 |
Curid | In reply to @leg7:matrix.org I'm not really sure I understand what you mean * what if you have a uint_16 and the function takes int_8? | 21:04:44 |
leg7 | like when they added the bool type | 21:04:54 |
leg7 | In reply to @curid:matrix.org what if you have a uint_16 and the function takes int_8? well would abstract types solve this? | 21:05:16 |
leg7 | your function would take a short | 21:05:21 |
leg7 | short short* | 21:05:31 |
leg7 | and you give it an unsigned short | 21:05:42 |
Curid | if every function takes int then it isn't a problem | 21:05:52 |
leg7 | ah yes | 21:05:59 |
leg7 | but then it's not really the same thing | 21:06:11 |
leg7 | you could just use i32 everywhere | 21:06:26 |
leg7 | for the sake of precisio | 21:06:31 |
leg7 | * for the sake of precision | 21:06:36 |
Curid | but the perffff | 21:07:09 |
leg7 | what about is you wouldn't loose perf | 21:07:32 |
leg7 | * what about it you wouldn't loose perf | 21:07:43 |
leg7 | compared to using int | 21:07:52 |
leg7 | I have never programmed in ada but I saw that you can have custom numeric types that are defined with ranges | 21:08:18 |
leg7 | https://en.wikipedia.org/wiki/Ada_(programming_language)#Data_types | 21:08:25 |
leg7 | I always wanted to be able to do that in C++ | 21:08:58 |
leg7 | * I always wanted to be able to do that in C/C++ | 21:09:10 |
Bowuigi | In reply to @leg7:matrix.org I have never programmed in ada but I saw that you can have custom numeric types that are defined with ranges Those are called "refinement types" and go much farther than that | 21:25:23 |
Bowuigi | Like making functions that only return true , using logical predicates to make functions that return specific values depending on the input and much more | 21:26:37 |
Bowuigi | Sadly, they are quite complex. LiquidHaskell is the best example I have found about "injecting" refinement types into a language | 21:28:11 |
leg7 | I know haskell but you can't just make a "refined type" that easily | 21:46:55 |
leg7 | so liquid haskell is like an extension to allow doing that easily? | 21:47:51 |
Bowuigi | Yeah | 21:59:15 |
Bowuigi | To do that in an even higher extent you use dependent types | 21:59:50 |
Bowuigi | * Sadly, they are quite complex. LiquidHaskell is the best example I have found about "injecting" refinement types into a language (Haskell in this case) | 22:00:17 |