math - Right behavior for variable-arity sum function -


i'm defining variable-arity sum function toy language. seems natural me allow called without arguments , return 0, real languages (and implementations) disagree among themselves.

is there use-case returning 0 less correct throwing exception?

mathematically speaking, empty sum (the sum of no numbers) defined zero. mathematically correct, returning 0 seems proper choice here. throwing exception in case potentially complicate use of function, since have sure guard each call try/catch in case provide 0 arguments somehow.

hope helps!


Comments

Popular posts from this blog

Glib GIOChannel -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -

python - Obscure curses error message when creating a sub window -