
On Sun, Apr 19, 2020 at 02:34:35PM -0400, Eric V. Smith wrote:
I'd be only -0.5 on any proposal from this thread (as opposed to -1000 as I am now) if it were more general purpose than just function calls. [...] My point is: We already have a way to pass the items in a dictionary as keyword args: let's not invent another one. Instead, let's focus on a general purpose way of creating a dictionary that meets the requirements of being able to be passed as keyword args. That way we'd me making the language more expressive beyond just function calls.
Good point. Maybe we should step back and look at the bigger picture and ask what we're fundamentally trying to do. And that, it seems to me, is solve a problem that beginners often ask: "How do I get the name of a variable?" The answer is, in general, you can't. But what if we could? In low-level languages like C and Pascal, there are usually "address of" unary operators. Would it solve the problem if we had a "name of" operator? Let's call it `$` just for something to call it. {'name': name} {$name: name} Well, that saves us a mere one character. In a function call: func(arg, $name=name) and that *costs* us an unnecessary character, if it even worked, which it probably wouldn't. What if it expanded to name=value? {'name': name} {$name} Hmm, that's terser, but now it looks like a set. If we changed the dollar sign to a colon, we come back to Andrew's suggestion. Maybe I've stepped back too far. Sometimes we can overgeneralise. But either way, it's good food for thought. -- Steven