This Week in Mojo 2023-07-14
- New blog post titled: What's the difference between the AI Engine and Mojo?
Mojo Playground Update
Mojo now has support for global variables! This enables
letdeclaration at the top-level scope in Mojo files. Global variable initializers are run when code modules are loaded by the platform according to the order of dependencies between global variables, and their destructors are called in the reverse order.
The Mojo programming manual is now written as a Jupyter notebook, and available in its entirety in the Mojo Playground
HelloMojo.ipynbincluded most of the same material, but it was not up-to-date. We’ve also re-written
HelloMojo.ipynbto be much shorter and provide a more gentle first-user experience.
Coroutine module documentation is now available. Coroutines form the basis of Mojo’s support for asynchronous execution. Calls to
async fncan be stored into a Coroutine, from which they can be resumed, awaited upon, and have their results retrieved upon completion.
simd_bit_widthin the TargetInfo module has been renamed to
simdbitwidthto better align with
The walrus operator now works in if/while statements without parentheses, such as
x := function():
Issue #428: The FloatLiteral and SIMD types now support conversion to Int via the
__int__method calls. The behavior matches that of Python, which rounds towards zero.
Mojo Team Answers
Global Variables REPL
Global variables were added to the language but they have not been wired into the REPL environment yet. The REPL environment layers extra features on the language to provide redefinition and top-level variables, and using global variables to enable the code you wrote has not occurred yet. Sorry for the confusion!