Carbon

(in ./Carbon/_.lua)

This is the Carbon core, containing all other modules and some utilities.


Methods

class public Carbon:ImportCore()

Returns void

Imports Carbon's core utilities into the current file for use.

Presently imports:

  • Async
  • Assert
  • Error
  • IsObject
  • LoadString
  • Deprecated

class public Carbon.Assert(bool condition, [string message])

Returns void

  • required condition: The condition to assert.
  • optional message: The message to throw if the assertion fails.

Asserts, like Lua's assert, but calls tostring on the message explicitly.

DEPRECATED in 1.1: Use assert or Exception:ThrowIf (added in 1.1)


class public Carbon.Async(function method)

Returns coroutine

  • required method: The method to get an asynchronous form of.

Returns a version of the given function that is async.

Presently an alias for Lua's coroutine.wrap, but this may change in the future.


class public Carbon.Deprecated(any? thing)

Returns any?

  • required thing: The thing to mark as deprecated.

Wraps an object in a deprecation handler.

If the RemoveDeprecated feature is enabled, this method will return nil.

If thing is a function, it will throw a one-time warning on the first call.


class public Carbon.Disable(any feature)

Returns void

  • required feature: The feature to disable

Disables a feature by name.


class public Carbon.Enable(any feature)

Returns void

  • required feature: The feature to enable

Enables a feature by name.


class public Carbon.Enabled(any feature)

Returns void

  • required feature: The feature to check

Returns whether a feature is enabled.


class public Carbon.Error(...)

Returns void

  • required ...: Arguments to pass to Lua's error function.

Throws an error, calling tostring on the message explicitly.

DEPRECATED in 1.1: Use error or Exception:Throw (added in 1.0)


class public Carbon.IsObject(any object)

Returns bool

  • required object: The object to check

Returns whether the given object is a valid Carbon object.


class public Carbon.LoadString(string source, [string chunkname, table environment])

Returns function

  • required source: The source code to compile into a function.
  • optional chunkname: The name of the chunk to reference if the method returns an error.
  • optional environment: The environment to load the function into.

Loads a function with a given environment. Essentially backports Lua 5.2's load function to LuaJIT and Lua 5.1.


class public Carbon.Unpack(table t)

Returns function

  • required t: The table to unpack

Performs a fast unpack on the table.


Properties

public set Carbon.Features

Contains a set of features and whether they are enabled or disabled.


public dictionary Carbon.Support

Contains the support information provided by Graphene.


public list Carbon.Version

Contains the current version in the form {major, minor, revision, status}.


public string Carbon.VersionString

Contains a string version of the current version in the form "major.minor.revision-status".