Implicitly overwrite file content

I’m currently programming a tool for downloading stuff from the internet. For the user it is possible to specify a download folder where all downloaded files are stored.

Assume that the program realize that it should save the download to a file that already exists – how should it react.

Intuitively I would say that the program should come up with some kind of dialog asking the user whether it should replace the existing file, save the download to another file or …

However, due to the automatic execution it is NOT possible to ask the user what should be done (replace, use other file, log error, …).

So what should be done in such a case?

Greetings, quant

Safe to consider webapp user’s email as implicitly confirmed after a password reset?

In my system, a new user must confirm his email.

But there is an edge case:

  • he registers
  • does not confirm
  • forgets password, performs password reset (which involves a mail loop)

At that point I know his email works – so I’m inclined to reset his password, and then simply mark his email as “confirmed”.

Are there any risks I’ve not considered?

How to pass around global or local state implicitly

In my situation I have functions, some of which will use global state, some of which will use local state like the function scope or parent scope, others which use both.

So for example you might have stuff like this:

var MY_GLOBAL = 10 var GLOBAL_STATE = {}  function myfunction1(a) {   return a + myfunction2(a) }  function myfunction2(a) {   return a * MY_GLOBAL + this.parent.arguments[0] }  function myfunction3(k, v) {   return GLOBAL_STATE[k] = v } 

Say I have a 100 functions which all act on the global state. One thing I can do is pass it to every function:

function afunction(state, ...rest) { ... } 

But I’m not sure I want to do this as it would require removing the simplicity and clarity of the functions. I like the idea of having special global variables which you reference in the code. However, I don’t want to just be referencing random global variables.

So one solution I am sort of imagining is having the function definition include the global variable, only if it directly uses it. Then somehow it gets injected in or something. Then any subfunctions that use the global variable, they also get it injected in rather than passed down.

Basically the end goal is I think to not pollute all the functions with these at least 2 variables (global state, and local scope), yet still be able to use them in any function. Wondering what sorts of solutions exist for this. I tried to check out Haskell’s State Monad, but not being a Haskell programmer I don’t see how it works.

Thinking in terms of functional programming with mutable state, not OO programming. Basically like JavaScript.

Can I prove my legal age *implicitly* so that I can drink in the UK?

I hold Swede passport and I am traveling to UK this month. I’ve read (http://news.bbc.co.uk/2/hi/uk_news/6598867.stm) that legal age of drinking alcohol in UK is 16 to 18 depending on the type of beverage.

I am an undergraduate student and look about 18. Can I use my my university card (Swede uni) in place of my passport in bar entries. Since a typical university student is 18 or above so can my university card be as a proof of age, implicitly though?