Small ML Language
  • Small ML language
  • Installation
  • Hello World
  • Basics
    • Literals
    • Types
    • Type casting
    • Variables
    • Operators
    • Functions
    • Function chaining
    • Conditionals
    • Match
    • Arrays
    • Structs
    • Structure field Access
    • Enums
    • Enum Specialization
    • Object Destructuring
    • Modules
  • Compiler internals
    • SMLL to JAVA
Powered by GitBook
On this page
  1. Basics

Structure field Access

The need for field access

PreviousStructsNextEnums

Last updated 10 months ago

Defining data structures is important for writing efficient and maintainable software. Without the ability to access and use the data stored structures become a redundant feature. In SMLL data structure fields can be extracted from instances either using or using the :: operator.

struct Foo (bar: Int)

fn main(): Unit => 
    let
        baz = Foo {bar: 200}
    in printf("Bar = %d\n", baz::bar) 

This allows the users to write concise code that that is re-usable as structs can be composed to form even more complex data structures.

Object Destructuring