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
A pointer is an object in many programming languages that stores a memory address.
242
246
Pointers may point to data memory or program memory.
243
247
@@ -390,7 +394,9 @@ \subsection{Procedures}
390
394
391
395
This example also demonstrates how \ff{go.to} object can be used to simulate the behavior of the \ff{return} statement from within the body of a method.
392
396
393
-
\subsubsection{Impure Functions}
397
+
\subsection{Impure Functions}
398
+
399
+
\broken
394
400
395
401
A function is pure when, among other qualities, it does not have side effects:
396
402
no mutation of local static variables, non-local variables, mutable reference arguments,
A class is an extensible program code template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). The following program contains a Ruby class with a single constructor, two methods, and one mutable member variable:
424
432
425
433
\begin{ffcode}
@@ -465,6 +473,8 @@ \subsection{Classes}
465
473
\subsection{Destructors}
466
474
\label{sec:destructors}
467
475
476
+
\broken
477
+
468
478
In C++ and some other languages, a destructor is a method that is called for a class object when that object passes out of scope or is explicitly deleted. The following code will print both \ff{Alive} and \ff{Dead} texts:
469
479
470
480
\begin{ffcode}
@@ -521,26 +531,25 @@ \subsection{Exceptions}
521
531
522
532
\begin{ffcode}
523
533
[] > book
524
-
[] > price /int
534
+
[] > price ?
525
535
[b] > price
526
536
if. > @
527
537
b.eq 0
528
538
error "NPE!"
529
539
b.price.times 1.1
530
540
[b] > print
531
541
try > @
532
-
[]
542
+
[] >>
533
543
QQ.io.stdout > @
534
-
QQ.txt.sprintf
535
-
"The price: %d"
536
-
price b
537
-
[e]
544
+
QQ.txt.sprintf *1
545
+
"The price: %d"
546
+
price b
547
+
[e] >>
538
548
QQ.io.stdout > @
539
-
QQ.txt.sprintf
540
-
"Error: %s"
541
-
e
542
-
[]
543
-
nop > @
549
+
QQ.txt.sprintf *1
550
+
"Error: %s"
551
+
e
552
+
true
544
553
\end{ffcode}
545
554
546
555
Here, the object \ff{try} expects three arguments: 1)~an abstract object to be dataized, 2)~an abstract object to be copied with one argument, in case dataization returns an encapsulated object, and 3)~an object to be dataized anyway (similar to Java \ff{finally} block).
@@ -549,6 +558,8 @@ \subsection{Exceptions}
549
558
550
559
\subsubsection{Many Exception Types}
551
560
561
+
\broken
562
+
552
563
A Java method may throw a number of either checked or unchecked exceptions, for example:
A generator is a routine that can be used to control the iteration behavior of a loop.
627
640
For example, this PHP program will print the first ten Fibonacci numbers:
628
641
@@ -671,7 +684,11 @@ \subsection{Generators}
671
684
\subsection{Types and Type Casting}
672
685
\label{sec:types}
673
686
674
-
A type system is a logical system comprising a set of rules that assign a property called a type to various constructs of a computer program, such as variables, expressions, functions, or modules. The main purpose of a type system is to reduce possibilities for bugs in computer programs by defining interfaces between different parts of a computer program, and then checking that the parts have been connected in a consistent way. In this example, a Java method \ff{add} expects an argument of type \ff{Book} and compilation would fail if another type is provided:
687
+
\broken
688
+
689
+
A type system is a logical system comprising a set of rules that assign a property called a type to various constructs of a computer program, such as variables, expressions, functions, or modules.
690
+
The main purpose of a type system is to reduce possibilities for bugs in computer programs by defining interfaces between different parts of a computer program, and then checking that the parts have been connected in a consistent way.
691
+
In this example, a Java method \ff{add} expects an argument of type \ff{Book} and compilation would fail if another type is provided:
675
692
676
693
\begin{ffcode}
677
694
class Cart {
@@ -728,6 +745,8 @@ \subsection{Types and Type Casting}
728
745
\subsection{Reflection}
729
746
\label{sec:reflection}
730
747
748
+
\broken
749
+
731
750
Reflection is the ability of a process to examine, introspect, and modify its own structure and behavior.
732
751
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:
733
752
@@ -743,6 +762,8 @@ \subsection{Reflection}
743
762
744
763
\subsubsection{Monkey Patching}
745
764
765
+
\broken
766
+
746
767
Monkey patching is making changes to a module or class while the program is running.
747
768
This JavaScript program adds a new method \ff{print} to the object \ff{b} after the object has already been instantiated:
748
769
@@ -808,6 +829,8 @@ \subsection{Static Methods}
808
829
\subsection{Inheritance}
809
830
\label{sec:inheritance}
810
831
832
+
\broken
833
+
811
834
Inheritance is the mechanism of basing a class upon another class while retaining similar implementation. In this Java code class \ff{Book} inherits all methods and non-private attributes from class \ff{Item}:
812
835
813
836
\begin{ffcode}
@@ -837,6 +860,8 @@ \subsection{Inheritance}
837
860
838
861
\subsubsection{Prototype-Based Inheritance}
839
862
863
+
\broken
864
+
840
865
So-called prototype-based programming uses generalized objects, which can then be cloned and extended. For example, this JavaScript program defines two objects, where \ff{Item} is the parent object and \ff{Book} is the child that inherits the parent through its prototype:
Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inherit features from more than one parent object or parent class. In this C++ example,
879
906
the class \ff{Jack} has both \ff{bark} and \ff{listen} methods, inherited from \ff{Dog} and \ff{Friend} respectively:
Method overloading is the ability to create multiple functions with the same name but different implementations. Calls to an overloaded function will run a specific implementation of that function appropriate to the context of the call, allowing one function call to perform different tasks depending on context. In this Kotlin program two functions are defined with the same name, while only one of them is called with an integer argument:
Generics extend Java's type system to allow a type or method to operate on objects of various types while providing compile-time type safety. For example, this Java class expects another class to be specified as \ff{T} before use:
975
+
\broken
976
+
977
+
Generics extend Java's type system to allow a type or method to operate on objects of various types while providing compile-time type safety.
978
+
For example, this Java class expects another class to be specified as \ff{T} before use:
947
979
948
980
\begin{ffcode}
949
981
class Cart<T extends Item> {
@@ -969,6 +1001,8 @@ \subsection{Java Generics}
969
1001
\subsection{C++ Templates}
970
1002
\label{sec:templates}
971
1003
1004
+
\broken
1005
+
972
1006
Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types, allowing a function or class to work with many different data types without being rewritten for each one.
973
1007
974
1008
\begin{ffcode}
@@ -994,6 +1028,8 @@ \subsection{C++ Templates}
994
1028
\subsection{Mixins}
995
1029
\label{sec:mixins}
996
1030
1031
+
\broken
1032
+
997
1033
A mixin is a class that contains methods for use by other classes without having to be the parent class of those other classes. The following code demonstrates how a Ruby module is included in a class:
998
1034
999
1035
\begin{ffcode}
@@ -1017,6 +1053,8 @@ \subsection{Mixins}
1017
1053
\subsection{Annotations}
1018
1054
\label{sec:annotations}
1019
1055
1056
+
\broken
1057
+
1020
1058
In Java, an annotation is a form of syntactic metadata that can be added to source code; classes, methods, variables, parameters, and Java packages may be annotated. Later, annotations may be retrieved through the Reflection API. For example, this program analyzes the annotation attached to the class of the provided object and changes the behavior depending on one of its attributes:
1021
1059
1022
1060
\begin{ffcode}
@@ -1060,6 +1098,8 @@ \subsection{Annotations}
1060
1098
1061
1099
\section{Traceability}
1062
1100
1101
+
\broken
1102
+
1063
1103
A certain amount of semantic information may be lost during the translation from a more powerful programming language to \eolang{} objects, such as, for example, names, line numbers, comments, etc. Moreover, it may be useful to have the ability to trace \eolang{} objects back to the original language constructs from which they were derived. For example, a simple C function:
0 commit comments