Comment

Comment by one-more-minute

For reference, a staged function is something sorta similar to a macro, except it lets you take advantage of Julia's inferred type info. Contrived (and wholly redundant) example:

  stagedfunction foo(x)
      if x == Int
          :(2x)
      else
          :x
      end
  end

  y = 1
  foo(y)  == 2
  y = 1.
  foo(y) == 1.0 
Again, just like a macro, except that before `x` is quoted you work with the type of y instead of the symbol `y`. This means you can do even more crazy code specialisation, including on e.g. matrix dimensions or generating appropriate FFI calls based on arbitrary input types. It has zero overhead and you can use it just like a regular function.

Very cool, and I think people will do really interesting things with this (especially after mixing them with macros).

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton