Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all concepts and fix CI #199

Merged
merged 58 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1de260d
Fix configlet linting
midyh Oct 30, 2021
cad3174
Add concept: abstract-types
midyh Oct 30, 2021
8a80239
Add concept: array-comprehension
midyh Oct 30, 2021
64af3b3
Add concept: arrays
midyh Oct 30, 2021
6196206
Add concept: bit-manipulation
midyh Oct 30, 2021
d8051a7
Merge pull request #4 from midyHamdoun/concept-abstract-types
midyh Oct 30, 2021
60bb127
Merge pull request #5 from midyHamdoun/concept-array-comprehension
midyh Oct 30, 2021
586c9e6
Merge pull request #6 from midyHamdoun/concept-arrays
midyh Oct 30, 2021
4a7125e
Merge pull request #7 from midyHamdoun/concept-bit-manipulation
midyh Oct 30, 2021
34b4dc6
Add concept: basics
midyh Oct 31, 2021
7b07376
Add titles for concept: booleans
midyh Oct 31, 2021
6491b00
Remove concept: chars
midyh Oct 31, 2021
3348887
Add concept: classes
midyh Oct 31, 2021
c1c9418
Add concept: constructors
midyh Oct 31, 2021
39a5d41
Add missing docs files
midyh Oct 31, 2021
5378771
Add concept: datetimes
midyh Oct 31, 2021
78d3a1a
Add concept: do-while
midyh Nov 1, 2021
5a316a6
Add concept: enums
midyh Nov 1, 2021
5df98f6
Add concept: equality
midyh Nov 1, 2021
d803c47
Add concept: exceptions
midyh Nov 1, 2021
b3ce40b
Add concept: final
midyh Nov 1, 2021
6d49243
Add concept: flag-enums
midyh Nov 1, 2021
47d0918
Add concept: floating-point-numbers
midyh Nov 1, 2021
fea5e2d
Add concept: for-loops
midyh Nov 2, 2021
78f1faf
Remove concept: foreach-loops
midyh Nov 2, 2021
6b3d218
Add concept: generic-types
midyh Nov 2, 2021
d601e44
Add concept: if-statements
midyh Nov 2, 2021
3206a1a
Remove concept: indexers
midyh Nov 2, 2021
e298284
Add concept: inheritance
midyh Nov 2, 2021
2cedc9c
Remove concept: integral-numbers
midyh Nov 2, 2021
6bd288e
Add concept: interfaces
midyh Nov 2, 2021
9b8754b
Add concept: iterators
midyh Nov 3, 2021
bae1393
Add concept: lambdas
midyh Nov 3, 2021
a4ae536
Add concept: lists
midyh Nov 3, 2021
2a2bbcd
Add concept: maps
midyh Nov 4, 2021
e29d339
Add concept: nullability
midyh Nov 4, 2021
55d6b23
Add concept: numbers
midyh Nov 4, 2021
d75cd0c
Add concept: operator-overloading
midyh Nov 4, 2021
95b2db6
Add concept: option-type
midyh Nov 4, 2021
d8f78c4
Add concept: optional-arguments
midyh Nov 4, 2021
60bb132
Add concept: patter-matching
midyh Nov 4, 2021
d4fee51
Add concept: properties
midyh Nov 5, 2021
cc1447e
Add concept: randomness
midyh Nov 5, 2021
c6273cd
Add concept: reflection
midyh Nov 5, 2021
107be53
Add concept: regular-expressions
midyh Nov 5, 2021
ec2927f
Add concept: rest-args
midyh Nov 5, 2021
22e5b14
Add concept: string-buffer
midyh Nov 6, 2021
fbf2b0d
Update concept: string-interpolation
midyh Nov 6, 2021
c63b791
Update concept: strings
midyh Nov 6, 2021
fc5ad95
Add concept: switch-expressions
midyh Nov 6, 2021
36538af
Add concept: templates
midyh Nov 6, 2021
da43268
Add concept: ternary-operators
midyh Nov 6, 2021
d6cef3f
Add concept: throw-expressions
midyh Nov 6, 2021
1f180cf
Add concept: time
midyh Nov 6, 2021
9da91dc
Add concept: typedefs
midyh Nov 6, 2021
0b84add
Add concept: using-statement
midyh Nov 6, 2021
d30b7c8
Add concept: while-loops
midyh Nov 6, 2021
4c39a2d
Merge branch 'fix-ci' of https://github.com/midyHamdoun/haxe into fix-ci
midyh Nov 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions concepts/abstract-types/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for abstract types concept",
"authors": [],
"blurb": "Abstract types are types that change on run-time.",
"authors": ["midyHamdoun"],
"contributors": []
}
34 changes: 33 additions & 1 deletion concepts/abstract-types/about.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
TODO about: abstract-types
# About

