5 ms·
One of those functions is to consume nothing and returns their (the programmer's) current age. This is - or at least might be - ambiguous. Current age as of im
by danbruc 9y ago
One of those functions is to consume nothing and returns their (the programmer's) current age.
This is - or at least might be - ambiguous. Current age as of implementation time or current age as of function invocation time? And while a result in whole years is a pretty natural and obvious choice for the age of a person in absence of an explicit requirement, it is certainly not the only sensible choice.
- bonesss 9y agoI'd argue it's not ambiguous: current age would have to be a function of invocation time, while "age at time of writing the function" would be a constant. Expressing "age" in whole years is acceptable in English, but using a decimal would be highly defensible. That's an issue of grading though.
- danbruc 9y agoIf we were talking about pure functions, I would certainly agree, but in Python it would of course be perfectly fine and not unusual to have an impure function implicitly depending on the current time. Obviously assuming »consume nothing« only refers to the parameters of the function, so this too could be less ambiguous.
- nothis 9y agoYea, that would have stumped me, expecting a trick/trap. What if my birthday is tomorrow? By the time my teacher checks it, it's wrong. "Your birth year" would have prevented that. This is a problem I have with certain parts of computer science and math education. Everything is encouraged to be exact, then, suddenly, variable names are used inconsistently, niche cases are ignored arbitrarily and explained with essentially referring to "common sense".
- bonesss 9y agoIsn't that more or less what happens in the real world? Software engineering is all about mapping dirty nuance to formal systems.
- nothis 9y agoBut general purpose education isn’t „the real world“. I think the opposite argument is often made to justify teaching theory when it doesn’t seem to have many real world applications.
- acbart 8y agoIt's graded immediately (automatically), so there wouldn't be any issues. Further, the text of the problem makes it clear that I'm not actually going to check their age - they can return any valid number (although it does check >0 and <100, perhaps discriminatorily). It would be a little invasive to their privacy otherwise, I think.