You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here, the one-argument abstract atom \ff{goto} is being copied with a one-argument abstract anonymous object, which is the sequence of objects incrementing \ff{i} and then comparing it with the number ten. If the condition is true, \ff{g.backward} is called, which leads to a backward jump and re-iteration of \ff{goto}.
Here, the same abstract atom \ff{goto} is copied with an abstract one-argument object, which is a sequence of objects. When the condition is true, a forward jump is performed by \ff{g.forward} atom.
157
+
Here, the same abstract atom \ff{goto} is copied with an abstract one-argument object, which is a sequence of objects.
158
+
When the condition is true, a forward jump is performed by \ff{g.forward} atom.
154
159
155
160
Similarly, the atom \ff{goto} may be used to simulate other conditional jump statements, like \ff{break}, \ff{continue}, or \ff{return} in the middle of a function body (see \cref{sec:procedures}).
156
161
@@ -170,7 +175,8 @@ \subsubsection{Complex Case}
170
175
}
171
176
\end{ffcode}
172
177
173
-
In order to translate this code to \eolang{}, it has to be refactored as \cref{fig:goto} demonstrates. The function \ff{f()} is copied twice and each copy has its own execution flow implemented.
178
+
In order to translate this code to \eolang{}, it has to be refactored as \cref{fig:goto} demonstrates.
179
+
The function \ff{f()} is copied twice and each copy has its own execution flow implemented.
174
180
175
181
\begin{figure}
176
182
\includegraphics[width=0.9\columnwidth]{goto-pic}
@@ -194,7 +200,7 @@ \subsubsection{Complex Case}
194
200
}
195
201
\end{ffcode}
196
202
197
-
Then, the translation to \eolang{} is trivial, with the use of the \ff{goto} object.
203
+
Then, the translation to \eolang{} is trivial, with the use of the \ff{go.to} object.
198
204
199
205
In more complex cases, a program may first be restructured to replace \ff{goto} statements with loops and branching, as suggested by~\citet{williams1985restructuring,pan1996formal,erosa1994taming,ceccato2008goto}.
A pointer is an object in many programming languages that stores a memory address. Pointers may point to data memory or program memory.
240
+
A pointer is an object in many programming languages that stores a memory address.
241
+
Pointers may point to data memory or program memory.
235
242
236
243
\subsubsection{Pointers to Data}
237
244
238
-
This is an example of C code, where the pointer \ff{p} is first incremented by seven times \ff{sizeof(book)} (which is equal to 108) and then de-referenced to become a struct \ff{book} mapped to memory. Then, the \ff{title} part of the struct is filled with a string and the \ff{price} part is returned as a result of the function \ff{f}:
245
+
This is an example of C code, where the pointer \ff{p} is first incremented by seven times \ff{sizeof(book)} (which is equal to 108) and then de-referenced to become a struct \ff{book} mapped to memory.
246
+
Then, the \ff{title} part of the struct is filled with a string and the \ff{price} part is returned as a result of the function \ff{f}:
239
247
240
248
\begin{ffcode}
241
249
#include "string.h"
@@ -266,7 +274,7 @@ \subsubsection{Pointers to Data}
266
274
0
267
275
108
268
276
[p] > f
269
-
seq > @
277
+
seq * > @
270
278
book (p.add 7) > b
271
279
b.title.write
272
280
("Object Thinking").as-bytes
@@ -299,7 +307,7 @@ \subsubsection{Pointers to Code}
299
307
x.plus y > @
300
308
[] > f
301
309
cage 0 > p
302
-
seq > @
310
+
seq * > @
303
311
p.write
304
312
[x y]
305
313
foo x y > @
@@ -338,7 +346,7 @@ \subsubsection{Variables in Stack}
A generator is a routine that can be used to control the iteration behavior of a loop. For example, this PHP program will print first ten Fibonacci numbers:
625
+
A generator is a routine that can be used to control the iteration behavior of a loop.
626
+
For example, this PHP program will print first ten Fibonacci numbers:
618
627
619
628
\begin{ffcode}
620
629
function fibonacci(int $limit):generator {
@@ -637,18 +646,18 @@ \subsection{Generators}
637
646
memory 0 > a
638
647
memory 0 > b
639
648
memory 0 > i
640
-
seq > @
649
+
seq * > @
641
650
a.write 1
642
651
b.write 1
643
652
f 0
644
653
while.
645
654
seq (i.write (i.plus 1)) (i.lt limit)
646
655
[idx]
647
-
seq > @
656
+
seq * > @
648
657
b.write (a.plus b)
649
658
a.write (b.minus a)
650
659
f (b.minus a)
651
-
TRUE
660
+
true
652
661
fibonacci > @
653
662
10
654
663
[n]
@@ -718,7 +727,8 @@ \subsection{Types and Type Casting}
718
727
\subsection{Reflection}
719
728
\label{sec:reflection}
720
729
721
-
Reflection is the ability of a process to examine, introspect, and modify its own structure and behavior. In the following Python example the method \ff{hello} of an instance of class \ff{Foo} is not called directly on the object, but is first retrieved through reflection functions \ff{globals} and \ff{getattr}, and then executed:
730
+
Reflection is the ability of a process to examine, introspect, and modify its own structure and behavior.
731
+
In the following Python example the method \ff{hello} of an instance of class \ff{Foo} is not called directly on the object, but is first retrieved through reflection functions \ff{globals} and \ff{getattr}, and then executed:
722
732
723
733
\begin{ffcode}
724
734
def Foo():
@@ -732,7 +742,8 @@ \subsection{Reflection}
732
742
733
743
\subsubsection{Monkey Patching}
734
744
735
-
Monkey patching is making changes to a module or a class while the program is running. This JavaScript program adds a new method \ff{print} to the object \ff{b} after the object has already been instantiated:
745
+
Monkey patching is making changes to a module or a class while the program is running.
746
+
This JavaScript program adds a new method \ff{print} to the object \ff{b} after the object has already been instantiated:
We demonstrated how some language features often present in high-level object-oriented languages, such as Java or C++, may be expressed using objects. We used \eolang{} as a destination programming language because of its minimalistic semantics: it doesn't have any language features aside from objects and their composition and decoration mechanisms.
1084
+
We demonstrated how some language features often present in high-level object-oriented languages, such as Java or C++, may be expressed using objects.
1085
+
We used \eolang{} as a destination programming language because of its minimalistic semantics: it doesn't have any language features aside from objects and their composition and decoration mechanisms.
0 commit comments