v0.6.1 (2023-12-18)
⭐️ New
-
The Mojo REPL now provides limited support for the
%cdmagic command.This command automatically maintains an internal stack of directories you visit during the REPL session. Usage:
%cd 'dir': change to directorydirand push it on the directory stack.%cd -: pop the directory stack and change to the last visited directory.
-
Structs decorated with
@valuenow automatically conform to theMovableandCopyablebuilt-in traits. -
Stringnow has newtoupper()andtolower()methods analogous, respectively, to Python'sstr.toupper()andstr.tolower(). -
Added a
hash()built-in function andHashabletrait for types implementing the__hash__()method. Future releases will addHashablesupport to Standard Library types. In the meantime, thehashmodule includes a version of thehash()function that works on arbitrary byte strings. To generate hashes forSIMDtypes, you use the internal_hash_simd()function:from builtin.hash import _hash_simd
fn gen_simd_hash():
let vector = SIMD[DType.int64, 4](1, 2, 3, 4)
let hash = _hash_simd(vector) -
Several standard library types now conform to the
CollectionElementtrait. These types includeBool,StringLiteral,DynamicVector,Tensor,TensorShape, andTensorSpec.
🦋 Changed
-
utils.vectorhas been moved to a newcollectionspackage to make space for new collections. This means that if you had previous code that didfrom utils.vector import DynamicVector, it now needs to befrom collections.vector import DynamicVectordue to the move. -
The special destructor method
__del__()has been changed to enforce that it cannot raise an error. Raising destructors are not supported properly at the moment.
🛠️ Fixed
-
#1421 - Fixed a crash when using Tuples in the REPL.
-
#222 - Generate an error for obviously self recursive functions.
-
#1408 - Fix overload resolution when candidates can return generic types.
-
#1413 and #1395 - Do not crash when re-declaring a builtin declaration.
-
#1307 - Fix compatibility of function signatures that only differ in default argument values.
-
#1380 - Fix printing of empty
String.