In Haxe, an abstract type is a type which is a different type at run-time. It is a compile-time feature which defines types "over" concrete types in order to modify or augment their behavior:

```haxe
abstract AbstractInt(Int) {
inline public function new(i:Int) {
this = i;
}
}
```

Here we are declaring the `AbstractInt` type using the `abstract` keyword. Its syntax is very similar that of `class`. And just like classes, abstarct types can have methods. They can also be instantiated and used just like classes:

```haxe
class Main {
static public function main() {
var a = new AbstractInt(12);
trace(a); // 12
}
}
```

As mentioned above, abstracts are a compile-time feature. Compiling the above example to JavaScript gives the following:

```javascript
var a = 12;
console.log(a)
```

The abstract type `AbstractInt` completely disappears from the output. That's because the constructor of `Abstract` is [inlined][inline], which we'll see later.

[inline]: https://haxe.org/manual/class-field-inline.html
23 changes: 22 additions & 1 deletion concepts/abstract-types/introduction.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
TODO introduction: abstract-types
# Introduction

In Haxe, an abstract type is a type which is a different type at run-time. It is a compile-time feature which defines types "over" concrete types in order to modify or augment their behavior:

```haxe
abstract AbstractInt(Int) {
inline public function new(i:Int) {
this = i;
}
}
```

Here we are declaring the `AbstractInt` type using the `abstract` keyword. Its syntax is very similar that of `class`. And just like classes, abstarct types can have methods. They can also be instantiated and used just like classes:

```haxe
class Main {
static public function main() {
var a = new AbstractInt(12);
trace(a); // 12
}
}
```
4 changes: 4 additions & 0 deletions concepts/abstract-types/links.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[
{
"url": "https://haxe.org/manual/types-abstract.html",
"description": "Haxe: Abstract types"
}
]
4 changes: 2 additions & 2 deletions concepts/array-comprehension/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for array comprehension concept",
"authors": [],
"blurb": "Array comprehension in Haxe is the combination of array decelartions and loops.",
"authors": ["midyHamdoun"],
"contributors": []
}
43 changes: 42 additions & 1 deletion concepts/array-comprehension/about.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
TODO about: array-comprehension
# About

Array comprehension in Haxe combines array decelartion and loops to allow array initialization. The keywords `for` and `while` are used:

```haxe
function main() {
var a = [for (i in 0...10) i];
trace(a); // [0,1,2,3,4,5,6,7,8,9]

var i = 0;
var b = [while(i < 10) i++];
trace(b); // [0,1,2,3,4,5,6,7,8,9]
}
```

The compiler generates code required to fulfill the array comprehension. So for the above example, the `a` variable is done like this:

```haxe
var a = [];
for (i in 0...10) a.push(i);
```

And for the `b` variable:

```haxe
var i = 0;
var b = [];
while (i < 10) b.push(i++);
```

The loop expression can be anything, including conditions and nested loops, so the following works as expected:

```haxe
function main() {
var a = [
for (i in 0...10)
for (j in 2...4)
i + "." + j
];
trace(a); // [2,3,3,4,4,5,5,6,6,7]
}
```
28 changes: 27 additions & 1 deletion concepts/array-comprehension/introduction.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
TODO introduction: array-comprehension
# Introduction

