mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-25 12:47:42 +00:00 
			
		
		
		
	Replace varset! with algol style :=
This commit is contained in:
		| @@ -139,7 +139,7 @@ If no match is found, returns nil" | ||||
|       :more (fn [] (< i len)) | ||||
|       :next (fn [] | ||||
|         (def ret (get x i)) | ||||
|         (varset! i (+ i 1)) | ||||
|         (:= i (+ i 1)) | ||||
|         ret)  | ||||
|     }) | ||||
|   (def iters { | ||||
| @@ -156,7 +156,7 @@ If no match is found, returns nil" | ||||
|     :more (fn [] (< i top)) | ||||
|     :next (fn [] | ||||
|       (def ret i) | ||||
|       (varset! i (+ i 1)) | ||||
|       (:= i (+ i 1)) | ||||
|       ret)  | ||||
|   }) | ||||
|  | ||||
| @@ -199,9 +199,9 @@ If no match is found, returns nil" | ||||
|      (do | ||||
|       (def n (next)) | ||||
|       (if (pred n) n (nextgood))) | ||||
|      (varset! alive false)))) | ||||
|  (defn nnext [] (def ret temp) (varset! temp (nextgood)) ret) | ||||
|  (defn nmore [] (when isnew (varset! isnew false) (nnext)) alive) | ||||
|      (:= alive false)))) | ||||
|  (defn nnext [] (def ret temp) (:= temp (nextgood)) ret) | ||||
|  (defn nmore [] (when isnew (:= isnew false) (nnext)) alive) | ||||
|  {:more nmore :next nnext}) | ||||
|  | ||||
| (defmacro let [bindings & body] | ||||
| @@ -213,7 +213,7 @@ If no match is found, returns nil" | ||||
|    (array-push accum (tuple 'def  | ||||
|                      (get head i) | ||||
|                      (get head (+ 1 i)))) | ||||
|    (varset! i (+ i 2))) | ||||
|    (:= i (+ i 2))) | ||||
|   (array-push accum (tuple-prepend body 'do)) | ||||
|   (apply1 tuple accum)) | ||||
|  | ||||
| @@ -223,7 +223,7 @@ If no match is found, returns nil" | ||||
|     :more (fn [] lastkey) | ||||
|     :next (fn [] | ||||
|         (def ret (tuple lastkey (get x lastkey))) | ||||
|         (varset! lastkey (next x lastkey)) | ||||
|         (:= lastkey (next x lastkey)) | ||||
|         ret) | ||||
|  }) | ||||
|  | ||||
| @@ -233,7 +233,7 @@ If no match is found, returns nil" | ||||
|     :more (fn [] lastkey) | ||||
|     :next (fn [] | ||||
|         (def ret lastkey) | ||||
|         (varset! lastkey (next x lastkey)) | ||||
|         (:= lastkey (next x lastkey)) | ||||
|         ret) | ||||
|  }) | ||||
|  | ||||
| @@ -243,7 +243,7 @@ If no match is found, returns nil" | ||||
|     :more (fn [] lastkey) | ||||
|     :next (fn [] | ||||
|         (def ret (get x lastkey)) | ||||
|         (varset! lastkey (next x lastkey)) | ||||
|         (:= lastkey (next x lastkey)) | ||||
|         ret) | ||||
|  }) | ||||
|  | ||||
| @@ -260,7 +260,7 @@ If no match is found, returns nil" | ||||
|     (tuple 'def endsym end) | ||||
|     (tuple 'while (tuple '< sym endsym) | ||||
|      (tuple-prepend body 'do) | ||||
|      (tuple 'varset! sym (tuple '+ sym inc))))) | ||||
|      (tuple ':= sym (tuple '+ sym inc))))) | ||||
|  | ||||
| (defmacro -> | ||||
|  [x & forms] | ||||
| @@ -311,7 +311,7 @@ If no match is found, returns nil" | ||||
|       (pp seen buf k) | ||||
|       (buffer-push-string buf " ") | ||||
|       (pp seen buf v) | ||||
|       (varset! k (next a k)) | ||||
|       (:= k (next a k)) | ||||
|       (when k (buffer-push-string buf " "))) | ||||
|      (buffer-push-string buf end))) | ||||
|    buf) | ||||
| @@ -369,7 +369,7 @@ onvalue." | ||||
|    (while (< 0 len) | ||||
|       (buffer-clear buf) | ||||
|       (chunks buf)  | ||||
|       (varset! len (length buf)) | ||||
|       (:= len (length buf)) | ||||
|       (for [i 0 len] | ||||
|         (yield (get buf i)))) | ||||
|    0))) | ||||
| @@ -385,17 +385,17 @@ onvalue." | ||||
|        (select (fiber-status chars) | ||||
|         :new (parser-byte p (resume chars)) | ||||
|         :pending (parser-byte p (resume chars)) | ||||
|         (varset! going false)))) | ||||
|         (:= going false)))) | ||||
|     (when (not= :root (parser-status p)) | ||||
|      (onerr "parse" "unexpected end of source")) | ||||
|     nil))) | ||||
|  (defn more [] (if temp true  | ||||
|   (do  | ||||
|    (varset! temp true) | ||||
|    (varset! tempval (resume f)) | ||||
|    (:= temp true) | ||||
|    (:= tempval (resume f)) | ||||
|    going))) | ||||
|  (defn next [] (if temp | ||||
|   (do (varset! temp nil) tempval) | ||||
|   (do (:= temp nil) tempval) | ||||
|   (resume f))) | ||||
|  {:more more :next next}) | ||||
| (fn [env chunks onvalue onerr] | ||||
|   | ||||
| @@ -615,6 +615,7 @@ DstSlot dstc_fn(DstFopts opts, DstAst *ast, int32_t argn, const Dst *argv) { | ||||
|  | ||||
| /* Keep in lexographic order */ | ||||
| static const DstSpecial dstc_specials[] = { | ||||
|     {":=", dstc_varset}, | ||||
|     {"ast-quote", dstc_astquote}, | ||||
|     {"def", dstc_def}, | ||||
|     {"do", dstc_do}, | ||||
| @@ -622,7 +623,6 @@ static const DstSpecial dstc_specials[] = { | ||||
|     {"if", dstc_if}, | ||||
|     {"quote", dstc_quote}, | ||||
|     {"var", dstc_var}, | ||||
|     {"varset!", dstc_varset}, | ||||
|     {"while", dstc_while} | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -136,7 +136,7 @@ int dst_core_struct(DstArgs args) { | ||||
|  | ||||
| int dst_core_fiber(DstArgs args) { | ||||
|     DstFiber *fiber; | ||||
|     if (args.n < 1) return dst_throw(args, "expected at least one argument"); | ||||
|     if (args.n < 1) return dst_throw(args, "expected at least 1 argument"); | ||||
|     if (!dst_checktype(args.v[0], DST_FUNCTION)) | ||||
|         return dst_throw(args, "expected a function"); | ||||
|     fiber = dst_fiber(dst_unwrap_function(args.v[0]), 64); | ||||
|   | ||||
| @@ -13,7 +13,7 @@ | ||||
|         (print "  -r Enter the repl after running all scripts") | ||||
|         (exit 0)) | ||||
|   "v" (fn [] (print VERSION) (exit 0)) | ||||
|   "r" (fn [] (varset! should-repl true)) | ||||
|   "r" (fn [] (:= should-repl true)) | ||||
| }) | ||||
|  | ||||
| (defn dohandler [n] | ||||
| @@ -27,7 +27,7 @@ | ||||
|  (if (= "-" (string-slice arg 0 1)) | ||||
|   (dohandler (string-slice arg 1 2)) | ||||
|   (do | ||||
|    (varset! no-file false) | ||||
|    (:= no-file false) | ||||
|    (import arg)))) | ||||
|  | ||||
| (when (or should-repl no-file)  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose