December 2022
Week of 2022-12-26β
-
π’ You can now call functions in a parameter context! Calling a function in a parameter context will evaluate the function at compile time. The result can then be used as parameter values. For example,
fn fma(x: Int, y: Int, z: Int) -> Int: return a + b * c fn parameter_call(): alias nelts = fma(32, 2, 16) var x: SIMD[f32, nelts] -
You can now disable printing of types in an
__mlir_attrsubstitution by using unary+expression. -
π’
letdeclarations are now supported in functions.letdeclarations are local run-time constant values, which are always rvalues. They complement 'var' decls (which are mutable lvalues) and are the normal thing to use in most cases. They also generate less IR and are always in SSA form when initialized.We will want to extend this to support 'let' decls in structs at some point and support lazy initialized 'let' declarations (using dataflow analysis) but that isn't supported yet.
-
π Add the
NDBufferstruct. -
Happy new year.
Week of 2022-12-19β
-
π Start of the Standard library:
- Added Integer and SIMD structs to bootstrap the standard library.
- Added very basic buffer data structure.
-
We have basic support for parsing parameter results in function calls! Result parameters are an important Mojo metaprogramming feature. They allow functions to return compile-time constants.
fn get_preferred_simdwidthof[() -> nelts: Int](): return[2] fn vectorized_function(): get_preferred_simdwidthof[() -> nelts]() var x: SIMD[f32, nelts] -
Types can now be used as parameters of
!kgen.mlirtypein many more cases. -
MLIR operations with zero results don't need to specify
_type: []anymore. -
We support parsing triple quoted strings, for writing docstrings for your functions and structs!
-
A new
__mlir_type[a,b,c]syntax is available for substituting into MLIR types and attributes is available, and the old placeholder approach is removed. This approach has a few advantages beyond what placeholders do:- It's simpler.
- It doesn't form the intermediate result with placeholders, which gets rejected by MLIR's semantic analysis, e.g. the complex case couldn't be expressed before.
- It provides a simple way to break long attrs/types across multiple lines.
-
We now support an
@evaluatordecorator on functions for KGEN evaluators. This enables specifying user-defined interface evaluators when performing search during compilation. -
π’
importsyntax is now supported!This handles packaging imported modules into file ops, enables effective isolation from the other decls. "import" into the desired context is just aliasing decls, with the proper symbols references handle automatically during IR generation. As a starting point, this doesn't handle any notion of packages (as those haven't been sketched out enough).
-
π’ Reversed binary operators (like
__radd__) are now looked up and used if the forward version (like__add__) doesn't work for some reason. -
π’ Implicit conversions are now generally available, e.g. in assign statements, variable initializers etc. There are probably a few more places they should work, but we can start eliminating all the extraneous explicit casts from literals now.
-
Happy Holidays
Week of 2022-12-12β
-
π’ Function overloading now works. Call resolution filters candidate list according to the actual parameter and value argument specified at the site of the call, diagnosing an error if none of the candidates are viable or if multiple are viable and ambiguous. We also consider implicit conversions in overload look:
fn foo(x: Int): pass fn foo(x: F64): pass foo(Int(1)) # resolves to the first overload foo(1.0) # resolves to the second overload foo(1) # error: both candidates viable with 1 implicit conversion! -
The short circuiting binary
andandorexpressions are now supported. -
Unary operator processing is a lot more robust, now handling the
notexpression and~xon Bool. -
π’ The compiler now generates debug information for use with GDB/LLDB that describes variables and functions.
-
The first version of the Mojo Visual Studio Code extension has been released! It supports syntax highlighting for Mojo files.
-
The first version of the
Booltype has landed in the new Mojo standard library! -
π’ Implicit conversions are now supported in return statements.
Week of 2022-12-05β
-
"Discard" patterns are now supported, e.g.
_ = foo() -
We now support implicit conversions in function call arguments, e.g. converting an
indexvalue toIntautomatically. This eliminates a bunch of casts, e.g. the need to say F32(1.0) everywhere.This is limited for a few reasons that will be improved later:
- We don't support overloading, so lots of types aren't convertible from all the things they should be, e.g. you can't pass "1" to something that expects F32, because F32 can't be created from index.
- This doesn't "check to see if we can invoke
__new__" it force applies it on a mismatch, which leads to poor QoI. - This doesn't fix things that need radd.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!