JohnEarnest/Decker

Idea: numbers default to identity

mnemnion opened this issue · 1 comments

I really like the idea of a nil-free dynamic type system, but numbers defaulting to zero didn't sit right with me.

It makes sense for: indexing, addition, subtraction. Concatenation shouldn't matter, because the void resolves to the empty string. But it isn't great for exponentiation, multiplication, and for division: terrible.

The solution being, for the last three contexts to resolve to 1. That would mean a missing number does nothing in the calculation, wherever found.

Just a thought! Look forward to seeing where this project goes.

Thank you for the suggestion.

I have given this some thought, and while I agree that it might be convenient in some situations, I do not see a way to implement this which does not have complex and potentially much more surprising implications. It would not be a trivial matter for undefined variable fetches to evaluate to a different identity value depending upon the operator consuming them, especially when fetching and consuming are not immediately adjacent. Really the only mechanism I can see working would be to introduce an actual non-numeric nil type which is always coerced when consumed, but that also has far-reaching consequences.

At this time I do not think I will be making a change along these lines.