
> Critics, including language designers,https://en.wikipedia.org/wiki/Expression-oriented_programming_language#cite_note-1\|[1] blame expression-orientation for an entire class of <https://en.wikipedia.org/wiki/Software_bug|programming mistakes> wherein a programmer accidentally codes an https://en.wikipedia.org/wiki/Assignment_(computer_science)\|assignment expression, which replaces a variable with an expression rather than testing it for https://en.wikipedia.org/wiki/Equality_(relational_operator)\|equality with that expression. > The designers of https://en.wikipedia.org/wiki/Ada_(programming_language)\|Ada and https://en.wikipedia.org/wiki/Java_(programming_language)\|Java prevent this type of mistake by restricting <https://en.wikipedia.org/wiki/Conditional_(computer_programming)|control expressions> to those that evaluate strictly to the <https://en.wikipedia.org/wiki/Boolean_data_type|boolean data type>.https://en.wikipedia.org/wiki/Expression-oriented_programming_language#cite_note-2\|[2]https://en.wikipedia.org/wiki/Expression-oriented_programming_language#cite_note-3\|[3] From https://en.wikipedia.org/wiki/Expression-oriented_programming_language

The first sentence doesn’t make sense. And the reference [1] is an advice for Java.
Anyone interested in writing repairing this?

Hm. Hilariously, since set!
-> #<void>
, and (not (not (void)))
-> #t
(i.e., #<void>
is not #false
)_,_ the following function always returns 1 regardless of its inputs (e.g., #t
and #f
) (define (f start end)
(define a start)
(if (set! a end)
1
2))
So while the criticised assignment-expression-as-conditional is possible in Racket, it’s behavior is not altogether surprising if you know what set!
and if
do. It’s also hard to confuse with equality comparisons given the completely different names (=
, eq?
, etc.)

The phrase “replaces a variable with an expression” bothers me.

Maybe somebody forgot the word “mutates”?

actually, it’s more simple than that in schemes. anything that’s not #f
is considered true.

and it is weird that someone wrote that on wikipedia. obviously, the notation used for assignment and comparison isn’t a problem specific to expression oriented language.

yeah, I think it’s mostly about surface syntax confusion between =
and ==
. I think with :=
for assignment and ==
for comparison (and make =
an error), the confusion would go away.

In F# it is <-
for assignment and =
for equality testing, which seems to work pretty well on the whole.

But I mean, that’s a classic “six of one, half a dozen of the other” situation :slightly_smiling_face:

So, there was a really important paragraph that was removed in 2016.

Or we can pull out R where assignment can be done with =
, <-
, or ->
. Whoever thought that was a good idea should have their programming license revoked. :yum:

> (equal? 1 #t)
#f

:neutral_face:

Hilarious that Python is mentioned; I would definitely not call it expression-oriented.

Any way to see why it was removed and/or try to get it back?

It would start with finding a reference to back up the removed claim (see https://twitter.com/sorawee_p/status/1523481218070634496).

I think it might even be less expression oriented than C