Skip to content

Instantly share code, notes, and snippets.

View ShalokShalom's full-sized avatar
🐉
Garuda

ShalokShalom ShalokShalom

🐉
Garuda
View GitHub Profile

Schrödingers error handling

The Problem: The "Manual Unwrapping" Ceremony

In popular error handling systems like Swift's options or Go's error tuples,
the types that are used to represent missing data or potential errors, are just passive containers.

The standard operators like + for addition, or > for comparison, don't know how to work with them. This forces the programmer into a constant, repetitive ceremony when error handling;

To change Value<'a> to Value<'v> in the return type, you need to ensure that:

  1. The struct has a lifetime parameter 'v: The struct implementing this method must be defined with a lifetime 'v, e.g., struct MyStruct<'v> { ... }.

  2. 'v outlives 'a: The lifetime 'v of the Values must outlive the reference lifetime 'a (i.e., 'v: 'a). This ensures the Values remain valid for the duration of the returned slice.

Here's the corrected signature if your struct is MyStruct<'v>:

impl&lt;'v&gt; MyStruct&lt;'v&gt; {
To change `Value<'a>` to `Value<'v>` in the return type, you need to ensure that:
1. **The struct has a lifetime parameter `'v`**: The struct implementing this method must be defined with a lifetime `'v`, e.g., `struct MyStruct<'v> { ... }`.
2. **`'v` outlives `'a`**: The lifetime `'v` of the `Value`s must outlive the reference lifetime `'a` (i.e., `'v: 'a`). This ensures the `Value`s remain valid for the duration of the returned slice.
Here's the corrected signature if your struct is `MyStruct<'v>`:
```rust
impl<'v> MyStruct<'v> {
Can I change this code:
```rust
pub fn peek_frame<'a>(&'a self) -> Option<&'a [Value<'a>]>
```
into​
```rust
pub fn peek_frame<'a>(&'a self) -> Option<&'a [Value<'v>]>
# python_julia_connector.py
import os
from juliacall import Main as jl
# from juliacall import JuliaError # To specifically catch Julia errors if needed
# --- Environment Management & Initialization ---
# You might need to configure JuliaCall if Julia is not in your PATH
# or if you want to use a specific Julia project environment.
# For example:
# from juliacall import JuliaCall # For more control
New features get merged into `development`
New corrections get merged into `release`
Every new merge creates a new version.
A release has the versioning 2024.06.12-1
Binaries are called release-2024.06.12-1 and
development-2025.07.23-2
homoiconic transpiler toolchain
@ShalokShalom
ShalokShalom / gist:335c7aafd8a93b0e0c65cb6ff86b418d
Created February 19, 2025 00:03
The transparency of programming
Semantic transparency
Examples:
-- Multiple dispatch - ECS
-- Lambda principle - Lisp interpreter
An implementation can match the semantics of the architecture of the underlying system.
The tool ideally matches the product.
If CVEs in C++ code were 98% lower (2% of today) in the four key buckets -- initialization safety, type safety, bounds safety, and lifetime safety -- then we wouldn't be having this conversation. There would be no problem.
Cpp2 today has
guaranteed initialization safety (better than C# or Java),
guaranteed type safety (via safe is type queries and as casts),
bounds safety (via subscript checking, banning pointer arithmetic, and safe-by-construction iteration such as range-for) except for naked use of raw STL iterators, and
--Rich Hickey's infamous transducers, demonstrating reversed function composition.
--Look closely.
function transduce(tf, rf, init, iter)
for i in iter do
init = tf(rf)(init, i)
end
return init
end