Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85093

Re: [OT] fortran lib which provide python like data type

Date 2015-02-02 09:25 -0700
From Michael Torrie <torriem@gmail.com>
Subject Re: [OT] fortran lib which provide python like data type
References (11 earlier) <8761bmf4gn.fsf@elektro.pacujo.net> <makn7g$lg0$1@dont-email.me> <87oapde98u.fsf@elektro.pacujo.net> <mailman.18384.1422838947.18130.python-list@python.org> <87fvaoep9d.fsf@elektro.pacujo.net>
Newsgroups comp.lang.python
Message-ID <mailman.18404.1422894344.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 02/02/2015 12:39 AM, Marko Rauhamaa wrote:
> Michael Torrie <torriem@gmail.com>:
> 
>> http://en.cppreference.com/w/cpp/utility/functional/function
>>
>> Thus if we were to shoehorn your example into C++, the result would be
>> idiomatically very similar to what you have in your Python code.
> 
> I can understand why you wouldn't write out my example in C++:

I wouldn't write it out because it's a contrived example, and why should
I waste my time? You have no intention of being impressed with C++, let
alone simply learn about it.

> 
>    using std::placeholders::_1;
> 
>    std::function<void(int)> f_add_display2 =
>         std::bind( &Foo::print_add, foo, _1 );

Looks okay to me.  That's normal C++ that would be clear to any C++
programmer.  And for a statically compiled language, that's incredibly
powerful while providing for a measure of safety.  You may shudder, but
it's a really good statically compiled solution, given the constraints
of C++ and its compiler.

But like I said, idiomatically in C++, this isn't normally what you'd do
anyway.  You'd store a std::ostream object.

> vs
> 
>    f_add_display2 = foo.print_add
> 
> The cherry on top: "_1"! The C++ compiler figures out template types
> heroically but can't wrap its head around the arity of the method.

std::bind is a generic function that works with undecorated function
pointers.  There's no possible way for the compiler to know the arity of
the function without you telling it (how else would you do it? I
honestly want to know.).  That you would find this fact to be
incredulous suggests that you have very little understanding of
compilers in general.  Python being a dynamic, interpreted language can
examine a function at runtime.

Python is a very expressive language compared to C++ that can do things
at runtime that C++ cannot.  It's also an interpreted, dynamically-typed
language, whereas C++ is a statically-typed language that is clearly
faster at many things than Python is.  It's a matter of different tools
for different jobs.  For most of my jobs Python is the right tool.  But
I can see why people would still want to pick a compiled language, and I
can understand why some people still use C++.  It's a very powerful
language.

