Python syntax in Lisp and Scheme
David Mertz
mertz at gnosis.cx
Fri Oct 17 14:20:30 EDT 2003
More information about the Python-list mailing list
Fri Oct 17 14:20:30 EDT 2003
- Previous message (by thread): Python syntax in Lisp and Scheme
- Next message (by thread): Python syntax in Lisp and Scheme
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
bokr at oz.net (Bengt Richter) wrote previously: |>Nope. That's the point of the Y combinator; you don't need a name to do |>this (just first class anonymous functions). See, for example: |> http://en2.wikipedia.org/wiki/Y_combinator |I'd call that a specialized syntax, to serve my purposes ;-) Well... it's specialized. But it's not a syntax, just a somewhat odd HOF. But I would definitely agree that I don't want all my recursion to be based on anonymous functions. |>This particular convenience is VERY small. |That's what I meant by the first line in Yeah, but I put the 'very' in caps :-). |the hypothetical version is what you were referring to by 'that way.' Yeah, sorry about my pronoun. I meant "can't spell the full suite..." |> >>> def ValFactory(x): |> ... def say_val(x=x): return 'My value is %s' % x |> ... return say_val |Sure. Interesting you chose to use the default-value hack rather than |a closure ;-). What I had in mind when I pre-agreed was something like | >>> class SayVal(object): | ... def __init__(self, v): self.v=v | ... def __call__(self): return 'My value is %s' % self.v Well... the "default value hack" *IS* a closure. I know I'm in the minority here, but it feels like more of a hack to me to make class instances whose (main) purpose is to "act like functions" (i.e. have custom '.__call__()' methods). In my mind, when I want a bunch of related callables, the natural approach is writing a function factory, not a class. But either way, Bengt's is another perfectly good spelling for a collection of callables that allow full suites. Not being Dutch, I can't say which one is the "one obvious way." Yours, David... -- ---[ to our friends at TLAs (spread the word) ]-------------------------- Echelon North Korea Nazi cracking spy smuggle Columbia fissionable Stego White Water strategic Clinton Delta Force militia TEMPEST Libya Mossad ---[ Postmodern Enterprises <mertz at gnosis.cx> ]--------------------------
- Previous message (by thread): Python syntax in Lisp and Scheme
- Next message (by thread): Python syntax in Lisp and Scheme
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list