addons

package
v0.0.0-...-cfb4354 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: Zlib Imports: 1 Imported by: 0

README

Package addons provides easier access to common iolang types and constants.

This package copies some types and constants to make iolang addons much less verbose. To use it, do import . "github.com/zephyrtronium/iolang/addons". CFunction definitions can then look like this:

func Foo(vm *VM, target, locals *Object, msg *Message) *Object {
	x, stop := msg.EvalArgAt(vm, locals, 0)
	if stop != NoStop {
		return vm.Stop(x, stop)
	}
	// ...
	return foo
}

instead of this:

func Foo(vm *iolang.VM, target, locals *iolang.Object, msg *iolang.Message) *iolang.Object {
	x, stop := msg.EvalArgAt(vm, locals, 0)
	if stop != iolang.NoStop {
		return vm.Stop(x, stop)
	}
	// ...
	return foo
}

The following iolang types are aliased:

  • Object
  • Slots
  • Stop
  • VM
  • Message
  • Exception

Additionally, the Stop constants for serial control flow are copied:

  • NoStop
  • ContinueStop
  • BreakStop
  • ReturnStop
  • ExceptionStop
  • ExitStop

See the Range addon at iolang/addons/range for an example of how and why to use this.

Documentation

Overview

Package addons provides easier access to common iolang types and constants.

This package is intended to be imported using the "import ." construct. It uses type aliases and copies some constants to make iolang addons much less verbose.

This is the place where evil dwells.

Index

Constants

View Source
const (
	NoStop        = iolang.NoStop
	ContinueStop  = iolang.ContinueStop
	BreakStop     = iolang.BreakStop
	ReturnStop    = iolang.ReturnStop
	ExceptionStop = iolang.ExceptionStop
	ExitStop      = iolang.ExitStop
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Exception

type Exception = iolang.Exception

type Message

type Message = iolang.Message

type Object

type Object = iolang.Object

type Slots

type Slots = iolang.Slots

type Stop

type Stop = iolang.Stop

type VM

type VM = iolang.VM

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL