Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Who needs functional programming...

Name: Anonymous 2015-07-27 20:45

... when C has function pointers?

Name: Anonymous 2015-08-01 6:00

>>34
JavaScript and PHP are strongly typed.
2 is a number and "2" is a string. Bash, which is "stringly typed" (statically and dynamically unityped), treats them both as strings. The + operator does different things depending on the dynamic types of its operands. If these languages happened to use different symbols for each case of the + and == operators (and all the other operators), it would still be possible to write your own function that checks the dynamic types of its arguments and does the same thing as JavaScript's and PHP's built-ins.
You're caught up on the "built-in" aspects of these operators. In Scheme, + is just a procedure. It can be replaced by a procedure that has (as close as possible to) JavaScript semantics.
Think of + as someIdiotsIdeaOfWhatAdditionMeans. You can write your own addNumbers and concatenateStrings in JavaScript if you like and they can throw exceptions when values of the wrong types are passed in. You just can't give them the + syntax.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List