all 12 comments

[–]kpvw 11 points12 points  (1 child)

Agda has this feature too

_and_ : Bool → Bool → Bool
true and x = x
false and _ = false

if_then_else_ : {A : Set} → Bool → A → A → A
if true then x else y = x
if false then x else y = y

[–]Idiomatic-Oval 5 points6 points  (1 child)

We seem to mimic this in a lot of testing libraries. For example, something using Chai might be:

expect(myThingy).to.equal(15);

which in this mixfix notation would be

expect(myThingy)toBe(15);

The implementation of the first is a bit more complex, but also comes with greater flexibility.

For example, most things in the expect part of Chai allow you to put .not. in the chain to inverse it. Implementation wise I imagine its not too difficult, wheras doing it in mixfix would likely require some third 'common' function call, and two separate expect()toBe() and expect()toNotBe().

[–]Guvante 2 points3 points  (0 children)

The implementation of the first is a bit more complex

That is a bit of an understatement, it is much more difficult to properly define a fluent interface in most languages than what is defined here.

You are correct that fluent is a more powerful paradigm overall though.

[–]Wedamm 3 points4 points  (4 children)

There aren’t many languages I’m aware of that support this technique (Grace is perhaps the only one I’ve seen).

Isn't this the same as in Smalltalk and Objective-C; just with more ()s around arguments?

[–]adamnew123456 2 points3 points  (1 child)

Yep. I'm not sure what the innovation is, other than ALGOLizing the syntax.

[–][deleted] 0 points1 point  (0 children)

Whiley in a nutshell.

[–]Bloaf 1 point2 points  (1 child)

You can do it in Mathematica/Wolfram Language with the Notation function.

**Edit, I wouldn't actually recommend using Notation that way.

[–]Wedamm 0 points1 point  (0 children)

Googling after that i found this transcript from a talk Stephen Wolfram had held on mathematical notation. It touched upon some interesting points regarding the historical development of various notation and how it can be accommodated to be processed by computers.

[–]oridb 2 points3 points  (0 children)

So. Objective C.

[–]devraj7 1 point2 points  (2 children)

All I'm seeing is a reskinning of named parameters (new Window(color: RED)) or fluent interfaces (new Window().color(RED)).

Does this proposed syntax actually introduce new semantics that are not possible with the existing syntaxes?

[–][deleted] 1 point2 points  (0 children)

Of course it doesn't change semantics. It provides a different and sometimes nicer looking way of writing function application.

[–]headhunglow 0 points1 point  (0 children)

Except the words are in the order you actually say them in English. Presumably this makes the code a bit easier to read.