w3c/web-share

Base isn't needed in main branch of algorithm

Closed this issue · 2 comments

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.

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

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...