Skip to content

Meta Directives

IsaacShelton edited this page Nov 16, 2022 · 2 revisions

Meta Directives

Meta directives allow for conditional compilation and basic compile-time computation

Usage

Meta directives start with a # followed by the directive and its parameters

#directive // ... parameters ...

Directives

#define

Defines a transcendent variable with an initial value

#define enable_secret_feature true

#default

Sets the value of a transcendent variable if it's undefined

#default transcendent_variable value

#set

Sets the value of a transcendent variable

#set transcendent_variable value

#print

Prints the value of a transcendent expression

#print "Hello World!"
#print "Welcome  + name

#print_error

Prints the value of a transcendent expression as an error

#print_error "Something went wrong"
#print_error "Compilation failed due to " + fail_reason

#print_warning

Prints the value of a transcendent expression as a warning

#print_warning "Wet floor!"
#print_warning "Assuming version to be " + version

#place

Prints the value of a transcendent epression without a trailing newline

#place "Hello World"
#place "Welcome " + name

#place_error

Prints the value of a transcendent expression without a trailing newline as an error

#place_error "Something went wrong"
#place_error "Compilation failed due to " + fail_reason

#place_warning

Prints the value of a transcendent expression without a trailing newline as a warning

#place_warning "Wet floor!"
#place_warning "Assuming version to be " + version

#input

Reads from standard input into a transcendent variable

#input name

#done

Stops compilation, exits with status of 0.

#done

#halt

Stops compilation, exits with status of 1.

#halt

#if

Conditionally compiles a section of code

#if condition
    #print "condition is true"
#end

#elif

Conditionally compiles a section of code if none of the previous #if/#elif conditions were met and the given condition is true

#if condition1
    #print "condition1 is true"
#elif condition2
    #print "condition1 is false, but condition2 is true"
#end

#else

Conditionally compiles a section of code if none of the previous if/elif conditions were met

#if condition1
    #print "condition1 is true"
#else
    #print "condition1 is false"
#end

#end

Ends a meta conditional

#if condition
    #print "condition is true"
#end

#unless

Compiles a section of code if the condition given isn't true

#unless condition
    #print "condition is false"
#end

#import

Imports the value of a transcendent expression

#import necessary_folder + "necessary.adept"

#error

Raises an error (with a code snippet) and halts compilation

#error "Requirements not met!"
main.adept:2:1: error: Requirements not met!
  2| #error "Requirements not met!"
     ^^^^^^

#warning

Raises a warning (with a code snippet)

#warning "Missing information"
main.adept:2:1: warning: Missing information
  2| #warning "Missing information"
     ^^^^^^^^

#get

Gets the value of a transcendent variable and injects it into the surrounding code

print(#get version_string)

#runtime_resource

Creates a project-local copy of a file (if one with the same name doesn't already exist)

#runtime_resource "libcurl-x64.dll"

Used to automatically supply runtime resources such as .dll files to new projects that need them.

#pragma

Alternative syntax for pragma directives

#pragma compiler_supports '2.5'

#import

Alternative syntax for file imports

#import <basics>
#import "greet.adept"

Clone this wiki locally