Comment

Comment by andreyf

Because aif works with any expression, not just print. Granted, in a functional language like JS, one could say:

    ifNotNull(foo.getBar().getName(), function (it) { print it; });
but "function (it)" and all of the "().{}" are still blub. As PG points out on the arclanguage forums [1], an even simpler way of putting it is:

    (only.print foo!bar!name)
Which, without the Arc-specific syntax sugar, is:

    ((only print) ((foo 'bar) 'name))
So "only" is a modifier that makes a verb (function) happen only if its argument is truthy (think Python decorators).

Note to PG: the dot operator is undocumented, and f.g.h.3 does not at all what I expect - looks like it does (f g h 3), whereas I expected (f (g (h 3))), in the spirit of Python decorators.

1. http://arclanguage.org/item?id=9350

parent andreyf 17 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton