or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdnative-overrides.md
tile.json

tessl/maven-org-scala-native--scalalib-native0-5-2-13

Native-specific overrides for Scala standard library components, providing VM memory management and enhanced Enumeration implementation

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.scala-native/scalalib_native0.5_2.13@0.5.x

To install, run

npx @tessl/cli install tessl/maven-org-scala-native--scalalib-native0-5-2-13@0.5.0

index.mddocs/

Scala Native Standard Library Overrides (scalalib)

Native-specific implementations that replace or enhance standard Scala library components for the Scala Native runtime. This module provides platform-optimized versions of select Scala standard library components, improving performance and compatibility with native compilation.

Package Information

  • Package Name: scalalib_native0.5_2.13
  • Package Type: Maven/SBT
  • Language: Scala (2.13, with support for 2.12 and 3.x)
  • Platform: Scala Native 0.5.x
  • Installation: libraryDependencies += "org.scala-native" %%% "scalalib" % "0.5.8"

Core Imports

The scalalib overrides are automatically used when the corresponding standard library classes are imported:

// Enumeration override is used automatically
import scala.Enumeration

// VM memory management utilities (package-private)
import scala.collection.immutable.VM

Basic Usage

// Enumeration works identically to standard Scala but with native optimizations
object Color extends Enumeration {
  type Color = Value
  val Red, Green, Blue = Value
}

val color = Color.Red
val allColors = Color.values

// VM memory management (used internally by collections)
import scala.collection.immutable.VM
VM.releaseFence() // Atomic memory fence operation

Architecture

The scalalib module provides only two key override components:

  • VM Memory Management: Atomic memory fence operations for thread-safe collection operations
  • Enhanced Enumeration: Native-optimized enumeration implementation with improved performance and Scala.js compatibility

This focused approach ensures that critical standard library components have native-specific optimizations while maintaining full API compatibility with standard Scala implementations.

Capabilities

VM Memory Management

Package-private atomic memory fence operations for internal use by immutable collections, providing thread-safe memory synchronization in the native runtime environment.

package scala.collection.immutable

/* private[immutable] */ object VM {
  def releaseFence(): Unit
}

VM Memory Management

Enhanced Enumeration Implementation

Complete native-optimized implementation of Scala enumerations with improved performance, better memory management, and Scala.js compatibility.

abstract class Enumeration(initial: Int) extends Serializable {
  def this(): Enumeration
  def values: ValueSet
  def apply(x: Int): Value
  def withName(s: String): Value
  def maxId: Int
  protected def Value: Value
  protected def Value(i: Int): Value
  protected def Value(name: String): Value
  protected def Value(i: Int, name: String): Value
}

abstract class Enumeration#Value extends Ordered[Value] with Serializable {
  def id: Int
  def compare(that: Value): Int
  def +(v: Value): ValueSet
}

class Enumeration#ValueSet extends immutable.SortedSet[Value] with Serializable {
  def contains(v: Value): Boolean
  def +(value: Value): ValueSet
  def -(value: Value): ValueSet
  def iterator: Iterator[Value]
  def toBitMask: Array[Long]
}

Enhanced Enumeration

Types

Core Enumeration Types

// ValueSet factory
object Enumeration#ValueSet {
  val empty: ValueSet
  def apply(elems: Value*): ValueSet
  def fromBitMask(elems: Array[Long]): ValueSet
  def newBuilder: mutable.Builder[Value, ValueSet]
}

// Internal Val implementation
protected class Enumeration#Val(i: Int, name: String) extends Value with Serializable {
  def this(i: Int): Val
  def this(name: String): Val
  def this(): Val
  def id: Int
}

// Value ordering
object Enumeration#ValueOrdering extends Ordering[Value] {
  def compare(x: Value, y: Value): Int
}