HadesLang Doc
  • Overview
  • Getting Started
    • Installing Hades
    • Basic Syntax
    • Coding Conventions
  • Language Spec
    • Foundation
      • Types
      • Built-in functions
    • Operators
      • Comparison and equality
      • Logical operators
      • Bitwise operators
      • Compound Assignment Operators
      • Operator overloading
    • Control flow
      • Conditions
      • Loops
      • Exception handling
      • Ternary and nullcheck operators
      • Pipelines
    • Classes and variables
      • Declaring variables
      • Declaring classes
      • Declaring structs
      • Declaring protos
      • Declaring arrays
      • Type conversions in simple variable types
    • Actors
      • Message passing
      • GenServer
      • Channels
    • Functions and lambdas
      • Declaring functions
      • Declaring lambdas
    • Functions of simple types
      • int
      • string
      • float
      • bool
      • atom
      • pid
    • Other
      • Annotations
      • Comments
      • Preprocessor statements
      • Reflection
      • Script file arguments
      • this keyword
  • Core Libraries
    • Standard library
      • std:io
        • console
        • file
        • directory
      • std:exceptions
      • std:int
      • std:internals
        • annotations
          • findMethod
          • findMethodInProto
          • findMethods
          • findMethodsInProto
        • function
      • std:collections
        • map
        • list
      • std:math
        • math
        • constants
        • matrix
      • std:networking
      • std:os
      • std:params
      • std:string
      • std:sql
    • Extra libraries
      • mssql:client
  • Other
    • Tools
    • Examples
    • Todos
Powered by GitBook
On this page
  • Import statements
  • Instantiable protos
  • Non-instantiable protos
  • Manually declaring protos
  • Protos as variables
  1. Language Spec
  2. Classes and variables

Declaring protos

Import statements

Protos are usually created when importing libraries or external code.

Instantiable protos

Classes and structs are imported as protos. The constructor of a class or struct is therefore an instantiable proto.

Non-instantiable protos

Every other proto (fixed classes, libraries) are not instantiable. You can call methods and instantiate classes on non-instantiable protos.

with math from std:math

var res = math.sqrt(16) //call a function on the proto

var velocity = math.Function("10x²+5x+3") //instantiate an object from the proto
var position = fn.integrate()

Manually declaring protos

Protos as variables

One can declare variables with the datatype proto. This is useful to create aliases for protos or pass protos to functions.

PreviousDeclaring structsNextDeclaring arrays

Last updated 5 years ago