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
@@ -109,7 +115,9 @@ b = foo(4) // overrides default value
109
115
b = foo(x=4) // overrides default value by name
110
116
```
111
117
112
-
usage of varying number of arguments:
118
+
usage of varying number of arguments (variadic parameters):
119
+
120
+
> variadic parameters are just syntactic sugar for slices `..int` and `[]int` are identical in structure
113
121
114
122
```odin
115
123
sum :: proc(nums: ..int) -> int {
@@ -131,15 +139,10 @@ foo :: proc() -> int {
131
139
return a
132
140
}
133
141
134
-
// with named output
135
-
foo :: proc() -> (a: int) {
136
-
a = 10
137
-
}
138
-
139
142
// with named output and naked return statement
140
143
foo :: proc() -> (a: int) {
141
144
a = 10
142
-
return // a return without arguments returns the named return value
145
+
return // return still required (returns the named return value)
143
146
}
144
147
```
145
148
@@ -216,7 +219,7 @@ for &value in some_array {
216
219
value = something // element can be modified
217
220
}
218
221
219
-
// map loop by referende (key can not be referenced)
222
+
// map loop by reference (key can not be referenced)
220
223
for key, &value in some_map {
221
224
value += 1
222
225
}
@@ -285,7 +288,7 @@ delete(my_map)
285
288
286
289
## Pointers
287
290
288
-
pointers have the same semantics as in c, but not the same syntax. using `^type` as pointer types, `ptr^` as dereference syntax, and `&value` as the adress of operator.
291
+
pointers have the same semantics as in c, but not the same syntax. using `^type` as pointer types, `ptr^` as dereference syntax, and `&value` as the address-of operator.
289
292
290
293
```c
291
294
// c
@@ -301,12 +304,13 @@ p: ^int = &x
301
304
p^ = 2
302
305
```
303
306
304
-
There is no such thing as pointer aritmatic like in c,
305
-
because unlike in c, arrays are not just pointers,
306
-
for pointer arritmatic like behaviour there are "multi pointers" of the `[^]T` type,
307
+
There is no such thing as pointer arithmetic like in c,
308
+
because unlike in c, arrays are not just fancy pointers, but actual value types,
309
+
for pointer arithmetic like behaviour there are "multi pointers" of the `[^]T` type,
307
310
which are pointers that map to multiple items, and can be indexed like an array.
308
-
multi pointers are easiest to use with the `raw_data()`buildin call.
311
+
multi pointers are easiest to use with the `raw_data()`builtin call.
309
312
the `raw_data` is a builtin which returns the underlying data of a builtin data type as a multi pointer.
313
+
the builtin `make()` procedure can also return multi pointers.
310
314
311
315
simple usage example of a multi pointer:
312
316
@@ -340,12 +344,12 @@ What multi pointers do not support:
340
344
341
345
Instead of headers of modules or namespaces, the Odin language uses packages.
342
346
Packages in odin are directory based, similar to how golang manages packages,
343
-
this makes using submodules usefull, and makes it so you dont need a package manager.
347
+
this makes using submodules useful, and makes it so you dont need a package manager.
344
348
In Odin a package is a directory of Odin code files, all of which have the same package declaration at the top.
345
349
Make a file part of a package by putting the `package package_name` declaration at the top of the odin files in the package.
346
350
A directory cannot contain more than 1 package, so you can not have different package declarations in the same directory.
347
351
To import a package (make it accesable), you use the `import` keyword.
348
-
To import a standard library package you can use a prefex like `import "core:fmt"` where `core:` is the library prefix.
352
+
To import a standard library package you can use a prefix like `import "core:fmt"` where `core:` is the collection prefix.
349
353
If no prefix is specified the package will be searched relative to the current file path.
350
354
Packages can be namespaced by using the `import foo "core:fmt"` syntax.
351
355
@@ -357,7 +361,7 @@ Packages can be namespaced by using the `import foo "core:fmt"` syntax.
357
361
358
362
## Casting
359
363
360
-
In odin there is no implicit widening type conversion like in c, all types must be manually cast, luckily odin has a nice and simple syntax for type conversions and casting:
364
+
In odin there is no implicit widening type conversion like in c, and only a [very short list of implicit conversions](https://odin-lang.org/docs/overview/#implicit-type-conversions) nearly all types must be manually cast, luckily odin has a nice and simple syntax for type conversions and casting:
361
365
362
366
The expression `T(value)` converts `value` to the `T` type:
363
367
```odin
@@ -378,14 +382,11 @@ i: i64 = 123
378
382
f: f64 = transmute(f64)i
379
383
```
380
384
381
-
## Function Overloading
385
+
## Prodecure (Function) Overloading
382
386
383
-
Unlike in many other languages, operator overloading in Odin is explicit,
384
-
the reason being that procedures can be nested within procedures and, as a result,
385
-
determining which procedure should be used in the case of implicit overloading is complex,
386
-
therefore explicit overloading makes more sense.
387
+
Unlike in many other languages, procedure overloading in Odin is explicit.
387
388
388
-
Here is an example of how to do function overloading:
389
+
Here is an example of how to do procedure overloading:
In odin a static array is typed like `[N]T`, or `[?]T` for inferred size, and a slice like `[]T`, and a dynamic array like `[dynamic]T`, or `[dynamic;N]T` for a dynamic array with a fixed capacity.
406
+
In odin a static array is typed like `[N]T`, or `[?]T` for inferred size (only in a literal), and a slice like `[]T`, and a dynamic array like `[dynamic]T`, or `[dynamic;N]T` for a dynamic array with a fixed capacity.
406
407
407
408
An array in odin is just like a struct in that its value type that contains all of its own data.
408
409
@@ -415,13 +416,12 @@ Slices and dynamic arrays are simple small structures with a pointer to an under
415
416
The zero value of a slice is nil. A nil slice has a length of 0 and does not point to any underlying memory. Slices can be compared against nil and nothing else.
0 commit comments