2026-07-22 16:08 UTC
@numeredevs@fosstodon.org @jwildeboer@social.wildeboer.net oh this is the kinds of discussion I really enjoy, and you're making a good point.
The default behaviour comes from APL, which fills will the 'fill value' of the array itself. It's kind of complicated, but generally boils down to either going with 0 or a space, for numeric or character stays respectively. This was important back in the early days of APL which didn't support nested arrays.
Now Kap improves on this (in my opinion) by simply having a single full value for functions that need it. This behaviour is similar to what J does. This value is 0 by default, but you can add a specification to the function call that tells the function to use a different fill value. So you could just specify null (or even a special error value which will raise an error when accessed).
So adapting your suggestion, Kap should use null or the error value as a default fill value. This is actually a pretty good idea.
If this was only for the disclose function (which converts a nested array into an array with one dimension higher) then I'd make this chance right now.
The problem is that the fill feature is used in other cases too, for example when taking n elements from an array of size m where n>m. The fact that it fills with 0 is commonly used in various algorithms.
If you're interested in the history of the full value in various array languages, there is an aplwiki page for it: http://aplwiki.com/wiki/Fill_element
The above page uses the term mix to describe the operation that Kap refers to as disclose.
Replies (1)
-
@numeredevs@fosstodon.org 2026-07-22 19:14
@loke@functional.cafe @jwildeboer@social.wildeboer.net It's so interesting that you share the same issues with the (as we call it) default values of arrays. We had a time, when we set it to 0, then we made it depending on the operation and now we have a "neutral value", which looks like "void" ("null" n APL, as I understand it), but actually is considered to be neutral in every operation. And still, sometimes it does silly things. It is so hard to find a good compromise that works in all situations