Updated visibility
This commit is contained in:
@@ -60,5 +60,5 @@ impl fmt::Display {
|
|||||||
|
|
||||||
- **Unified Scope**: Data, behavior, and trait logic live in one place, eliminating the friction of jumping between `struct` and `impl` blocks.
|
- **Unified Scope**: Data, behavior, and trait logic live in one place, eliminating the friction of jumping between `struct` and `impl` blocks.
|
||||||
- **Explicit Context**: The use of `self*` ensures that the relationship between a method and its instance is always transparent.
|
- **Explicit Context**: The use of `self*` ensures that the relationship between a method and its instance is always transparent.
|
||||||
- **Encapsulation**: Visibility modifiers (`public`) allow you to expose a clean API while keeping internal helper methods and state private to the class.
|
- **Encapsulation**: Visibility modifiers (`pub`) allow you to expose a clean API while keeping internal helper methods and state private to the class.
|
||||||
- **Zero-Cost Classes**: Under the hood, Mist desugars these into idiomatic Rust structs and implementation blocks, ensuring no runtime overhead compared to raw Rust.
|
- **Zero-Cost Classes**: Under the hood, Mist desugars these into idiomatic Rust structs and implementation blocks, ensuring no runtime overhead compared to raw Rust.
|
||||||
|
|||||||
@@ -53,5 +53,5 @@ public enum Validation<'a, T> {
|
|||||||
|
|
||||||
- **Consistent Member Declaration**: Struct-like variants maintain the `type name` order, ensuring that data modeling feels identical whether you are defining a top-level `struct` or an `enum` variant.
|
- **Consistent Member Declaration**: Struct-like variants maintain the `type name` order, ensuring that data modeling feels identical whether you are defining a top-level `struct` or an `enum` variant.
|
||||||
- **Rust-Native ADTs**: Enums compile directly to Rust enums, allowing for exhaustive pattern matching and zero-cost abstraction.
|
- **Rust-Native ADTs**: Enums compile directly to Rust enums, allowing for exhaustive pattern matching and zero-cost abstraction.
|
||||||
- **Shared Visibility**: The `public` modifier at the enum level exports all variants for use in other modules, matching Rust's visibility rules for enums.
|
- **Shared Visibility**: The `pub` modifier at the enum level exports all variants for use in other modules, matching Rust's visibility rules for enums.
|
||||||
- **Comma-Separated Members**: Fields within struct-like variants are separated by commas, mirroring the syntax used in standard Mist structs.
|
- **Comma-Separated Members**: Fields within struct-like variants are separated by commas, mirroring the syntax used in standard Mist structs.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void log_status(str* message) {
|
|||||||
|
|
||||||
## Visibility & Exports
|
## Visibility & Exports
|
||||||
|
|
||||||
Functions are private to their module by default. The `public` modifier exports the function for cross-module access.
|
Functions are private to their module by default. The `pub` modifier exports the function for cross-module access.
|
||||||
|
|
||||||
```mist
|
```mist
|
||||||
public i32 get_version() {
|
public i32 get_version() {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public struct Task {
|
|||||||
|
|
||||||
## Visibility
|
## Visibility
|
||||||
|
|
||||||
Use the `public` modifier to make the struct or its individual fields accessible from other modules.
|
Use the `pub` modifier to make the struct or its individual fields accessible from other modules.
|
||||||
|
|
||||||
```mist
|
```mist
|
||||||
public struct NetworkNode {
|
public struct NetworkNode {
|
||||||
@@ -57,4 +57,4 @@ public struct Buffer<'a, T> {
|
|||||||
- **Type-First Declaration**: Fields use the `type name` order to match function parameters and variable declarations.
|
- **Type-First Declaration**: Fields use the `type name` order to match function parameters and variable declarations.
|
||||||
- **Comma-Separated Members**: Fields are separated by commas, maintaining a clean and consistent delimiter style.
|
- **Comma-Separated Members**: Fields are separated by commas, maintaining a clean and consistent delimiter style.
|
||||||
- **Rust Compatibility**: Maps 1:1 to Rust structs, ensuring zero-cost abstraction and full ecosystem interoperability.
|
- **Rust Compatibility**: Maps 1:1 to Rust structs, ensuring zero-cost abstraction and full ecosystem interoperability.
|
||||||
- **Direct Visibility**: The `public` keyword replaces `pub` for a more consistent modifier language across the codebase.
|
- **Direct Visibility**: The `pub` keyword replaces `pub` for a more consistent modifier language across the codebase.
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ Inheritance is a major planned feature but is currently **not implemented**.
|
|||||||
|
|
||||||
Be aware that because we are focusing on syntax, keywords and structures may change between minor versions. Currently:
|
Be aware that because we are focusing on syntax, keywords and structures may change between minor versions. Currently:
|
||||||
|
|
||||||
* **Access Modifiers:** `public` and private defaults are being tested for various contexts (classes vs. structs, or `public(crate)`).
|
* **Access Modifiers:** `pub` and private defaults are being tested for various contexts (classes vs. structs, or `public(crate)`).
|
||||||
|
|
||||||
|
|
||||||
* **Pointers vs. References:** The `*` syntax for references (e.g., `self mut*`) is the current standard but is subject to refinement based on ecosystem feedback.
|
* **Pointers vs. References:** The `*` syntax for references (e.g., `self mut*`) is the current standard but is subject to refinement based on ecosystem feedback.
|
||||||
|
|||||||
Reference in New Issue
Block a user