w3c / web-share

Web API proposal for sharing data from a web page
https://www.w3.org/TR/web-share/
Other
353 stars 65 forks source link

Base isn't needed in main branch of algorithm #259

Closed chaals closed 1 year ago

chaals commented 1 year ago

There's no need for calculating the base unless you're going to use it. Moving it will simplify the algorithm, especially for "naive" implementations that just follow the spec instructions.

marcoscaceres commented 1 year ago

Actually, I had to revert #260. The |base| is actually used by validate share data, so it's declared in the right place.

chaals commented 1 year ago

It's not completely obvious that the variables created in the course of executing a particular algorithm are expected to be generally available (if this were real code, you'd have a way of declaring a "global" variable differently from one that is locally scoped, but since it isn't real code the assumptions underlying it need pretty clear documentation IMHO).

So it makes more sense (to me) to add the same line (again, if needed because there is indeed a URL) to validate share data algorithm too. An alternative approach would be is to explicitly point to where those are declared in the other algorithm, and another would be to explicitly state that variables are global in scope. That seems ugly to my particular sense of programming aesthetics. Which doesn't stop me doing it in practice...