It does feel like Perl, but, what if there was a keyword after the symbol? It'd be more readable and not Perl-ish, but, it wouldn't confuse the parser(or at least I wouldn't think it would).

Antoine Pitrou <solipsis@pitrou.net> wrote:
Le Sat, 3 Aug 2013 01:46:37 +1000,
Nick Coghlan <ncoghlan@gmail.com> a
écrit :

In this context, you usually have one or
two callbacks (two in Twisted-style programming: one for success,
one for failure), passed positionally to a consuming function:

loop.create_connection((host, port), @cb, @eb) where:
def cb(sock):
# Do something with socket
def eb(exc):
logging.exception(
"Failed connecting to %s:%s", host, port)

We can't use 'where' because we know it conflicts with the SQL sense
of the term in too many APIs. We're reasonably sure we can get away
with "given" without too much conflict, though.

How about reusing "with"? There's no ambiguity with context managers
since the syntactic context is different.

Using "@" as the marker character is also problematic, since the
following degenerate case will probably confuse the parser (due to it
looking too much like a decorator clause):

@something() given:
...

No, that would simply be forbidden. In this proposal, "@" can only mark
names of parameters in function calls. We already reuse "*" and "**"
for a specific meaning in front of function call parameters, so there's
a precedent for such polysemy.

I liked the notion of "?" as suggesting doubt and uncertainty - an
element of "leave this undefined for now, we'll fill it in later".

I don't really like it :-) "?" has other meanings traditionally: as part
of the ternary operator in C-like languages (many of them), as a
wildcard character in pattern matching languages, as a marker of
optional matchers in regular expressions.

Also, I really don't like the idea that "?" represents a full-blown
object with attribute access capabilities and whatnot. It smells too
much like Perl-style (Ruby-style?) magic variables. My proposal is more
limited: it's a syntactic addition, but it doesn't create new runtime
objects or types.

Regards

Antoine.




Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.