Skip to content

Conditional (Computer Programming)

A language construct selects a program branch or value by testing a condition and evaluating the selected alternative.

Version
v1 · 2026-10-03 · History
Domain-specific #
13077
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomain
Programming Language Semantics → Computer Science & Software Engineering
Aliases
Programming Conditional

Core Idea

A conditional evaluates a test and selects which program branch runs or which expression yields a value. In ordinary if and conditional-expression constructs, an unselected branch is skipped. This lets a test both choose behavior and guard operations that would be invalid in the other case.[ref-5c6c1ff2bd9f][ref-9e9166a51882]

Scope of Application

Programming languages use conditionals in statements and expressions. The pattern has a test, alternatives and a language-defined selection rule. A statement chooses a continuation; an expression yields the chosen value. Details vary by language: C permits an if without else, while Racket's if expression requires both alternatives.[ref-5c6c1ff2bd9f][ref-83e8408d55e0]

Clarity

It is not logical material implication or a generic decision. It is not always a Boolean-typed test: C interprets zero and nonzero scalar results. A conditional expression can have side effects, and replacing it with an eager function may evaluate a branch that the original would skip.[ref-5c6c1ff2bd9f][ref-9e9166a51882]

Manages Complexity

A C if/else chooses one action; C's condition ? value1 : value2 selects an expression's value; Racket's (if test then else) selects one required result branch. Each localizes a choice so downstream code need not treat both alternatives as simultaneously executed.[ref-5c6c1ff2bd9f][ref-9e9166a51882][^ref-83e8408d55e0]

Abstract Reasoning

To reason about a conditional, determine how the test is interpreted, which alternative is evaluated, and what continuation or value results. Then check whether the unselected branch is skipped under the language's actual rules; an eager substitute may change behavior.

Knowledge Transfer

Test-and-branch selection recurs across languages, but their truth conversion, evaluation order, optional branches and result typing do not transfer automatically. The receiving language's specification controls those details. Live Selection is the strict broader pattern; this construct adds operational branch evaluation.

[^ref-5c6c1ff2bd9f]: Microsoft Learn, C if Statement. [^ref-9e9166a51882]: Microsoft Learn, C Conditional-Expression Operator. [^ref-83e8408d55e0]: Racket, Conditionals.

Relationships to Other Abstractions

Local relationship map for Conditional (Computer Programming)Parents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Conditional (ComputerProgramming)DOMAINPrime abstraction: Selection — is a kind ofSelectionPRIME

Current abstraction Conditional (Computer Programming) Domain-specific

Parents (1) — more general patterns this builds on

  • Conditional (Computer Programming) is a kind of Selection Prime

    A programming conditional selects which available branch or value passes according to a test.

Hierarchy path (1) — routes to 1 parentless root

  • Conditional (Computer Programming) → Selection

Neighborhood in Abstraction Space

Conditional (Computer Programming) sits in a sparse region of the domain-specific corpus (68th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Logical Inference, Modality & Conditional Structures (27 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-10-08