#comptime code injection

1 messages · Page 1 of 1 (latest)

jade jasper
#

Is it possible to decide between two code blocks by comptime evaluation. Will the compiler inline one of the branches/exclude the other and 'if-else statement'.
something like:

fn foo(T: type) void {
  if (@typeInfo(T).Int) {
    ... // here will be inlined if `T` is int
  } else {
    ... // here will be inlined if `T` is not an int 
  }
}
slate merlin
#

this is already how if statements work when the expression is comptime known