Snowball Docs
SocialsContributeTry out online!Standard Library
  • 👋Welcome to snowball!
  • Overview
    • 🐈Why Snowball
    • ✨Language Features
  • fundamentals
    • 🛠️Getting started
    • 📝Installation
      • ‼️Common install issues
    • 👶Hello world!
  • language reference
    • 🌐Global Scope
    • 🤖Functions
      • 🐣Basic syntax
      • 😵Function Generics
      • ❓External functions
      • 🔧Function Attributes
      • 💢LLVM Functions
      • 🚪Program Entries
    • 🎭Types
      • 🔢Primitive types
      • 🔀Reference types
      • ☝️Pointer types
      • 🔓Mutability
      • ⁉️Type generics
      • 🔖Type aliases
      • 🚯Unknown pointer type (void pointers)
    • 🔄Casting
      • 🔐Mutability casting
      • 🦺Dynamic casting
      • 👨‍🎓Type conversions
    • 🏗️Classes
      • 💼Members
      • 🔒Access qualifiers
      • 🛑Final classes
      • 🍧Abstract classes
    • 🔏Access qualifiers
    • ⚒️Macros
      • ✨Builtin macros
    • 🔫Unsafe snowball
    • 😴Generics
    • 🌳Code Flow
      • ☝️If statements
    • 📦Modules
      • 👉Using Statement
  • snowball cli usage
    • 💻CLI usage and parameters
    • 🧪Testing mode
  • Confy
    • ⚙️Getting Started
    • 🐈Snowball's Schema
  • Reky Package Manager
    • 📦Getting Started
  • coding style
    • 💅The desired standard
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. language reference
  2. Types

Reference types

In Snowball, reference types allow you to create safe references to other values or objects without exposing low-level pointer manipulation. These references provide a way to access and work with data stored elsewhere in memory. Here's the syntax for reference types in Snowball:

&T

In Snowball, these reference types provide a higher level of abstraction compared to raw pointers, ensuring memory safety and preventing common programming errors like null pointer dereferences and dangling pointers. The references automatically handle memory management, making it easier to work with data while minimizing the risk of memory-related bugs.

func example(x: &mut myStruct) {
    a.field = 54;
}

let a: myStruct = ...; // a.field = 10
example(a)             // a.field = 54

By using reference types, you can create references to existing values and safely interact with them without directly manipulating memory addresses. Snowball's reference types enable you to write code that is easier to reason about, maintain, and debug.

Reference to a reference to a reference to a...

You can create as many references as you want (but it's not recommended ). for example:

let a: &&&&i32 = ...
PreviousPrimitive typesNextPointer types

Last updated 1 year ago

Was this helpful?

🎭
🔀