Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Alternatives to sed + awk



On Fri, Mar 11, 2011 at 3:52 PM, Josh Glover <jmglov@example.com> wrote:
> On 11 March 2011 03:47, Stephen J. Turnbull <stephen@example.com> wrote:
>
>> I like functions as first class objects a lot.
>
> I do as well in Python and C (heh heh); it just turns out that you
> never need them in Ruby. I actually don't use functions at all in my
> Ruby code.

I meant to include "methods", not just bare functions.  So, you don't
use functions like, say, sin()?  Yow!  (pi/4).sin, is that it? :-)

def init_foo(func,arg):
    def foo():
        nonlocal n
        n = func(n)
        return n
    return foo

def logistic(x)
    return 3.82*x*(1-x)

simple_chaos = (logistic,0.5)

while True:
    print (simple_chaos())
# Enjoy!

> Everything is a class or instance method, so it doesn't
> make sense to pass those around.

Au contraire, it's surely makes sense to pass around a bound method
(ie, a method which knows which object it's attached to); a special case
of a closure.

>> I find the Python convention that identifiers named with leading
>> underscores are private an equally good signal in practice.
>
> You mean the Perl convention? ;-P

Dunno.  In Python it's somewhat elaborated and in CPython there's some
support for identifier munging a la C++.  So I don't know if it's very similar
to the Perl convention or not.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links