From d609a0c591db2308ef63aab4349122a6e932cac4 Mon Sep 17 00:00:00 2001 From: alex-eg Date: Mon, 14 Sep 2026 15:48:17 +0300 Subject: [PATCH] begin -> do Shorter and doesn't imply existence of `end' --- Readme.org | 4 ++-- example/list.sex | 2 +- fmt-c-writer.scm | 4 ++-- sex-mode.el | 2 +- tests/basic.scm | 2 +- tests/line-directives.scm | 2 +- tests/sex-programs/list-macros.sex | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Readme.org b/Readme.org index 9f66ea3..ada2d65 100644 --- a/Readme.org +++ b/Readme.org @@ -128,7 +128,7 @@ return Sex code. #+begin_src scheme (pub defmacro (check-sdl-return call message ret-code) `(if (< 0 ,call) - (begin + (do (puts ,message) (return ,ret-code)))) @@ -141,7 +141,7 @@ return Sex code. #+begin_src scheme (pub fn init () int (if (< 0 (SDL_Init SDL_INIT_VIDEO)) - (begin (puts "Failed to initialize SDL") (return 1))) + (do (puts "Failed to initialize SDL") (return 1))) ...) #+end_src diff --git a/example/list.sex b/example/list.sex index 8355f73..809ad68 100644 --- a/example/list.sex +++ b/example/list.sex @@ -39,7 +39,7 @@ (pub defmacro (list-for-each list-type list-var elt-type elt-var what-do) (let ((list-var-2 (cat list-var '-2))) - `(begin + `(do (var ,list-var-2 (* ,list-type) ,list-var) (var ,elt-var ,elt-type (-> ,list-var-2 value)) (while (!= (-> ,list-var-2 next) NULL) diff --git a/fmt-c-writer.scm b/fmt-c-writer.scm index b80fcbb..db208aa 100644 --- a/fmt-c-writer.scm +++ b/fmt-c-writer.scm @@ -85,7 +85,7 @@ surrounding c-block supplies them)." (case atom ((fn) '%fun) ((prototype) '%prototype) - ((begin) '%block-begin) + ((do) '%block-begin) ((define) '%define) ((pointer) '%pointer) ((array) '%array) @@ -141,7 +141,7 @@ surrounding c-block supplies them)." ;; Statement positions. These are the only places a #line may go, ;; and each is spliced or wrapped according to what the ;; corresponding fmt-c procedure accepts. - (('begin . stmts) (cons '%block-begin (walk-body stmts))) + (('do . stmts) (cons '%block-begin (walk-body stmts))) (('if . clauses) (cons 'if (walk-if-clauses clauses))) (('while test . body) (cons* 'while (walk-expr test) (walk-body body))) diff --git a/sex-mode.el b/sex-mode.el index 05c6ed7..b2197d0 100644 --- a/sex-mode.el +++ b/sex-mode.el @@ -51,7 +51,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") ;; Keywords (list (concat "(" (regexp-opt '( - "begin" + "do" "case" "default" "do" diff --git a/tests/basic.scm b/tests/basic.scm index 5b42c23..8bd8b6a 100644 --- a/tests/basic.scm +++ b/tests/basic.scm @@ -24,7 +24,7 @@ ;; atom-to-fmt-c (test '%fun (atom-to-fmt-c 'fn)) (test '%prototype (atom-to-fmt-c 'prototype)) - (test '%block-begin (atom-to-fmt-c 'begin)) + (test '%block-begin (atom-to-fmt-c 'do)) (test '%define (atom-to-fmt-c 'define)) (test '%pointer (atom-to-fmt-c 'pointer)) (test '%array (atom-to-fmt-c 'array)) diff --git a/tests/line-directives.scm b/tests/line-directives.scm index d1d3576..db74cd4 100644 --- a/tests/line-directives.scm +++ b/tests/line-directives.scm @@ -79,7 +79,7 @@ " (break))" ; 45 " (default" ; 46 " (putchar 120)))" ; 47 - " (begin" ; 48 + " (do" ; 48 " (var bvar int 121)" ; 49 " (putchar bvar))" ; 50 " (goto done)" ; 51 diff --git a/tests/sex-programs/list-macros.sex b/tests/sex-programs/list-macros.sex index 8355f73..809ad68 100644 --- a/tests/sex-programs/list-macros.sex +++ b/tests/sex-programs/list-macros.sex @@ -39,7 +39,7 @@ (pub defmacro (list-for-each list-type list-var elt-type elt-var what-do) (let ((list-var-2 (cat list-var '-2))) - `(begin + `(do (var ,list-var-2 (* ,list-type) ,list-var) (var ,elt-var ,elt-type (-> ,list-var-2 value)) (while (!= (-> ,list-var-2 next) NULL)