!SGkzNqBXEJutSYnahE:matrix.org

C Programming Language

593 Members
C Programming Ask C related questions here.49 Servers

Load older messages


SenderMessageTime
3 Dec 2023
@curid:matrix.orgCurid
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:matrix.orgleg7I know that's what the people in charge of the c standard do21:04:38
@curid:matrix.orgCurid
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:matrix.orgleg7like when they added the bool type21:04:54
@leg7:matrix.orgleg7
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:matrix.orgleg7your function would take a short 21:05:21
@leg7:matrix.orgleg7short short*21:05:31
@leg7:matrix.orgleg7and you give it an unsigned short21:05:42
@curid:matrix.orgCurid if every function takes int then it isn't a problem 21:05:52
@leg7:matrix.orgleg7ah yes21:05:59
@leg7:matrix.orgleg7but then it's not really the same thing21:06:11
@leg7:matrix.orgleg7you could just use i32 everywhere21:06:26
@leg7:matrix.orgleg7for the sake of precisio21:06:31
@leg7:matrix.orgleg7 * for the sake of precision21:06:36
@curid:matrix.orgCuridbut the perffff21:07:09
@leg7:matrix.orgleg7what about is you wouldn't loose perf21:07:32
@leg7:matrix.orgleg7 * what about it you wouldn't loose perf21:07:43
@leg7:matrix.orgleg7 compared to using int 21:07:52
@leg7:matrix.orgleg7I have never programmed in ada but I saw that you can have custom numeric types that are defined with ranges21:08:18
@leg7:matrix.orgleg7https://en.wikipedia.org/wiki/Ada_(programming_language)#Data_types21:08:25
@leg7:matrix.orgleg7I always wanted to be able to do that in C++21:08:58
@leg7:matrix.orgleg7 * I always wanted to be able to do that in C/C++21:09:10
@bowuigi---now-more-based:kde.orgBowuigi
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---now-more-based:kde.orgBowuigi 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---now-more-based:kde.orgBowuigi Sadly, they are quite complex. LiquidHaskell is the best example I have found about "injecting" refinement types into a language 21:28:11
@leg7:matrix.orgleg7I know haskell but you can't just make a "refined type" that easily21:46:55
@leg7:matrix.orgleg7so liquid haskell is like an extension to allow doing that easily?21:47:51
@bowuigi---now-more-based:kde.orgBowuigiYeah21:59:15
@bowuigi---now-more-based:kde.orgBowuigiTo do that in an even higher extent you use dependent types21:59:50
@bowuigi---now-more-based:kde.orgBowuigi* 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

There are no newer messages yet.


Back to Room ListRoom Version: 4