Array comprehension in Haxe combines array decelartion and loops to allow array initialization. The keywords `for` and `while` are used:

```haxe
function main() {
var a = [for (i in 0...10) i];
trace(a); // [0,1,2,3,4,5,6,7,8,9]

var i = 0;
var b = [while(i < 10) i++];
trace(b); // [0,1,2,3,4,5,6,7,8,9]
}
```

The loop expression can be anything, including conditions and nested loops, so the following works as expected:

```haxe
function main() {
var a = [
for (i in 0...10)
for (j in 2...4)
i + "." + j
];
trace(a); // [2,3,3,4,4,5,5,6,6,7]
}
```
4 changes: 4 additions & 0 deletions concepts/array-comprehension/links.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[
{
"url": "https://haxe.org/manual/lf-array-comprehension.html",
"description": "Haxe: Array comprehension"
}
]
4 changes: 2 additions & 2 deletions concepts/arrays/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for arrays concept",
"authors": [],
"blurb": "Arrays are a collection of multiple values of the same type.",
"authors": ["midyHamdoun"],
"contributors": []
}
47 changes: 46 additions & 1 deletion concepts/arrays/about.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
TODO about: arrays
# About

In Haxe, an **array** is a collection of elements (usually) of the same type. There are three ways to create an array in Haxe; either by constructor or by a decleration syntax. In Haxe, the first element of an array has an index of zero:

```haxe
var a = [1, 2, 3];
trace(a); // [1,2,3]

// Here the second element is called by index
trace(a[1]); // 2

// The actual first element's index is 0
trace(a[0]); // 1
```

To create an array using a constructor, you need to pass the type of the elements that are going to be included in the array:

```haxe
var a:Array<Int> = [0, 1, 2, 3];
a[1] = "Hello"; // Error: the array a takes integers only
```

Since array access in Haxe is unbounded, i.e. it is guaranteed to not throw an exception, this requires further discussion:

- If a read access is made on a non-existing index, a target-dependent value is returned.
- If a write access is made with a positive index which is out of bounds, `null` (or the default value for basic types on static targets) is inserted at all positions between the last defined index and the newly written one.
- If a write access is made with a negative index, the result is unspecified.

If we want an array to contain multiple types of elements, we add the `Dynamic` type to the type indicator:

```haxe
var a:Array<Dynamic> = [10, "Bob", true]
```

## Iteration

Arrays can be iterated using a `for` loop:

```haxe
var nums = [2, 3, 5];
var sum = 0;
for (num in nums) {
sum += num;
}
trace(sum); // 10
```
28 changes: 27 additions & 1 deletion concepts/arrays/introduction.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
TODO introduction: arrays
# Introduction

In Haxe, an **array** is a collection of elements (usually) of the same type. There are three ways to create an array in Haxe; either by constructor or by a decleration syntax. In Haxe, the first element of an array has an index of zero:

```haxe
var a = [1, 2, 3];
trace(a); // [1,2,3]

// Here the second element is called by index
trace(a[1]); // 2

// The actual first element's index is 0
trace(a[0]); // 1
```

To create an array using a constructor, you need to pass the type of the elements that are going to be included in the array:

```haxe
var a:Array<Int> = [0, 1, 2, 3];
a[1] = "Hello"; // Error: the array a takes integers only
```

If we want an array to contain multiple types of elements, we add the `Dynamic` type to the type indicator:

```haxe
var a:Array<Dynamic> = [10, "Bob", true]
```
8 changes: 8 additions & 0 deletions concepts/arrays/links.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[
{
"url": "https://haxe.org/manual/std-Array.html",
"description": "Haxe: Arrays"
},
{
"url": "https://api.haxe.org/Array.html",
"description": "Haxe: Array class"
}
]
4 changes: 2 additions & 2 deletions concepts/basics/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for basics concept",
"authors": [],
"blurb": "Learn about Haxe basics like functions and variables.",
"authors": ["midyHamdoun"],
"contributors": []
}
39 changes: 38 additions & 1 deletion concepts/basics/about.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
TODO about: basics
# About

