RocketLang v0.23.0 is released
Breaking Changesโ
This release includes breaking changes to integer and string conversion methods.
Removed Base Parameters from .to_s() and .to_i()โ
The .to_s() and .to_i() methods no longer accept optional base parameters. This functionality was broken and has been removed in favor of the new explicit .base() and .to_base() methods.
Before (v0.22.x and earlier):
num = 1234
num.to_s(2) // Would convert to binary string
num.to_s(8) // Would convert to octal string
str = "1010"
str.to_i(2) // Would parse as binary
Now (v0.23.0):
// Integers now carry base information internally
num = "0b1010".to_i() // Integer with base 2, value 10
num.to_s() // Returns "0b1010" (preserves base representation)
num.base() // Returns 2
// Use .to_base() for base conversion
num.to_base(8) // Returns 0o12 (octal integer)
num.to_base(16) // Returns 0xa (hexadecimal integer)
num.to_base(16).to_s() // Returns "0xa" (hex string)
// String parsing automatically detects and preserves base
str = "0b1010"
int_val = str.to_i() // Integer with base 2, value 10
int_val.base() // Returns 2
This change makes integer conversion behavior more predictable and fixes bugs related to base handling.
New Featuresโ
Matrix Object Typeโ
You can now work with matrices natively in RocketLang. This release introduces a new matrix object type with support for matrix multiplication, addressing issue #64.
// Create matrices from nested arrays
m1 = [[1, 2], [3, 4]].to_m()
m2 = [[5, 6], [7, 8]].to_m()
// Matrix multiplication
result = m1 * m2
// Element-wise operations
sum = m1 + m2
diff = m2 - m1
puts(result)
// Output:
// 2x2 matrix
// โ โ
// โ 19.0 22.0 โ
// โ 43.0 50.0 โ
// โ โ
See Matrix for more information about matrix operations and methods.
Variable Unpacking on Assignmentโ
You can now unpack multiple return values directly into variables, making it easier to work with functions that return multiple values (issue #112).
// Unpack multiple values at once
a, b, c = some_function()
x, y = [1, 2]
This feature greatly simplifies code that needs to handle multiple return values.
Optional Parentheses for Control Expressionsโ
Control flow expressions are now more flexible. Following issue #203, you can now omit parentheses around conditions in if, while, and other control structures.
// Both styles are now valid
if condition
puts("No parentheses needed!")
end
if (condition)
puts("Parentheses still work too!")
end
Integer Base Handlingโ
Integers now carry their base information internally and provide new methods to work with different number bases:
.base()- Returns the base of an integer (2, 8, 10, or 16).to_base(INTEGER)- Converts an integer to a different base representation
// Integers now remember their base when created from strings
binary_num = "0b1010".to_i()
binary_num.base() // Returns 2
// Convert between bases while preserving the value
octal = binary_num.to_base(8) // Returns 0o12
hex = binary_num.to_base(16) // Returns 0xa
See Integer for more information.
Improvementsโ
Better puts Behaviorโ
The puts function has been improved (some would say it was broken before) to behave more consistently across different scenarios (fixing issue #170).
Bug Fixesโ
Integer Downcast Preventionโ
Fixed an issue where integers could be incorrectly downcast, potentially leading to data loss. Your numeric operations are now safer and more reliable.
Array .pop() Safetyโ
Fixed a panic that occurred when calling .pop() on an empty array (issue #166). The method now handles empty arrays gracefully.
Dependency Updatesโ
All dependencies have been updated to their latest versions, ensuring better security and performance.
Documentation Updatesโ
The documentation site has been updated to Docusaurus 3.9, providing a better reading experience and improved navigation.
Check out the full changelog for a complete list of changes and contributors.