iflike
Iflike is a term used in programming and software design discussions to describe a conditional construct that combines branching logic with pattern-based matching. It is not an official language feature in major programming languages, but rather a conceptual pattern used in examples and some domain-specific languages.
Definition: In an iflike construct, a value is tested against a pattern; if the value matches, a
Typical syntax (illustrative):
- iflike x matches 'prefix*' then do A; else iflike x matches '*suffix' then do B; else do
- In more functional syntax: case x of { _ iflike 'prefix*' -> A; _ iflike '*suffix' -> B; _ -> C }.
- iflike(name, 'A%') then greeting = 'starts with A' else greeting = 'not starting with A'
- Or in functional style: match name with
| Like('A%') -> "starts with A"
| Like('%son') -> "ends with son"
| _ -> "other"
Relationship to existing concepts: The concept overlaps with pattern matching features found in languages such as
History and usage: The term appears mainly in informal discussions and design blogs to describe a
Critique: Proponents say it can clarify intent and reduce boilerplate by centralizing pattern-based tests. Critics note
See also: Pattern matching, Guard, Switch statement, Like operator, Fuzzy matching, Regex.
---