From 9653c623bdd713f164482fee1ff7cdd5d0972d80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Teo=20Samar=C5=BEija?=
<46264381+FlatAssembler@users.noreply.github.com>
Date: Thu, 15 Jul 2021 12:53:16 +0200
Subject: [PATCH] Explained why I chose `:=` for assignment.
---
AEC_specification.html | 45 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
diff --git a/AEC_specification.html b/AEC_specification.html
index 4d7f464..62d2ef4 100755
--- a/AEC_specification.html
+++ b/AEC_specification.html
@@ -1045,10 +1045,14 @@
AEC Specification
"^\\d+\\.\\d*$" is of the type
Decimal64 and is also passed unchanged
to the assembler. Notice that in AEC for WebAssembly,
- 3/2=1 (as in C and C++), while, in AEC
- for x86, 3/2=1.5 (as in JavaScript).
- It's hard to tell which approach is better, both can produce
- hard-to-find bugs.
+ 3/2=1 (as in C, C++, Java, C#, Rust and
+ Python 2.x), while, in AEC for x86,
+ 3/2=1.5 (as in JavaScript, PHP, LISP
+ and Python 3.x). It's hard to tell which approach is better, both can
+ produce hard-to-find bugs. The Pascal-like approach of using different
+ operators for integer division and decimal division probably makes the
+ most sense, but it will also undeniably feel alien to most
+ programmers.
Variable declarations
In the version of AEC targeting x86, there are no variable declarations
in the language itself, the compiler simply assumes any token that
@@ -1243,6 +1247,39 @@ AEC Specification
C++ and JavaScript. They can make code significantly shorter.
(UPDATE on 14/09/2020: They have been implemented.)
+ UPDATE on 15/07/2021: In most programming languages these days,
+ the assignment operator is =, whereas
+ the equality-testing operator is ==.
+ The rationale for that, dating back to the C programming language, is
+ that most programs more commonly do variable assignments than they do
+ testing for equality between variables, so that it makes sense to use a
+ shorter operator for a more common operation that is assignment. While
+ that may have made sense back then, I don't think that makes any sense
+ with modern computers. Beginners in programming are in particular often
+ confused by = meaning assignment,
+ rather than something they are used to from mathematics. Also, I believe
+ everybody who has programmed in a C-like language can agree that thing
+ about equality operator being two assignment operators often leads to
+ bugs. Namely, one of the most common errors in C-like languages is that
+ the programmer mistypes
+ if (variable==0) as
+ if (variable=0), leading to the value
+ in variable being lost and the block of
+ code after that if never being
+ executed. C# attempts to solve that problem by disallowing implicitly
+ converting to the boolean type in the if-conditions, which is an
+ interesting solution, but it often makes the code longer, as well as not
+ addressing the fact that the same problem can happen with boolean
+ variables. So, I think that making
+ := the assignment operator and
+ = the equality-testing operator is a
+ good choice. The AEC-to-WebAssembly compiler allows whitespace between
+ : and
+ = in the assignment operator
+ :=, so that, when ClangFormat mistakes
+ : for the label-ending sign and puts a
+ whitespace after it, the code does not lose its meaning. I am not sure
+ now whether that was a good choice.
Operators
AEC has the following operators: