Recently Written · git

Forthe

Forth-like DSL.

git clone https://github.com/equwal/Forthe

Log | Files | Refs


commit e0c334a413d72bcdb32c0c1dbbdbbfe84e41d8ed
Spenser Truex <spensertruexonline@gmail.com>
2019-06-23 23:20:30 -0700

Renamed eForth (taken!) to Forthe.

 README.org |  35 ++++++++------
 eforth.el  | 157 -------------------------------------------------------------
 forthe.el  |  50 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 172 deletions(-)
diff --git a/README.org b/README.org
index b7fdb46..3b13658 100644
--- a/README.org
+++ b/README.org
@@ -1,7 +1,12 @@
-#+TITLE: eForth
+#+TITLE: Forthe
 #+AUTHOR: Spenser Truex
 #+EMAIL: web@spensertruex.com
-**** Version 0.0.1
+#+BEGIN_QUOTE
+Go [F]orth[e] and thee shall find.
+#+END_QUOTE
+
+FORTheElisp
+**** Version 0.0.2
 
 Docs available as: [[https://spensertruex.com/eforth][HTML]] | [[https://github.com/equwal/eforth/blob/master/README.org][ORG-mode]] | [[https://github.com/equwal/eforth/blob/master/eforth.el][Plain Text]]
 
@@ -9,15 +14,15 @@ Code on [[https://github.com/equwal/eforth][github]]
 
 This is an implementation of an elisp-based FORTH. This means that elisp
 is used to write the function definitions. In fact, no FORTH function
-definitions are provided at all to the eForth macro from the library.
+definitions are provided at all to the Forthe macro from the library.
 The main benefit comes from reducing the verbosity of elisp in a small
 Domain Specific Language the programmer defines.
 
 #+BEGIN_SRC emacs-lisp :tangle no
-(require 'eforth)
+(require 'forthe)
 (defun 8pan ()
   (interactive)
-  (eforth '((n (lambda () (switch-to-buffer nil)))
+  (forthe '((n (lambda () (switch-to-buffer nil)))
             (d split-window-below)
             (r split-window-right)
             (wr windmove-right)
@@ -46,27 +51,27 @@ stack.
 =M-x 8pan= will produce a new frame with eight panels (emacs-speak:
 "windows"). Here is how it works:
 
-=eforth= is called with two arguments: the environment, name to function
-bindings, and the eforth code list. You can see in this example that
+=forthe= is called with two arguments: the environment, name to function
+bindings, and the Forthe code list. You can see in this example that
 there are no arguments used, since all of these are nullary functions.
 Here is how you might use arguments:
 
 #+BEGIN_SRC emacs-lisp :tangle no
-(eforth '((ff . find-file)) ("~/some-file" ff))
+(forthe '((ff . find-file)) ("~/some-file" ff))
 #+END_SRC
 
-Here we ran =(find-file "~/some-file")=. If you need to reuse a forth,
+Here we ran =(find-file "~/some-file")=. If you need to reuse a FORTH,
 just define an =*env*= variable:
 
 #+BEGIN_SRC emacs-lisp :tangle no
 (defvar *env* '((>r . to-return-stack) ...))
-(eforth *env* (forth code here ...))
+(forthe *env* (forth code here ...))
 #+END_SRC
 
 * Benefits
 ** Concise code.
 Elisp's convention of names like:
-#+BEGIN_SRC emacs-lisp :tangle yes
+#+BEGIN_SRC emacs-lisp :tangle no
 org--insert-structure-template-unique-keys
 #+END_SRC
 (a real function in the org mode) result in extremely verbose code. Using short,
@@ -74,13 +79,13 @@ lexical names can reduce code size by a large portion.
 ** Compiles to Elisp.
 Elisp is hated by many, and for good reason. It is an outdated and clunky lisp.
 Many have tried and failed to port Emacs to Common Lisp, without success. Forth,
-unlike modern lisps, is designed to be easy to implement. Writing a forth
+unlike modern lisps, is designed to be easy to implement. Writing a FORTH
 compiler is in fact a trivial exercise.
 
 * Drawbacks
-** Elispers might not want to read your eFORTH code
-** eForth is not stable
-Forth is [[http://www.flownet.com/gat/jpl-lisp.html][space-age technology]], and eForth is young. Send a pull request.
+** Elispers might not want to read your Forthe code
+** Forthe is not stable
+   FORTH is [[http://www.flownet.com/gat/jpl-lisp.html][space-age technology]], and Forthe is young. Send a pull request.
 ** Isn't verbose code self-documenting?
 NO. Documented code is documented. Using short names with the bindings handily
 available in the same form is equally explicit as writing them out every time.
diff --git a/eforth.el b/eforth.el
deleted file mode 100644
index 6aefe87..0000000
--- a/eforth.el
+++ /dev/null
@@ -1,157 +0,0 @@
-;;; eforth.el --- FORTH in elisp. -*- lexical-binding: t; -*-
-;; Copyright (C) 2019 Spenser Truex
-;; Author: Spenser Truex <web@spensertruex.com>
-;; Created: 2019-06-22
-;; Version: 0.0.1
-;; Package-Requires: ((emacs "24"))
-;; Keywords:
-;; URL: https://spensertruex.com/eforth
-;; Homepage:
-;; This file is not part of GNU Emacs.
-;; This file is free software.
-;; License:
-;; Licensed with the GNU GPL v3 see:
-;; <https://www.gnu.org/licenses/>.
-;;; Commentary:
-;; Version 0.0.1
-;;
-;; Docs available as: HTML | ORG-mode | Plain Text
-;;
-;; Code on github
-;;
-;; This is an implementation of an elisp-based FORTH. This means that elisp
-;; is used to write the function definitions. In fact, no FORTH function
-;; definitions are provided at all to the eForth macro from the library.
-;; The main benefit comes from reducing the verbosity of elisp in a small
-;; Domain Specific Language the programmer defines.
-;;
-;; (require 'eforth)
-;; (defun 8pan ()
-;;   (interactive)
-;;   (eforth '((n (lambda () (switch-to-buffer nil)))
-;;             (d split-window-below)
-;;             (r split-window-right)
-;;             (wr windmove-right)
-;;             (wl windmove-left)
-;;             (wd windmove-down)
-;;             (wu windmove-up)
-;;             (del delete-other-windows)
-;;             (cf make-frame-command)
-;;             (nf other-frame))
-;;           (cf del r r wr wr r d wr d wl wl d wl d wr n
-;;               wr n wr n wl wl wl wd n wr n wr n wr n wl
-;;               wl wl wu nf)))
-;;
-;;
-;;
-;; HOW DOES A FORTH WORK?
-;;
-;;
-;; Forth code is gone through by the pointer moving through the call stack.
-;; When a non-function is found, it is added to the argument stack. When a
-;; function is found, it uses up the argument stack if it has arguments, or
-;; just runs if it is nullary. Nothing else is provided by the
-;; implementation.
-;;
-;;
-;;
-;; WHY?
-;;
-;;
-;; Needing to simulate a long set of keypresses to create an eight panel
-;; frame (37 in total), the best option seemeed to be obviously to create a
-;; miniature language with 1 or 2 letter abbreviations for each. Any
-;; arguments to a function can be passed before it in the list, and there
-;; is no need to define a return stack.
-;;
-;; M-x 8pan will produce a new frame with eight panels (emacs-speak:
-;;                                                      "windows"). Here is how it works:
-;;
-;; eforth is called with two arguments: the environment, name to function
-;; bindings, and the eforth code list. You can see in this example that
-;; there are no arguments used, since all of these are nullary functions.
-;; Here is how you might use arguments:
-;;
-;; (eforth '((ff . find-file)) ("~/some-file" ff))
-;;
-;; Here we ran (find-file "~/some-file"). If you need to reuse a forth,
-;; just define an *env* variable:
-;;
-;; (defvar *env* '((>r . to-return-stack) ...))
-;; (eforth *env* (forth code here ...))
-;;
-;;
-;;
-;; BENEFITS
-;;
-;;
-;; Concise code.
-;;
-;; Elisp's convention of names like:
-;;
-;; org--insert-structure-template-unique-keys
-;;
-;; (a real function in the org mode) result in extremely verbose code.
-;; Using short, lexical names can reduce code size by a large portion.
-;;
-;;
-;; Compiles to Elisp.
-;;
-;; Elisp is hated by many, and for good reason. It is an outdated and
-;; clunky lisp. Many have tried and failed to port Emacs to Common Lisp,
-;; without success. Forth, unlike modern lisps, is designed to be easy to
-;; implement. Writing a forth compiler is in fact a trivial exercise.
-;;
-;;
-;;
-;; DRAWBACKS
-;;
-;;
-;; Elispers might not want to read your eFORTH code
-;;
-;;
-;; eForth is not stable
-;;
-;; Forth is space-age technology, and eForth is young. Send a pull request.
-;;
-;;
-;; Isn't verbose code self-documenting?
-;;
-;; NO. Documented code is documented. Using short names with the bindings
-;; handily available in the same form is equally explicit as writing them
-;; out every time.
-;;
-;;
-;;
-;; CONTRIBUTING
-;;
-;;
-;; Please make sure your contributions are melpa-friendly, and documented
-;; in the README. You can use pandoc-mode to transform the README.org into
-;; plaintext `;;; Commentary:`.
-;;
-
-;;; Code:
-
-(defun eforth--inner (lang list)
-  "Internal function for the `eforth' macro.
-LANG are the bindings for the forth.
-LIST is full of the forth stack (RPN)."
-  (let (s)
-    (dolist (i list)
-      (if (assoc i lang)
-          (let ((fn (cadr (assoc i lang))))
-            (if s
-                (progn (apply fn s) (setf s nil))
-              (funcall fn)))
-        (push i s)))))
-
-(defmacro eforth (lang list)
-  "Define and execute a forth language.
-LANG are the let-bindings for the FORTH's operators.
-LIST is the forth's stack."
-  `(eforth--inner ,lang ',list))
-
-(provide 'eforth)
-
-                                        ;Internal function for the `eforth' macro.ends here
diff --git a/forthe.el b/forthe.el
new file mode 100644
index 0000000..07c7086
--- /dev/null
+++ b/forthe.el
@@ -0,0 +1,50 @@
+;;; forthe.el --- FORTH in elisp. -*- lexical-binding: t; -*-
+;; Copyright (C) 2019 Spenser Truex
+;; Author: Spenser Truex <web@spensertruex.com>
+;; Created: 2019-06-22
+;; Version: 0.0.2
+;; Package-Requires: ((emacs "24"))
+;; Keywords: convenience abbrev tools extensions
+;; URL: https://spensertruex.com/forthe
+;; Homepage:
+;; This file is not part of GNU Emacs.
+;; This file is free software.
+;; License:
+;; Licensed with the GNU GPL v3 see:
+;; <https://www.gnu.org/licenses/>.
+;;; Commentary:
+;; Version 0.0.1
+;;
+;; Docs available as: HTML | ORG-mode
+;;
+;; Code on github
+;;
+;; This is an implementation of an elisp-based FORTH. This means that elisp
+;; is used to write the function definitions. In fact, no FORTH function
+;; definitions are provided at all to the Forthe macro from the library.
+;; The main benefit comes from reducing the verbosity of elisp in a small
+;; Domain Specific Language the programmer defines.
+
+;;; Code:
+
+(defun forthe--inner (lang list)
+  "Internal function for the `forthe' macro.
+LANG are the bindings for the forth.
+LIST is full of the Forthe stack (RPN)."
+  (let (s)
+    (dolist (i list)
+      (if (assoc i lang)
+          (let ((fn (cadr (assoc i lang))))
+            (if s
+                (progn (apply fn s) (setf s nil))
+              (funcall fn)))
+        (push i s)))))
+
+(defmacro forthe (lang list)
+  "Define and execute a FORTH language (called Forthe).
+LANG are the let-bindings for the FORTH's operators.
+LIST is the forth's stack."
+  `(forthe--inner ,lang ',list))
+
+(provide 'forthe)
+;; forthe.el ends here