Skip to content

Commit

Permalink
feat: update documentation and links for Helix language features, inc…
Browse files Browse the repository at this point in the history
…luding questionable types and panic handling
  • Loading branch information
Ze7111 committed Dec 5, 2024
1 parent 8266d71 commit 5c124ac
Show file tree
Hide file tree
Showing 7 changed files with 442 additions and 17 deletions.
Empty file.
2 changes: 1 addition & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default defineConfig({
baseUrl: 'https://github.com/helixlang/helix-site/edit/new-template/src/content/docs/docs/',
},
social: {
github: 'https://github.com/helixlang/helix',
github: 'https://github.com/helixlang/helix-lang',
},
customCss: ["/src/styles/docstyle.css"],
expressiveCode: {
Expand Down
6 changes: 4 additions & 2 deletions src/content/docs/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Helix is a modern, compiled programming language designed to empower developers
## **Why Choose Helix?**

#### 1. **Performance at Its Core**
Helix uses the LLVM toolchain** to compile to native machine code, leveraging the power of cutting-edge compiler optimizations to produce fast, predictable binaries. It offers:
Helix uses the LLVM toolchain¹ to compile to native machine code, leveraging the power of cutting-edge compiler optimizations to produce fast, predictable binaries. It offers:
- Low-level access to system resources when needed.
- Zero-cost abstractions that don't compromise performance or efficiency.
- Fine-grained control over memory, concurrency, data layout, and more.
Expand Down Expand Up @@ -63,4 +63,6 @@ Helix seamlessly interacts with other languages:

Helix is the language that adapts to your needs—whether you're building performance-critical systems or expressive, maintainable applications. Explore the journey ahead and see why Helix is the next evolution in programming.

** Helix at the current stage uses a an intermediate C++ backend to get to the LLVM IR, but we are planing to move to the LLVM IR directly in the future.
---

*1. Helix at the current stage uses a an intermediate C++ backend to get to the LLVM IR, but we are planing to move to the LLVM IR directly in the future.*
14 changes: 12 additions & 2 deletions src/content/docs/docs/language/panicking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Panicking
description: Comprehensive guide to the `panic` statement in Helix, its behavior, and best practices for error handling.
---

import { Tabs, TabItem, Aside } from '@astrojs/starlight/components';
import { CardGrid, LinkCard, Tabs, TabItem, Aside } from '@astrojs/starlight/components';

## Panic in Helix

Expand All @@ -30,7 +30,7 @@ In Helix, **`panic`** is a special statement used to signal an error by returnin
#### With Questionable Types (`?`)

When a function's return type is a questionable type, `panic` sets the return value to an error. This value can then be validated using `...?` or `error in ...` syntax.
Refer to the [Questionable Types Guide](../questionable-types) for more details on questionable types.
Refer to the [Questionable Types Guide](../questionable) for more details on questionable types.

```helix
import std::errors;
Expand Down Expand Up @@ -290,3 +290,13 @@ fn main() {
The **`panic` statement** in Helix is a powerful and integrated error-handling mechanism. By leveraging questionable types (`?`) or `std::Error::<T, E...>`, you can create predictable and robust error propagation paths.

Ensure every `panic` is handled gracefully with checks (`...?`, `error in ..`, `.has_value()`) and explicitly extract values where needed. This design keeps Helix code clean, safe, and predictable.

### References

<CardGrid>
<LinkCard
title="Questionable Types"
description="Learn about nullable and error-prone data handling in Helix."
href="../questionable"
/>
</CardGrid>
21 changes: 18 additions & 3 deletions src/content/docs/docs/language/questionable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Questionable
description: Comprehensive guide to using questionable types in Helix, their behavior, and best practices for error and null handling.
---

import { Tabs, TabItem, Aside } from '@astrojs/starlight/components';
import { CardGrid, LinkCard, Tabs, TabItem, Aside } from '@astrojs/starlight/components';

## Questionable Types (?)

Expand Down Expand Up @@ -114,7 +114,7 @@ A questionable type can hold one of three states:
<TabItem label="Error">
- **errors** can not be assigned directly. Since they are the panicked state of a function.
- They can be assigned as a result of a function call. but not directly.
- refer to [Panic](../panic) for more information.
- refer to [Panic](../panicking) for more information.
```helix
let x: int? = divide(10, 0); // Holds an error
```
Expand Down Expand Up @@ -255,4 +255,19 @@ if x?:

### Conclusion

Questionable types (`?`) in Helix are a powerful tool for managing nullable and error-prone data. By embedding error and null handling into the type system, Helix enables clean, concise, and safe code. Use `...?`, `in`, and `error in ...` to validate questionable types and write robust programs.
Questionable types (`?`) in Helix are a powerful tool for managing nullable and error-prone data. By embedding error and null handling into the type system, Helix enables clean, concise, and safe code. Use `...?`, `in`, and `error in ...` to validate questionable types and write robust programs.

### References

<CardGrid>
<LinkCard
title="Panic"
description="Learn about error handling and panics in Helix."
href="../panicking"
/>
<LinkCard
title="Functions"
description="Explore how functions work in Helix and best practices for defining them."
href="../functions"
/>
</CardGrid>
Loading

0 comments on commit 5c124ac

Please sign in to comment.