I'm a little unclear as to why you're even bringing up the comparison
with C++.  What's your point?  To feel superior?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[OT] fortran lib which provide python like data type 1989lzhh <1989lzhh@gmail.com> - 2015-01-29 21:39 +0800
  Re: [OT] fortran lib which provide python like data type beliavsky@aol.com - 2015-01-29 14:39 -0800
    Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-01-29 17:40 -0800
      Re: [OT] fortran lib which provide python like data type Christian Gollwitzer <auriocus@gmx.de> - 2015-01-30 08:32 +0100
        Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-01-30 08:27 -0800
          Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-01-30 10:08 -0700
            Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-01-30 09:31 -0800
              RAII vs gc (was fortran lib which provide python like data type) Rustom Mody <rustompmody@gmail.com> - 2015-01-30 10:02 -0800
                Re: RAII vs gc (was fortran lib which provide python like data type) Sturla Molden <sturla.molden@gmail.com> - 2015-01-30 21:28 +0000
                Re: RAII vs gc (was fortran lib which provide python like data type) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-01 14:00 +1100
                Re: RAII vs gc (was fortran lib which provide python like data type) Chris Angelico <rosuav@gmail.com> - 2015-02-01 14:21 +1100
                Re: RAII vs gc (was fortran lib which provide python like data type) Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-31 19:27 -0800
              Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-01-30 11:15 -0700
                Re: [OT] fortran lib which provide python like data type Paul Rubin <no.email@nospam.invalid> - 2015-01-30 10:23 -0800
                Re: [OT] fortran lib which provide python like data type Christian Gollwitzer <auriocus@gmx.de> - 2015-01-31 09:27 +0100
                Re: [OT] fortran lib which provide python like data type Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-31 11:51 +1300
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-31 10:49 +1100
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-01-31 14:22 +0200
                Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-01-31 07:50 -0800
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-01-31 19:43 +0200
                Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-01-31 18:30 -0800
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-01 09:38 +0200
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-02 03:49 +1100
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-01 20:57 +0200
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-02 12:59 +1100
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-02 13:05 +1100
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-02 10:51 +0200
                Re: [OT] fortran lib which provide python like data type Chris Angelico <rosuav@gmail.com> - 2015-02-02 13:04 +1100
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-02 18:01 +1100
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-02 10:52 +0200
                Re: [OT] fortran lib which provide python like data type Paul Rudin <paul.nospam@rudin.co.uk> - 2015-02-02 12:56 +0000
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-02 15:27 +0200
                Re: [OT] fortran lib which provide python like data type Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-02 16:08 +0000
                Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-02-02 08:21 -0800
                Re: [OT] fortran lib which provide python like data type Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-02 16:52 +0000
                Re: [OT] fortran lib which provide python like data type Chris Angelico <rosuav@gmail.com> - 2015-02-03 04:25 +1100
                Re: [OT] fortran lib which provide python like data type Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-02 18:34 +0000
                Re: [OT] fortran lib which provide python like data type Chris Angelico <rosuav@gmail.com> - 2015-02-03 10:15 +1100
                Re: [OT] fortran lib which provide python like data type Matthew Barnett <auxlang@mrabarnett.plus.com> - 2015-02-02 02:35 +0000
                Re: [OT] fortran lib which provide python like data type Chris Angelico <rosuav@gmail.com> - 2015-02-02 13:45 +1100
                Re: [OT] fortran lib which provide python like data type Roy Smith <roy@panix.com> - 2015-02-01 23:12 -0500
                Re: [OT] fortran lib which provide python like data type Roy Smith <roy@panix.com> - 2015-02-01 23:14 -0500
                Re: [OT] fortran lib which provide python like data type Chris Angelico <rosuav@gmail.com> - 2015-02-02 15:47 +1100
                Re: [OT] fortran lib which provide python like data type Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-02 16:06 +0000
                Re: [OT] fortran lib which provide python like data type Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-31 17:59 +0000
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-01 13:27 +1100
                Re: [OT] fortran lib which provide python like data type Paul Rubin <no.email@nospam.invalid> - 2015-01-31 22:26 -0800
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-01 09:58 +0200
                Re: [OT] fortran lib which provide python like data type Christian Gollwitzer <auriocus@gmx.de> - 2015-02-01 09:14 +0100
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-01 21:12 +0200
                Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-02-01 17:50 -0700
                Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-02-01 18:02 -0700
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-02 09:39 +0200
                Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-02-02 09:25 -0700
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-02 19:57 +0200
                Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-02-02 11:23 -0700
                Re: [OT] fortran lib which provide python like data type Marko Rauhamaa <marko@pacujo.net> - 2015-02-02 20:54 +0200
                Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-02-01 18:02 -0700
                Re: [OT] fortran lib which provide python like data type beliavsky@aol.com - 2015-02-02 05:30 -0800
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-31 10:50 +1100
                Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-01-30 20:49 -0700
                Re: [OT] fortran lib which provide python like data type Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-31 22:04 +1100
                Re: [OT] fortran lib which provide python like data type Rustom Mody <rustompmody@gmail.com> - 2015-01-31 08:18 -0800
          Re: [OT] fortran lib which provide python like data type Sturla Molden <sturla.molden@gmail.com> - 2015-01-30 23:12 +0000
          Re: [OT] fortran lib which provide python like data type Michael Torrie <torriem@gmail.com> - 2015-01-30 20:35 -0700

csiph-web