
On Oct 1, 2015, at 14:12, Random832 <random832@fastmail.com> wrote:
On Thu, Oct 1, 2015, at 16:57, Ron Adam wrote: And to go out on a limb... ;-)
Another possibility is to have a *special magic callable* that when called skips the argument evaluation and returns None.
That's dangerous talk indeed. Special magic callables are Lisp territory. ;)
Despite the smiley at the end, I think that second sentence is exactly the issue here. This is basically fexprs, with the same pros and cons. The language doesn't have to provide new short-circuiting operators like if-else or ?? or other kinds of flow-control expressions because the end user can write them himself easily. On the other hand, because the end user can write flow-control expressions himself, every project ends up being written in a similar but semantically different language. (Of course hardcore Lisp advocates claim that con is also a pro: it means you can spend the first 80% of a project building up a language that makes the application trivial, and the last 20% coding and debugging the application. Sure, anyone who wasn't involved in that first 80% is never going to be able to understand the code you wrote in the last 20%, but really, who else in the world is smart enough to grok your brilliant code anyway, so where's the problem? Fortunately, no one has outlawed Lisp, so those people can continue to use it and don't have to use horribly restrictive languages like Python or Scala like all of us dumb sheeple, so we can ignore that.)
And I don't even know how you'd implement it efficiently without them being known at compile-time.
I guess at *every* callsite you could test if the callable is magic, and if it is evaluate the arguments, and if it's not just pass in a lambda that will return the arguments. But you've got to generate those lambdas for *all* callsites, even the vast majority that will never be a magic callable.
What if the callable only wants *some* of the arguments? Hey, if this had existed back then the ternary operator could have been a normal function - instead of (b() if a else c()) just do iif(a, b(), c()).
And is this going to be fully general? I.e. should this be supported for regular operators? If __add__ is magic does + do this, for example?