Am 20.02.22 um 16:48 schrieb Python:
Abdur-Rahmaan Janhangeer wrote:
Greetings list.
Out of curiosity, why doesn't Python accept
def ():
return '---'
()
Where the function name is ''?
For the same reason an empty sequence of characters cannot
be a variable name. Do you know any language (or formal
theory) that allows that?
Tcl allows that:
Main console display active (Tcl8.6.9 / Tk8.6.9)
(CDEF) 49 % set "" Hallo
Hallo
(CDEF) 50 % puts ${}
Hallo
(CDEF) 51 % proc "" {} { puts "I'm empty" }
(CDEF) 52 % ""
I'm empty
(CDEF) 53 %
Any string can be a variable or command name, only :: is special as a
namespace separator.
This only works because of the sparse syntax; to retrieve a variable's
content, $ is used. For "strange" names quoting is required, therefore I
had to use "" in the example.
It's a different matter how useful this actually is. One of the object
systems in Tcl uses the empty variable to represent "self" as an array,
so that you can write $(prop) for self.prop as it is in Python.
Christian
--
https://mail.python.org/mailman/listinfo/python-list