3 ms·
We might as well chuck away "def" for a function signature. When I started learning python way back, this particular aspect of Python was an eye-sore. Why would
by fermienrico 6y ago
We might as well chuck away "def" for a function signature. When I started learning python way back, this particular aspect of Python was an eye-sore. Why wouldn't they use any one of these: func, function, fun, etc. or just like C, no need for a word. void foo(){} is already sufficient structure to indicate that its a function.
- pansa2 6y agoIn the absence of a return type, and with an LL(1) parser, there needs to be a keyword to indicate the start of a function definition. `def` is a little unusual, but it's also used by Ruby. I once designed a Python-like language and used `function`, because the language made a distinction between `function`s and `method`s.
- zelphirkalt 6y agoAnd lispy langs mostly use "define…" keywords.
- dependenttypes 6y agodoing simply funname(args): would work fine
- pansa2 6y agoHow would the parser know that’s a function definition and not a function call?
- deleted 6y ago[deleted]
- dependenttypes 6y agoby the :
- pansa2 6y agoThat's too late. The parser needs to know whether it's looking at a definition or a call before that - for example, to know whether to parse "args" as a `parameters` or an `arglist` [0]. [0] https://docs.python.org/3/reference/grammar.html https://docs.python.org/3/reference/grammar.html
- shakna 6y agoHere's a code snippet using SRFI 49, for Scheme. (A 2003 formalisation for a macro system that had been rocking around for a few decades, for a very old Lisp): define fac x if = x 0 1 * x fac - x 1 Python's keywords are sometimes shorter, but they are familiar to most Lispers, which some of the founders were.