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
* Add tests for files in README
Test readme examples to make sure:
- Language is at the point where we expect it to
be.
- And that the examples themselves are correct.
This servers as a baseline for current hotfixes.
We will also update the examples in the README
accordingly so that it conforms the current
grammar.
* Rename factorial check file
* Update some README examples
* is a logic excepts class identifier
* [ci skip] is a logic excepts class identifier
Bunch of other small modifications uncovered
while trying to fix the README examples.
* Fix handle test
* Update version numbers in README
@@ -208,7 +213,7 @@ Type refinement allows us to do some additional things:
208
213
that certain conditions hold. We can simply ask whether a given object is a certain state by checking whether it is a
209
214
certain type.
210
215
211
-
### 🔒 Pure functions (🇻 0.4.1)
216
+
### 🔒 Pure functions (🇻 0.4.1+)
212
217
213
218
Mamba has features to ensure that functions are pure, meaning that if `x = y`, for any `f`, `f(x) = f(y)`.
214
219
(Except if the output of the function is say `None` or `NaN`.)
@@ -242,7 +247,7 @@ def pure sin(x: Int) =>
242
247
ans
243
248
```
244
249
245
-
### ⚠ Error handling (🇻 0.5+)
250
+
### ⚠ Error handling
246
251
247
252
Unlike Python, Mamba does not have `try``except` and `finally` (or `try``catch` as it is sometimes known).
248
253
Instead, we aim to directly handle errors on-site so the origin of errors is more tracable.
@@ -274,15 +279,16 @@ This also prevents us from wrapping large code blocks in a `try`, where it might
274
279
This is shown below:
275
280
276
281
```mamba
277
-
def a := function_may_throw_err() handle
278
-
err: MyErr =>
279
-
print("We have a problem: {err.message}.")
280
-
return # we return, halting execution
281
-
err: MyOtherErr =>
282
-
print("We have another problem: {err.message}.")
283
-
0 # ... or we assign default value 0 to a
284
-
285
-
print("a has value {a}.")
282
+
def g() =>
283
+
def a := function_may_throw_err() handle
284
+
err: MyErr =>
285
+
print("We have a problem: {err.message}.")
286
+
return # we return, halting execution
287
+
err: MyOtherErr =>
288
+
print("We have another problem: {err.message}.")
289
+
0 # ... or we assign default value 0 to a
290
+
291
+
print("a has value {a}.")
286
292
```
287
293
288
294
If we don't want to use a `handle`, we can simply use `raise` after a statement or exception to show that its execution might result in an exception, but we don't want to handle that here.
0 commit comments