<div dir="ltr">Only problem is that it looks a tad perlish...</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 4, 2014 at 5:09 PM, Carl Smith <span dir="ltr"><<a href="mailto:carl.input@gmail.com" target="_blank">carl.input@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-family:arial,helvetica,sans-serif">The tentatively proposed idea here is using dollar signed expressions to define 'bills'. A bill object is essentially an expression which can be evaluated any number of times, potentially in different scopes.</span><br>
</div><br><font face="arial, helvetica, sans-serif">The following expression [a </font><span style="font-family:arial,helvetica,sans-serif">bill literal</span><font face="arial, helvetica, sans-serif">] would be pointless, but would define a </font><span style="font-family:arial,helvetica,sans-serif">bill</span><font face="arial, helvetica, sans-serif"> that always evaluates to 1.</font><br>
<br><font face="courier new, monospace"> $1</font><br><br><font face="arial, helvetica, sans-serif">So, eval($1)==1.</font><br><br><font face="arial, helvetica, sans-serif">Some better examples...</font><br><br><font face="arial, helvetica, sans-serif">* assign a bill to `a` so that `a` will evaluate to the value of the name `foo` any time that `a` is evaluated, in the scope of that evaluation</font><br>
<br><font face="courier new, monospace"> a = $foo</font><br><br><font face="arial, helvetica, sans-serif">* as above, but always plus one</font><br><br><font face="courier new, monospace"> a = $foo + 1</font><br><br>
<font face="arial, helvetica, sans-serif">* make `a` a bill that evaluates to the value of the name `foo` at the time that `a` is evaluated, in that scope, plus the value of `bar` **at the time and in the scope of the assignment to `a`**</font><br>
<br><font face="courier new, monospace"> a = $foo + bar</font><br><br><font face="arial, helvetica, sans-serif">Note. Similarly to mixing floats with ints, any expression that contains a </font><span style="font-family:arial,helvetica,sans-serif">bill </span><font face="arial, helvetica, sans-serif">evaluates to a </font><span style="font-family:arial,helvetica,sans-serif">bill, so </span>if `a` is a bill, `b=a+1` makes `b` a bill too. Passing a bill to eval should be the obvious way to get the value.<div>
<br><font face="arial, helvetica, sans-serif">The point? It allows functions to accept </font><span style="font-family:arial,helvetica,sans-serif">bills to use internally</span><font face="arial, helvetica, sans-serif">. The function would specify any names the </font><span style="font-family:arial,helvetica,sans-serif">bill</span><font face="arial, helvetica, sans-serif"> can reference in the function's API, like keywords.</font><br>
<br><font face="courier new, monospace">def f(b): </font><span style="font-family:'courier new',monospace"># the bill arg `b` can reference `item`</span><div><div><font face="courier new, monospace"> for item in something:<br>
if eval(b): return True<br></font></div><div><br></div><div><span style="font-family:'courier new',monospace">f($item < 0)</span><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="arial, helvetica, sans-serif">You could also use a function call, for example `$foo()` would evaluate to a bill that evaluates to a call to `foo` in the scope and at the time of any evaluation of the bill.</font></div>
</div></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I've no idea if this is even possible in Python, and have no hope of implementing it, but thought I'd share :)</font></div>
</div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Ryan<div><div>If anybody ever asks me why I prefer C++ to C, my answer will be simple: "It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was nul-terminated."</div>
</div><div><br></div></div>
</div>