Skip to content

Commit

Permalink
nodes.lkt: avoid the "if a then b else {...}.do(...)" pattern
Browse files Browse the repository at this point in the history
The ".do(...)" part unambiguously belongs to the "else" branch, but it
is clearer if the .do(...) is inside the block.
  • Loading branch information
pmderodat committed Jul 10, 2024
1 parent 9aa599e commit d18aeb2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ada/nodes.lkt
Original file line number Diff line number Diff line change
Expand Up @@ -8112,23 +8112,25 @@ class BaseSubpBody: Body {
s"__nextpart", node, dest_env=node.previous_part_env_name().do(
(name) => DesignatedEnv(
kind=DesignatedEnvKind.named_env, env_name=name, direct_env=null[LexicalEnv]
), default_val=# Due to overloading, it's not possible to find the previous
),
# Due to overloading, it's not possible to find the previous
# part of a non-library item subprogram at this stage if it
# has a top level env name (e.g. a subprogram declared in a
# package), since its body could be defined in another unit.
if node.has_top_level_env_name() then DesignatedEnv(
default_val=if node.has_top_level_env_name() then DesignatedEnv(
kind=DesignatedEnvKind.none, env_name=null[Symbol], direct_env=null[LexicalEnv]
) else {
bind env = node.default_initial_env();

self.body_scope(follow_private=false, force_decl=true)
}.do(
(non_null_env) => DesignatedEnv(
kind=DesignatedEnvKind.direct_env, env_name=null[Symbol], direct_env=non_null_env
), default_val=DesignatedEnv(
kind=DesignatedEnvKind.current_env, env_name=null[Symbol], direct_env=null[LexicalEnv]
self.body_scope(follow_private=false, force_decl=true).do(
(non_null_env) => DesignatedEnv(
kind=DesignatedEnvKind.direct_env, env_name=null[Symbol], direct_env=non_null_env
),
default_val=DesignatedEnv(
kind=DesignatedEnvKind.current_env, env_name=null[Symbol], direct_env=null[LexicalEnv]
)
)
)
}
)
)
do(node.populate_dependent_units())
Expand Down

0 comments on commit d18aeb2

Please sign in to comment.