The goal of a Haskell compiler is to take your code and spit out an executable. That executable is in fact the value named “Main.main,” which must be of the in-Haskell type (translating to English) “a program which produces nothing.” In the source code you are constantly juggling values of type “a program which produces ____” and linking them together with the in-built methods, to get to this point, and the compiler just takes one of these things, based on a naming convention, and spits it out to the filesystem. And I think it got this convention because it was really handy how C similarly used a well-known name to specify its entry point into the source file.
The difference is then that Pointless does not have a type restriction on what “main” can be and instead of “saving to the filesystem” it dumps to stdout. Presumably with the right sort of metaprogramming attitude one could do what Haskell does in Pointless, maybe—when output is a program it could maybe spit out a compiled executable to stdout and you would redirect it to a disk location and set its executable permission manually.
main :: IO Int
main = print "10" >> pure 10
the return value is just ignored when it's actually invoked as an executable (but can be used if invoked eg. in the repl, or if main is also called from somewhere deeper in the code).GNU Bash has a magic variable RANDOM that produces random numbers. Assignments to it appear to be ignored.
In Algol, the name of the enclosing function acts as a variable to which you assign in order to produce the return value. For instance, see the assignment to B in the nested function here;
Assignments are used to seed¹ the random number generator². This isn't limited to just bash/zsh/etc, it is intrinsic to the process of generating random numbers. Being aware of this is useful as it poses a significant footgun. The /dev/random docs³ provide a nice overview of how it is often handled on various systems at the OS level to deal with reboots.
An example of the fun that this can produce can be seen in a Debian bug⁴, running a script that uses subshells and RANDOM with bash will behave very differently when using zsh. In this instance you have to hope that subshells aren't being used to create unique logs as an example.
1. https://en.m.wikipedia.org/wiki/Random_seed
2. https://en.m.wikipedia.org/wiki/Random_number_generator
BASIC's version of $RANDOM is RND(x), and I remember that the sign of the argument was the most important thing. Negative values seeded the PRNG and any positive argument got you the next random number. Some later dialects had a RANDOMIZE statement.
The funny thing is BASIC also had a couple functions that took input variables, but didn't do anything with them, like POS() and FRE(). I think FRE's argument may have been significant on a couple BASICs.
I used it to write a go-moku (5-in-a-row) playing program in an AI course and got an A when it beat the professor.
I recognized right away that the span and break pattern-matching operators of Snobol must be the inspiration behind C library names like strspn and strpbrk.
[1]: http://mozart2.org/
Having read the documentation, I don't see any difference other than whether non-string keys are allowed, and as a result the syntax for value access (`obj.key` vs `map["key"]`).
And one of the things I've been wondering about with regard to language design is why more languages don't take a Clojure-like approach of fully merging the concept of "object" and "map", since they seem to cover so much of the same ground.
getSignZero(n) = if {
n > 0 then Positive
n < 0 then Negative
else Zero
}to follow up on this, does this mean that Pointless actually allows inheritance and polymorphic dispatch? Because clearly functions are first class, so they could easily be values in a map just like they could live in an object.
JS now has a dedicated Map type to work as a proper dictionary.
Just the inheritance.
compose(a, b) = x => a(b(x))
It's indeed more pointless than Haskell:-)Btw, the `x' in that definition is the `point' from which the name originates.
[0] https://blog.ploeh.dk/2015/04/13/less-is-more-language-featu...