New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeId builtin instead of isInteger, isFloat, etc #373

Closed
andrewrk opened this Issue May 16, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@andrewrk
Member

andrewrk commented May 16, 2017

Currently for testing the type of things, we have these builtin functions:

  • @isInteger
  • @isFloat
  • the == operator (T == bool)

There are a lot more things to check for, like structs, enums, nullables, etc. Instead of having functions for every one, let's have a function @typeId which takes a parameter T and returns an enum value for what kind of type it is. Here's an example of the return type of @typeId:

pub const TypeId = enum {
    Type,
    Void,
    Bool,
    NoReturn,
    Int,
    Float,
    Pointer,
    Array,
    Struct,
    FloatLiteral,
    IntLiteral,
    UndefinedLiteral,
    NullLiteral,
    Nullable,
    ErrorUnion,
    Error,
    Enum,
    EnumTag,
    Union,
    Fn,
    Namespace,
    Block,
    BoundFn,
    ArgTuple,
    Opaque,
};

This would go in the builtins file along with the other ones (@import("builtin").TypeId).

(@thejoshwolfe now is a good time to suggest improvements on any of these names)

@andrewrk andrewrk added this to the 0.1.0 milestone May 16, 2017

@andrewrk andrewrk closed this in b483db4 May 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment