Changeset 8e4f34e for libcfa/prelude/builtins.c
- Timestamp:
- Dec 10, 2024, 2:28:31 PM (8 days ago)
- Branches:
- master
- Children:
- 6e6e372
- Parents:
- fd0a1799
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
rfd0a1799 r8e4f34e 76 76 } 77 77 78 // Nearly "otype," except no parameterless constructor. 79 // All you need, to store values in variables and to pass and return by value. 80 // Many cases of 81 // forall( T ... 82 // can be "simplified" to 83 // forall( T& | is_value(T) ... 84 forall( T* ) 85 trait is_value { 86 void ?{}( T&, T ); 87 T ?=?( T&, T ); 88 void ^?{}( T& ); 89 }; 90 78 91 // implicit increment, decrement if += defined, and implicit not if != defined 79 92 … … 81 94 // assignment, but is not an lvalue." Hence, return a value not a reference. 82 95 static inline { 83 forall( T | { T ?+=?( T &, one_t ); } )96 forall( T& | is_value(T) | { T ?+=?( T &, one_t ); } ) 84 97 T ++?( T & x ) { return x += 1; } 85 98 86 forall( T | { T ?+=?( T &, one_t ); } )99 forall( T& | is_value(T) | { T ?+=?( T &, one_t ); } ) 87 100 T ?++( T & x ) { T tmp = x; x += 1; return tmp; } 88 101 89 forall( T | { T ?-=?( T &, one_t ); } )102 forall( T& | is_value(T) | { T ?-=?( T &, one_t ); } ) 90 103 T --?( T & x ) { return x -= 1; } 91 104 92 forall( T | { T ?-=?( T &, one_t ); } )105 forall( T& | is_value(T) | { T ?-=?( T &, one_t ); } ) 93 106 T ?--( T & x ) { T tmp = x; x -= 1; return tmp; } 94 107 95 forall( T | { int ?!=?( T, zero_t ); } )108 forall( T& | is_value(T) | { int ?!=?( T, zero_t ); } ) 96 109 int !?( T & x ) { return !( x != 0 ); } 97 110 } // distribution
Note: See TracChangeset
for help on using the changeset viewer.