|
|
|
|
|
by mckinney
1432 days ago
|
|
Ha! I implemented "concatenative" programming for Java as Binding [1] (or Unit) expressions, but had no idea. Seriously, never came across that term before this post. The idea with binding expressions is the type of expression A and the type of expression B implement "reactions" with one another in order to form a binding expression when they are lexically adjacent. 65 mph The type of `mph` defines a post reaction method with the type of `65` as an argument that results in type Rate. As I understand it this is concatenative, right? Another example: Money payment = 1.5M USD; There are tons of these. Concatenative programming in general feels like it should have a more prominent place in mainstream languages. Just my take. [1] https://github.com/manifold-systems/manifold/tree/master/man... |
|
1.5 USD = 1.5 * USD
65 mph = 65 * mile / hour
you can then use simple algebra to solve unit conversion and many other common deductive reasoning questions ("how many miles per gallon...?"), relying on the units to guide you to the solution.
There's probably a name for this, and it is indeed built into the SI notation (km/h vs mph).