forked from mirrors/jj
1c0bde1a2b
A lambda expression will be allowed only in .map() operation. The syntax is borrowed from Rust closure. In Mercurial, a map operation is implemented by context substitution. For example, 'parents % "{node}"' prints parents[i].node for each. There are two major problems: 1. the top-level context cannot be referred from the inner map expression. 2. context of different types inserts arbitrarily-named keywords (e.g. a dict type inserts "{key}" and "{value}", but how we could know.) These issues should be avoided by using explicitly named parameters. parents.map(|parent| parent.commit_id ++ " " ++ commit_id) ^^^^^^^^^ global keyword A downside is that we can't reuse template fragment in map expression. Suppose we have -T commit_summary, -T 'parents.map(commit_summary)' doesn't work. # only usable as a top-level template 'commit_summary' = 'commit_id.short() ++ " " ++ description.first_line()' Another problem is that a lambda expression might be confused with an alias function. # .map(f) doesn't work, but .map(g) does 'f(x)' = 'x' 'g' = '|x| x' |
||
---|---|---|
.. | ||
common | ||
test_abandon_command.rs | ||
test_alias.rs | ||
test_branch_command.rs | ||
test_cat_command.rs | ||
test_checkout.rs | ||
test_commit_command.rs | ||
test_commit_template.rs | ||
test_concurrent_operations.rs | ||
test_config_command.rs | ||
test_debug_command.rs | ||
test_describe_command.rs | ||
test_diff_command.rs | ||
test_diffedit_command.rs | ||
test_duplicate_command.rs | ||
test_edit_command.rs | ||
test_git_clone.rs | ||
test_git_colocated.rs | ||
test_git_fetch.rs | ||
test_git_import_export.rs | ||
test_git_push.rs | ||
test_git_remotes.rs | ||
test_gitignores.rs | ||
test_global_opts.rs | ||
test_init_command.rs | ||
test_interdiff_command.rs | ||
test_log_command.rs | ||
test_move_command.rs | ||
test_new_command.rs | ||
test_obslog_command.rs | ||
test_operations.rs | ||
test_rebase_command.rs | ||
test_resolve_command.rs | ||
test_restore_command.rs | ||
test_revset_output.rs | ||
test_show_command.rs | ||
test_sparse_command.rs | ||
test_split_command.rs | ||
test_squash_command.rs | ||
test_status_command.rs | ||
test_support_command.rs | ||
test_templater.rs | ||
test_undo.rs | ||
test_unsquash_command.rs | ||
test_untrack_command.rs | ||
test_workspaces.rs |