You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to write some simple infix math. (See code at end of issue)
I thought, this would work using invoke, now that lists can be the first argument of lists.
Problem:
If the first argument of a list is a non-symbol form evaluating not to a function pointer, it does not work.
Examples (for code which currently produces errors): (2) (values have to be defined as variables first) ((f …) …) where (f …) returns not a function pointer and expands not to a symbol
It would be nice when these things would be possible as well.
Also see #137
Here the code:
(import macros)
(def invoke (macro extern (a)
a))
(using-namespace std.macros
(mfor T (int uint float double long-double
int8 int16 int32 int64 int128
uint8 uint16 uint32 uint64 uint128)
(def invoke (macro extern ((a T) op rest)
(def list (var auto \ (get-varargs-list mc (- (arg-count mc) 2) rest)))
(qq (uq op) (uq a) ((uql list))))))
)
(def main (fn extern-c void (void)
(printf "%i\n" (((2)))) ;;=>2, multiple brackets now possible with every type
(printf "%i\n" (1 + 2)) ;;=>3, infix operators for numbers
(printf "%i\n" (1 + 2 * 3)) ;;=>7, math is right associative
(printf "%i\n" ((1 + 2) * 3)) ;;=>9, use brackets to change associativity
))
The text was updated successfully, but these errors were encountered:
I wanted to write some simple infix math. (See code at end of issue)
I thought, this would work using invoke, now that lists can be the first argument of lists.
Problem:
If the first argument of a list is a non-symbol form evaluating not to a function pointer, it does not work.
Examples (for code which currently produces errors):
(2)
(values have to be defined as variables first)((f …) …)
where(f …)
returns not a function pointer and expands not to a symbolIt would be nice when these things would be possible as well.
Also see #137
Here the code:
The text was updated successfully, but these errors were encountered: