-
Notifications
You must be signed in to change notification settings - Fork 8
Description
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 useiif(from sql, basic), butcondcould 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.currenttimeinsecondsbut for the Terra runtime and implement it with more accurate implementations (clock_gettime(CLOCK_MONOTONIC)for Linux,mach_absolute_timefor 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? :)