I wonder why they're called functors.
It's a pretty overloaded term. I haven't looked into the Cosmos semantics much, but since it's mentioned in the "logic programming" part of the language, I suspect it's referencing the Prolog sense of the term: http://www.cse.unsw.edu.au/~billw/prologdict.html#functor
An Opinionated Treatise on Cosmos, a New Programming Language
11–20 of 66 posts
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#12Re: An Opinionated Treatise on Cosmos, a New Programming Language
#13It's really neat that someone is trying to make logic programming accessible, but the introduction and the first fews sections are really offputting. There are lots of highly performant new languages competing for attention, and statements like "Today I want to talk about programming. It is interesting to note that I have solved it. Yes, I solved it." will drive a lot of the potential audience away. I recommend break…
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#14l = [1, 2] l = Cons(1, Cons(2, Cons)) Ah, my other car is a cdr. I almost longed for my lisp (scheme) days. I quickly recovered, though..
Your other CDR contains Cons. Which may just be a function.
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#15I beg to differ. You can definitely go wrong in more ways with Lua tables because they stand in for modules, arrays, and maps.
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#16Lemme tell you about TI-BASIC (for the TI-84). That stuff was the bee's knees. One day I wrote a really slow loop to translate whatever key was pressed into a number if the key corresponded to a button on the number pad. [1]
In JS the loop would look like
var output = -1,
codes = [103,92,93,94,82,83,84,72,73,74],
pressed = getKey();
for(var i=0;i
Way too complicated, way too slow for an interpreted game program on a 6MHz Z80. But TI-BASIC had some cool higher-order functions! It didn't even have to be a loop at that point, check out how succinct it became: var codes = [103,92,93,94,82,83,84,72,73,74],
pressed = getKey(),
digits = [0,1,2,3,4,5,6,7,8,9];
var output = sum((codes == pressed)*digits);
(Yes, this isn't "really TI-BASIC" but that stuff is a pain to type on a computer. Sorry.)How? `codes` is an array, which, when tested against a scalar, produces an array of 0 or 1 to indicate false or true. These, multiplied by digits, produce an array of 0 and a number that is pressed. The summation gets that number because adding by 0 just returns the number. (Also, getKey can't return more than one key at a time.) And because the loop happened inside the operators, the loop was run in assembly, which made it about 30x faster.
This is why I believe that TI-BASIC is the best programming language. (I don't, really. But I'm more believeable than the unexplained Functor malarkey and how it can somehow put me into outer space ;)
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#17And, as is often the case, it is impossible to have a universally beneficial compromise in programming language features. There are some things you simply cannot have if you don't lean strongly one way or the other, and you end up with a mediocre in-between with none of the benefits of either extreme. Case in point: type systems and the ability to compile to tight native machine code. In a dynamically typed/untyped language, you need to have multiple layers of indirection.
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#18Re: An Opinionated Treatise on Cosmos, a New Programming Language
#19A new programming language a day keeps the doctor away.
Re: An Opinionated Treatise on Cosmos, a New Programming Language
#20It looks like Oz [1] declarative variables could help implement a lot of this stuff. Essentially, its variables are pointers that can be assigned to only once. As such you can pass an unbound variable to a function and have it bound to produce a result. You can also do "unification" between two variables, meaning that it will try to make the two variables equal to each other. Typically, one or both of the two variabl…