Re: [web-nfc] non-Mime record should have a null mediaType (#441)

Looks good.

Out of curiosity, is there a particular reason you used `null` and not `undefined`?

I thought that when a variable or property is declared in WebIDL but not assigned in any algorithm in the spec, it should be `undefined` and not `null`.

At least on JS side, I find `undefined` more exact (in code), but both are falsy values and likely no one is going to be mislead to test the type of `mediaType` (which would be `object` if it was assigned  `null` and its `undefined` when `undefined`). 

I guess you use `null` because `mediaType` is nullable in WebIDL and you can use `nullptr` in C++.
However, I wonder why exactly are these (`mediaType`, `encoding` and `lang`) nullable in WebIDL, when they are the properties that are used only in certain cases depending on `recordType`, so they should be `undefined` when their use was not meant for.

Nevertheless, these are all strings and it makes sense to use `nullptr` for them in C++, so I guess it's easier for implementations if these are nullable in WebIDL and initialized to `null` in the algorithms?

No strong opinion here but I am interested if there is any other particular implementation reason for explicitly using `null`.

-- 
GitHub Notification of comment by zolkis
Please view or discuss this issue at https://github.com/w3c/web-nfc/pull/441#issuecomment-552328329 using your GitHub account

Received on Monday, 11 November 2019 07:39:26 UTC