Op 2004-12-17, Terry Reedy schreef [EMAIL PROTECTED]:
Jason Zheng [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Steven Bethard wrote:
Jason Zheng wrote:
I'm wondering why python still has limited lambda support. What's
stopping the developers of python to support more
Bengt Richter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Looks like your standard pattern could be updated:
dispatch = {}
def dispvia(name):
... def _(f, name=name):
... dispatch[name] = f
... return f
... return _
...
@dispvia('a')
... def
Terry Reedy wrote:
To avoid the redundancy of 'a' and '_a', etc, how about (untested):
def dispvia(f):
dispatch[f.__name__.split('_')[1]] = f
return f
A similar idea:
Py class DispatchTable(dict):
... def __init__(self, prefix=):
... self._prefix = prefix
... self._ignored =
On 2004-12-18, Terry Reedy [EMAIL PROTECTED] wrote:
Dima Dorfman [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Both languages compile all three functions (f and the two versions of
g) once and choose which g to return at run-time.
*If* OCaml or any other 'other' language
Terry Reedy wrote:
Jp Calderone [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy [EMAIL PROTECTED] wrote:
.
For one-off uses not eligible for lambda treatment, where you really do not
care about the name, use the same name, such as
Jason Zheng wrote:
I'm wondering why python still has limited lambda support. What's
stopping the developers of python to support more lisp-like lambda
function?
See boo and its support for closures: http://boo.codehaus.org/
http://boo.codehaus.org/Closures
It works with def or do, or
Bengt Richter wrote:
It is a little sneaky though, so it might not be prudent to promote
without a little more experimentation? I just like to explore ;-)
I don't think even the py-dev discussions of this settled on whether such tricks
were very cool or downright evil.
They're probably less evil
I'm wondering why python still has limited lambda support. What's
stopping the developers of python to support more lisp-like lambda function?
--
http://mail.python.org/mailman/listinfo/python-list
Lambda functions will become obsolette in the nearest future. This is
the PLAN.
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard wrote:
Even if you could settle the syntax issue, once you've decided that you
really do need a true
block in an anonymous function, you're not really saving much space by not
declaring it:
def f(*args):
# body line 1
# body line 2
# ...
# body line N
True enough, but suppose you want a hash of anonymous functions as
opposed to just a lexical? This is where lambas are nice to have.
Totally agreed about a small use here and there, but they do have some
use in dispatch tables, as they are a lot easier to read sometimes
than very long case
Steven Bethard wrote:
You're welcome to name the function whatever you want -- notice in my example
that the function is
used in the statement:
x = func or f
If you'd prefer the statement to read:
x = func or x
that's also fine. Depends on what exactly 'x' is, and whether or not it
Michael DeHaan wrote:
True enough, but suppose you want a hash of anonymous functions as
opposed to just a lexical?
I've seen at least one reasonable example of this kind of thing:
http://mail.python.org/pipermail/python-list/2004-October/245432.html
Though I haven't yet seen an example that
Michael DeHaan wrote:
True enough, but suppose you want a hash of anonymous functions as
opposed to just a lexical? This is where lambas are nice to have.
Totally agreed about a small use here and there, but they do have some
use in dispatch tables, as they are a lot easier to read
Steven Bethard wrote:
Jason Zheng wrote:
I'm wondering why python still has limited lambda support. What's
stopping the developers of python to support more lisp-like lambda
function?
This comes up every few weeks on the list. If you haven't already,
check the archives in Google for
Jason Zheng wrote:
The true beauty of lambda function is not the convenience of creating
functions without naming them. Lambda constructs truly enables
higher-order function. For example, I can create a function A that
returns a function B that does something interesting according to the
Steven Bethard wrote:
I've seen at least one reasonable example of this kind of thing:
http://mail.python.org/pipermail/python-list/2004-October/245432.html
the code he's referring to doesn't seem to use that construct anymore, so
it's not obvious what dejavu.icontains etc really is, but
Fredrik Lundh wrote:
Steven Bethard wrote:
I've seen at least one reasonable example of this kind of thing:
http://mail.python.org/pipermail/python-list/2004-October/245432.html
the code he's referring to doesn't seem to use that construct anymore, so
it's not obvious what dejavu.icontains etc
Jason Zheng [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Steven Bethard wrote:
Jason Zheng wrote:
I'm wondering why python still has limited lambda support. What's
stopping the developers of python to support more lisp-like lambda
function?
They already have: given the
Jeff Shannon wrote:
It occurs to me that, in a statically compiled language, function
definitions all happen before the program starts, and thus that
definition can't be affected by other variables (i.e. an outer
function's parameters).
I think you might be confusing static compilation in a
On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy [EMAIL PROTECTED] wrote:
Jason Zheng [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Steven Bethard wrote:
Jason Zheng wrote:
I'm wondering why python still has limited lambda support. What's
stopping the developers of python
Jp Calderone wrote:
On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy [EMAIL PROTECTED] wrote:
Jason Zheng [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Steven Bethard wrote:
Jason Zheng wrote:
I'm wondering why python still has limited lambda support. What's
stopping the
Steven Bethard wrote:
Jeff Shannon wrote:
It occurs to me that, in a statically compiled language, function
definitions all happen before the program starts, and thus that
definition can't be affected by other variables (i.e. an outer
function's parameters).
I think you might be confusing
Jeff Shannon [EMAIL PROTECTED] writes:
Steven Bethard wrote:
Hm, possibly. I must confess that my direct knowledge is limited to a
fairly narrow set of languages, and that C and C++ are the only
statically-compiled languages I've used. Still, I'm not sure that
it's just a matter of
On 2004-12-18, Jeff Shannon [EMAIL PROTECTED] wrote:
Would OCaml (or some
other static language) have something that's equivalent to this?
def f(x):
if x 0:
def g(y):
return y * -1
else:
def g(y):
return y
return g
foo = f(1)
On Fri, 17 Dec 2004 22:56:08 +0100, Fredrik Lundh [EMAIL PROTECTED] wrote:
Michael DeHaan wrote:
True enough, but suppose you want a hash of anonymous functions as
opposed to just a lexical? This is where lambas are nice to have.
Totally agreed about a small use here and there, but they do
Jp Calderone wrote:
Regarding #1: there must be a great variance between people in the
difficulty of some aspects of programming. I am always amazed to hear
from people who have no difficulty picking names for all of their
functions. This is a task that often stumps me for long minutes.
My
27 matches
Mail list logo