Skip to content

Remove mandatory -> Void return type annotation #40

@brianp

Description

@brianp

Right now every function that doesn't return anything still needs -> Void on the signature:

def package(pkg_name: String, version: String = "0.0.0") -> Void
    name = pkg_name
    version_str = version

That's noise. If there's no -> annotation, the return type should be Void by default. A bare def with no return type is obviously void. You shouldn't have to spell it out.

The change:

  • If a function signature has no -> Type annotation, the compiler treats the return type as Void
  • -> Void still works explicitly if you want it (backwards compatible)
  • Functions that return a value still require the annotation

So this would just work:

def package(pkg_name: String, version: String = "0.0.0")
    name = pkg_name
    version_str = version

def compiler(ver: String)
    compiler_version = ver

This came up while writing the Seedfile DSL for the package manager. Every method in the class is -> Void and it's visual clutter that adds nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmediumShould get done, not urgentparserParsing, syntax, lexertype-systemType checker, inference, generics, traits

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions