Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As an aside, Julia's MacroTools.jl defines pre- and post- code walking in four lines:

    walk(x, inner, outer) = outer(x)
    walk(x::Expr, inner, outer) = outer(Expr(x.head, map(inner, x.args)...))

    postwalk(f, x) = walk(x, x -> postwalk(f, x), f)
    prewalk(f, x)  = walk(f(x), x -> prewalk(f, x), identity)
It's dead simple and obvious in retrospect, but I don't think I would have ever thought of that! I've always wondered if there's a lineage to this set of definitions. Does anyone know?


Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: