Closed godind closed 11 months ago
What trouble do you see null
creating? In general it is a special value that indicates the absence of a real value and as such would be a good fit for this purpose.
null
and undefined
can create unforeseen interpretation side-effect for certain language, framework, libraries, etc. As an example, if you PUT value: undefined
against a meta property, the server will deleted the key, but this is actually an unexpected side effect - did we think undefined would delete? Will null do the same thing? I think it's a risk not worth taking... but I'm no expert on the subject.
Back to the proposition at hand; timeout: 0
is a clear and affirmative statement eg. we have a timeout and it's value is never. timeout: null
means timeout value has no reference - not as clear a statement, regardless of the fact that the null
keyword might be sensitive or not.
The undefined value is a primitive value used when a variable has not been assigned a value. The null value is a primitive value that represents the null, empty, or non-existent reference
undefined
: firstly it can not be represented in JSON that most of current SK depends on, secondly a client needs to handle the situation that a meta property is "undefined", which in practise is that it is missing / non existentnull
is already used in Signal K and the proposed usage is imho very well in line with that, to me it would seeing a null value would be "timeout is explicitly missing, not just absent in the data, so don't apply a timeout for this path"PS. I edited the title so that it describes the use case instead of prescribing a solution.
Make sense. Thanks!
@tkurki Question: do you think anything needs to be modified in SK to use null
string as a value, or could this cause issue with the current implementation?
Not pertinent anymore.
Timeout being potentially a critical meta value, we need a way to enforce 'no timeout'.
Current State
Proposition
Have Timeout key with value of 0
timeout: 0
interpreted as 'Infinity/No timeout. Note that valuesnull
andundefined
have 'special' meanings and can cause trouble.This would means:
Not only does it make numerical sense, it's also easier the handle and validate with Form Controls and eliminates the need to delete the key to have no expiration.