Haxe is a strongly typed, but the typing system can be subverted where required. Assigning a value to a name is referred to as defining a variable. A variable can be defined either by explicitly specifying its type, or by letting the Haxe compiler infer the type using the [`var` keyword](var). Therefore, the following two variable definitions are equal:

```haxe
var explicitVariable:Int = 10; // Explicitly typed
var implicitVariable = 10; // Implicit typed
```

Updating a variable can be done using the `=` operator:

```haxe
var number = 0; // Initial value
number = 1; // Updated value
```

The compiler will throw an error when trying to assign a value that's type is different from the variable:

```haxe
var number = 1; // Variable number is of integer type
number = "Hello" // Error trying to assign a string to an integer variable
```

In Haxe, code is usually written inside a _function_, also called [_method_](method). These functions can take parameters (arguments), and return values using the `return` keyword. Functions are invoked using `()` syntax. All functions must have a return type.

```haxe
function add(x:Int, y:Int):Int {
return x + y;
}
```

Scope in Haxe is defined between the `{` and `}` characters.

Haxe supports two types of comments. Single line are preceded by `//` and multiline comments are inserted between `/*` and `*/`.

[var]: https://haxe.org/manual/expression-var.html
[oop]: https://en.wikipedia.org/wiki/Object-oriented_programming
[method]: https://haxe.org/manual/class-field-method.html
41 changes: 40 additions & 1 deletion concepts/basics/introduction.md
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
TODO introduction: basics
# Introduction

Haxe is a strongly typed, but the typing system can be subverted where required. Assigning a value to a name is referred to as defining a variable. A variable can be defined either by explicitly specifying its type, or by letting the Haxe compiler infer the type. Therefore, the following two variable definitions are equal:

```haxe
var explicitVariable:Int = 10; // Explicitly typed
var implicitVariable = 10; // Implicit typed
```

Updating a variable can be done using the `=` operator:

```haxe
var number = 0; // Initial value
number = 1; // Updated value
```

The compiler will throw an error when trying to assign a value that's type is different from the variable:

```haxe
var number = 1; // Variable number is of integer type
number = "Hello" // Error trying to assign a string to an integer variable
```

A function that's inside a class is called a _method_. Methods can have zero or more parameters. All parameters must be explicitly typed. Just like the parameters, the return type of a method can't be inferred and must be typed. Values are returned from methods using the `return` keyword:

```haxe
function add(x:Int, y:Int):Int {
return x + y;
}
```

Invoking a method is done by specifying its class and method name and passing arguments:

```haxe
var sum = add(1, 2) // sum = 3
```

Scope in Haxe is defined between the `{` and `}` characters.

Haxe supports two types of comments. Single line are preceded by `//` and multiline comments are inserted between `/*` and `*/`.
8 changes: 8 additions & 0 deletions concepts/basics/links.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[
{
"url": "https://haxe.org/manual/expression-var.html",
"description": "var"
},
{
"url": "https://haxe.org/manual/class-field-method.html",
"description": "method"
}
]
4 changes: 2 additions & 2 deletions concepts/bit-manipulation/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for bit-manipulation concept",
"authors": [],
"blurb": "Haxe supports bitwise operators like AND, OR, XOR and shifting.",
"authors": ["midyHamdoun"],
"contributors": []
}
15 changes: 14 additions & 1 deletion concepts/bit-manipulation/about.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
TODO about: bit-manipulation
# About

Haxe has some [unary][unary] and [binary][binary] operators to perform bitwise manipulation:

- `&`: bitwise AND
- `|`: bitwise OR
- `^`: bitwise XOR
- `~`: bitwise NEGATION
- `<<`: shift left
- `>>`: shift right
- `>>>`: unsigned shift right

[binary]: https://haxe.org/manual/expression-operators-binops.html#bitwise-operators
[unary]: https://haxe.org/manual/expression-operators-unops.html
Loading