Expression problem: Difference between revisions

Content deleted Content added
ce
small clarification
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{Short description|Data abstraction problem in programming languages}}
The '''expression problem''' is a challenging problem in [[programming language]]s that concerns the extensibility and modularity of statically typed data abstractions. The goal is to define a data abstraction that is extensible both in its representations and its behaviors, where one can add new representations and new behaviors to the data abstraction, without recompiling existing code, and while retaining static type safety (e.g., no casts). The statement of the problem exposes deficiencies in [[programming paradigm]]s and [[programming language]]s,. andPhilip {{as of|2023|lc=y}} is still considered unsolvedWadler,{{citation needed|date=Octoberone 2023}}of althoughthe there are many proposed solutions.{{citation needed|reason=feels misleading as if there is some buzzco-authors of research interest or activityHaskell, whereashas in fact most oforiginated the references are from 30 years ago|date=October 2023}}term.
 
== History ==
Line 113:
|publisher = Cambridge University Press
|doi = 10.1017/S0956796808006758
|doi-broken-date = 4 June 2025
|s2cid = 21038598
|doi-access = free
Line 195 ⟶ 194:
</syntaxhighlight>
 
However, if we wish to add a new function over the type (a new method in C# terminology), for example to pretty print an expression, we have to change the {{code|IEvalExp}} interface and then modify all the classes that implement the interface. Another possibility is to create a new interface that extends the {{code|IEvalExp}} interface and then create sub-types for {{code|Lit}}, {{code|Add}} and {{code|Mult}} classes, but the expression returned in {{code|ExampleOne.AddOneAndTwo()}} has already been compiled so we will not be able to use the new function over the old type. The problem is reversed in functional programming languages like [[F Sharp (programming language)|F#]] where it is easy to add a function over a given type, but extending or adding types is difficult.
 
=== Problem solution using object algebra ===