Skip to content

What would you include in a tier-0 lib? #3

@capr

Description

@capr

I'll list a few things roughly in the order of how much I use them in my code. I've only written about 7K of Terra code total so far, so someone with more LOC written would probably have a better list and a different order, so FWIW:

  • the ternary operator macro: but what should we name it? the operator itself would be ideal (i.e. overloading ':' in the language when the first operand is a bool)... lacking that, I would prefer something as short as possible. I personally use iif (from sql, basic), but cond could work too (form lisp). Other suggestions?

  • print() and assert() -- my default debugging tools, use them all the time (tostring comes as a bonus, basically as a typed version of snprintf).

  • clock() -- monotonic clock, indispensable for profiling and benchmarking -- basically terralib.currenttimeinseconds but for the Terra runtime and implement it with more accurate implementations (clock_gettime(CLOCK_MONOTONIC) for Linux, mach_absolute_time for OSX)

  • typed versions of malloc, calloc, memset and memmove -- those could mimic ffi.new(), ffi.copy() and ffi.fill() semantics, so I would call them new(), copy() and fill() respectivelly. I would also add alloc() for malloc, since new() calls calloc which you may or may not want. I didn't test this but it would be interesting to know if Terra actually generates LLVM intrinsics for memmove and memset, that could be useful.

  • inc() and dec() macros -- to ease the pain of not having ++ and --

These are all in my low module, which begs the question -- what should we name this module? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions