Skip to main content

October 2022

Week of 2022-10-31​

  • Revised return handling so that a return statement with no expression is syntax sugar for return None. This enables early exits in functions that implicitly return None to be cleaner:

    def just_return():
        return
  • Added support for parsing more expressions: if-else, bitwise operators, shift operators, comparisons, floor division, remainder, and matmul.

  • πŸ“’ The type of the self argument can now be omitted on member methods.

Week of 2022-10-24​

  • Added parser support for right-associativity and unary ops, like the power operator a ** b ** c and negation operator -a.

  • Add support for &expr in Mojo, which allows denoting a by-ref argument in functions. This is required because the self type of a struct method is implicitly a pointer.

  • Implemented support for parametric function declarations, such as:

    struct SIMD[dt: DType, width: index]:
        fn struct_method(self: &SIMD[dt, width]):
            pass
    
    def fancy_add[dt: DType, width: index](
        lhs: SIMD[dt, width], rhs: SIMD[dt, width]) -> index:
      return width

Week of 2022-10-17​

  • Added explicit variable declarations with var, for declaring variables both inside functions and structs, with support for type references. Added index as a temporary built-in type.

    def foo(lhs: index, rhs: index) -> index:
        var result: index = lhs + rhs
        return result
  • Implemented support for parsing struct declarations and references to type declarations in functions! In def, the type can be omitted to signal an object type.

    struct Foo:
        var member: index
    
    def bar(x: Foo, obj) -> index:
        return x.member
  • Implemented parser support for if statements and while loops!

    def if_stmt(c: index, a: index, b: index) -> index:
        var result: index = 0
        if c:
            result = a
        else:
            result = b
        return result
    
    def while_stmt(init: index):
        while init > 1:
            init = init - 1
  • Significantly improved error emission and handling, allowing the parser to emit multiple errors while parsing a file.

Week of 2022-10-10​

  • Added support for parsing integer, float, and string literals.

  • Implemented parser support for function input parameters and results. You can now write parametric functions like,

    def foo[param: Int](arg: Int) -> Int:
        result = param + arg
        return result

Week of 2022-10-03​

  • Added some basic parser scaffolding and initial parser productions, including trivial expressions and assignment parser productions.

  • Implemented basic scope handling and function IR generation, with support for forward declarations. Simple functions like,

    def foo(x: Int):

    Now parse! But all argument types are hard-coded to the MLIR index type.

  • Added IR emission for simple arithmetic expressions on builtin types, like x + y.

Was this page helpful?