What is a primitive?(mlochbaum.github.io) |
What is a primitive?(mlochbaum.github.io) |
Although, if you're here... there's a more focused question that's been bothering me because I feel it should appear in category theory but can't locate it. There's an operation I call Under that I partially introduce at [1] and define at [2]. The idea is that given functions F and G, where G manipulates things in some overall framework like arrays, F⌾G is a function so that F⌾G x is as similar as possible to x while satisfying (G F⌾G x) = G x. Maybe it's a sort of pullback along a functor G. Does that look familiar?
[0] https://mlochbaum.github.io/BQN/doc/replicate.html
[1] https://mlochbaum.github.io/BQN/tutorial/variable.html#modif...
[2] https://mlochbaum.github.io/BQN/spec/inferred.html#under
[0] https://github.com/mlochbaum/BQN/blob/master/md.bqn
[1] https://raw.githubusercontent.com/mlochbaum/BQN/master/comme...
Some edge cases: literal ranges would be primitives, because their ast is represented (in Haskell) as "Range Int Int". Ranges which take values wouldn't be primitives, because their ast is represented as "Range expr expr"
In contrast, primitives are the starting point for programming, particularly tacit programming ("point-free" in Haskell). While the two names have a similar meaning, I think it fits a little better to call values that are indivisible from a particular perspective "atoms" and the ones that are meant to really be fundamental "primitives".
The languages i’ve written are pretty basic. e.g. the data types might be
- Number - String - True, false, null - Array of values - Record of fields (key + value) - Variant of options (key + value)
So the distinction is clearer.
Is it pronounced "bacon"?
Like APL versus "apple", the normal pronunciation is to spell it out B-Q-N, but it may be pronounced "bacon" if one wishes to establish a double-entendre. So a BQN user is a BQNator, pronounced like https://en.wikipedia.org/wiki/Baconator.
I can think of various langages where string is not a built-in, but i can’t think of a langage where string is not some sort of sequence, not just in its implementation but in its interface.
The definition also breaks down quickly e.g. is a complex a primitive? If not because they have real and imaginary parts, why are floats which have a mantissa and an exponent? And what about functions? What even is a child? Are value-less sum types primitives but valued ones not?
More importantly, how does it matter? What does the distinction you draw provide that is useful?
But I could very well be totally off.
Most of my problem seems to be that the definition of Under really depends on applying functions to particular arguments. So it's hard to see how to set up categories to capture the necessary properties. But I don't know if it's actually hard to do or just confusing.