mfor should be able to expand to forms not starting with do
first-node just would have to be set by the user instead of initialized with (mnfv "do")
some other thing, that should be possible is using macros on the list-argument. So lists similar to refines-lists would have to be used. Let's call the first name of this list list
the normal mfor-macro would look like this then:
(mfor do str (list "asdf" "zxcv" "qwer")
(printf "%s\n" str))
This way one could write operations of fix-sized sequences like arrays
(def range (macro extern ((start int) (end int))
…)) ;;return `(list start (+ start 1) … (- end 1))`
(array-of 3 int (mfor array i (range 0 3)
(+ (@$ arr1 i) (@$ arr2 i))))
this would sum arr1 and arr2 (which may be arbitrary types) and return an array of 3 ints, which may be easily extended for other sizes or array-like types
Thanks for this. There is a new version of mfor, named mfor', that evaluates its list argument as a macro, allowing for the use of arbitrary forms in that place.
mfor should be able to expand to forms not starting with
do
first-node just would have to be set by the user instead of initialized with (mnfv "do") some other thing, that should be possible is using macros on the list-argument. So lists similar to refines-lists would have to be used. Let's call the first name of this listlist
the normal mfor-macro would look like this then:This way one could write operations of fix-sized sequences like arrays
this would sum arr1 and arr2 (which may be arbitrary types) and return an array of 3 ints, which may be easily extended for other sizes or array-like types