Talos v0.1.1
Installing Talos
Upgrading Talos
talos upgradeClass Declarations
With the introduction of Talos v0.1.1, comes the implementation of class declarations. Classes are the templates for defining nominal objects. They are constructed similarly to function expressions, where their body is contains fields that are bound as they are declared.
// Defining a 2D Position Class.
class Position(a_x?: Number, b_x?: Number) {
// - PROPERTIES - //
private let m_x = a_x ?? 0;
private let m_y = a_y ?? 0;
// - PUBLIC METHODS - //
public let x = fn: Number => Self.m_x;
public let y = fn: Number => Self.m_y;
};
// Instantiating differing positions.
let start = Position();
let end = Position(5, 8);Classes can also inherit from other class declarations.
// Define a base class.
class Animal(a_kind: String, a_sound: String = "...") {
// - PROPERTIES - //
public let kind = a_kind;
public let noise = a_sound;
};
// Let's prepare a variety of derived classes.
class Cat => Animal("Cat", "Meow") {};
class Dog => Animal("Dog", "Woof") {};
class Rat => Animal("Rat", "Squeak") {};
class Fish => Animal("Fish") {};
// Prepare a polymorphic value to test outputs.
let listen = fn (animal: Animal) => Debug.println("{0}: '{1}'".fmt(animal.kind, animal.noise));
// Test all the variadic values now.
listen(Cat());
listen(Dog());
listen(Rat());
listen(Fish());For more information regarding specifics for using classes, see the class fundamentals section.
Compile-Time Attributes
Alongside the release of improved support for objects in Talos comes compile-time attributes. Similar to annotations in other languages (eg: Java, Dart), Talos allows a limited set of tools to provide the runtime with metadata for variable declarations.
Deprecation Annotations
Variable declarations can now be noted as deprecated and any usage of these variables will be hinted as such (see the linting command for restricting deprecation usage).
// Annotating a variable as being deprecated.
#[Deprecated "This value is deprecated and will be removed in a future release"]
let value = ...;
// In a code-editor with a compatible Talos language-server, any usage of `value` will now be noted as deprecated.
Debug.println(value); Limited Operator Hooks
In conjunction with the upcoming use statement, attributes also allow defining custom operators for classes and objects.
// Suppose we have a class that contains a disposable resource.
class Resource {
// We can then define a custom disposable handler.
#[Operator.dispose]
private let m_dispose = fn { ... };
};
// And when instantiating resources, they can be made disposable.
use resource = Resource();Explicit Resource Management
As briefly explained above, this release of Talos implements the use statement for explicit resource management. It works similarly to the using statement in TypeScript, where values that declare a disposal callback will be automatically destroyed at the end of the scoped lifetime.
// Let's define a resource generator.
let scoped = fn (label: String): Any {
// Show when the resource is created.
Debug.println("Created '{0}'".fmt(label));
// An anonymous resource (see below note).
let resource = {};
// Attaching a disposal callback to the resource directly.
#[Operator.dispose resource]
let callback = fn { Debug.println("Disposed '{0}'".fmt(label)); };
// Return the constructed resource.
return resource;
};
use a = scoped("A");
use b = scoped("B");
{
use c = scoped("C");
use d = scoped("D");
}
use e = scoped("E");For more information, see the explicit resource management usage page.
Note:
Currently, there are no typings available for explicit resources. These are planned to be added in the future with a
Disposable interface type and additional library support.
Upcoming Work
With the foundations of these big features will come documentation, testing and library support that is planned for the next available release of Talos.
Bug Fixes
Package / talos
- Moved: Some standard library crates have been renamed to simplify imports. This is primarly for performance (eg: smaller naming = faster parsing), but aimed not to remove readability.
- Moved: The core project structure around a little bit. Previously, the runtime was written under the naming convention
talos::forge, and was exposed using a CMake interface library astalos::talos. Now the runtime has been moved solely into a standalone library astalos::talos. To then expose cratedylib:*module registrations with this standalone library, the identifiertalos::cratesis now used.
Package / vscode
- Fixed: Executable lookup now attempts to firstly find
taloswithin the$HOME/.talosdirectory.
Toolkit / talos run
- Added: Implemented
classstatements. This includes: type-checking, instantiation, super-constructors, and interfaces. - Added: Integrated the
NO_PROGRESSenvironment variable. For more details see the standards website. - Added: Implemented the
Deprecatedattribute hook. This allows marking variables as deprecated (exposed via the type-system). - Added: Implemented the
Operatorattribute hook foundations. This allows setting limited custom operators to objects (eg:call,disposeanditerator). - Added: Completed explicit resource management foundations. This includes:
usestatements, and disposal attributes. - Began: Started the foundations for implementing a debugger. The core principle behind doing so is limited bytecode opcodes to a 7-bit value and using the most-significant to indicate that a breakpoint as been set.
Toolkit / talos upgrade
- Fixed: Simplified the uninstall process on Windows. Previously it used a scheduled-task, however this has been replaced with a delayed
rmdircommand invoked through a hidden separate process using thestartcommand.
Crate / talos:ffi
- Added: Prepared stub typings for a future FFI implementation.
Crate / talos:gc
- Moved: Renamed the garbage collection module from
talos:garbagetotalos:gc.
Crate / talos:mem
- Moved: Renamed the virtual memory module from
talos:memorytotalos:mem.
Crate / talos:uuid
- Added: Exposed all UUID versions 1, 3, 4, 5, 6 and 7, alongside available namespace seeds.