Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 11 submissions in the queue.
posted by martyb on Friday July 13 2018, @12:58PM   Printer-friendly
from the pass-it-on dept.

On a python developers' mailing list for the core developers, Python Committers, Benevolent Dictator for Life Guido van Rossum has announced that he is stepping down effective immediately and with out appointing a successor.

Now that PEP 572 is done, I don't ever want to have to fight so hard for a
PEP and find that so many people despise my decisions.

I would like to remove myself entirely from the decision process. I'll
still be there for a while as an ordinary core dev, and I'll still be
available to mentor people -- possibly more available. But I'm basically
giving myself a permanent vacation from being BDFL, and you all will be on
your own.

After all that's eventually going to happen regardless -- there's still
that bus lurking around the corner, and I'm not getting younger... (I'll
spare you the list of medical issues.)

I am not going to appoint a successor.

[...] I'll still be here, but I'm trying to let you all figure something out for
yourselves. I'm tired, and need a very long break.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by c0lo on Saturday July 14 2018, @02:18AM (5 children)

    by c0lo (156) on Saturday July 14 2018, @02:18AM (#706885) Journal

    I was able to use a variadic template in C++ with nothing more than my C knowledge and stack overflow and that was either right before or right after I even made my first class.

    Basics, even with variadic params, is easy and many useful things can be done with the basics.
    The things start to go quite horendous when you get into template metaprogramming - not everybody's piece of cake, but it's insanely powerful. And useful.
    E.g. write a templated function implementing one behaviour if you detect at compile time the (class) parameter implements a method with given signature, and a different behaviour if it doesn't. Do it without relying on inheritance - because you can't always go and pad a 3rd party library with "marker interfaces" specific to your needs.

    --
    https://www.youtube.com/watch?v=aoFiw2jMy-0
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 2) by Knowledge Troll on Saturday July 14 2018, @03:18AM (4 children)

    by Knowledge Troll (5948) on Saturday July 14 2018, @03:18AM (#706902) Homepage Journal

    That's awesome, thank you for sharing. I have yet to put together any template that has a branch that relates to the template variable but I've been wondering about what that might be useful for. Right now I just use templates to pass types through into the function so it can do something smart with them and the most sophisticated thing I think I've done so far is use T where the object name would go when using the name as a constructor in a templated class that provides constructors as static methods for the class that extends it. I was really pleased that it worked and it gave some nice shine to my base object interface.

    How do you do introspection in something like C++ at compile time to find out if a method signature exists on an object or not with out relying on the class hierarchy? Is that with typeinfo()? I didn't see an obvious way that would work in the documentation.

    Again, thanks for sharing, I truly appreciate it.

    • (Score: 2) by c0lo on Saturday July 14 2018, @09:35AM (3 children)

      by c0lo (156) on Saturday July 14 2018, @09:35AM (#707014) Journal

      If you haven't had any template metaprogramming experience, it will take you some time to get what's happening here. If this is the case:
      - SFINAE [cppreference.com]
      - see <type_traits> [cppreference.com]

      namespace detail {

      // SFINAE check for a method named `PostProcess`
      template <typename, typename T>
      struct has_PostProcess { // error case
          static_assert(
              std::integral_constant::value,
              "Second template parameter needs to be a function type."
          );
      };

      // specialization. Looking for a method named PostProcess declared by type X with rettype and args
      template <typename X, typename Ret, typename... Args>
      struct has_PostProcess<X, Ret(Args...)> {
      private:
          // constexpr data member - named `check` - of type function, will be used T has a PostProcess method
          // with matching arguments. The return type is either std::true_type or std::false_type
          template <typename T>
          static constexpr auto check(T*) ->
              typename std::is_same().PostProcess(std::declval()...)),
                  Ret
              >::type;
          // generic version of the check data member if the more specialized check
          // is not matched
          template <typename>
          static constexpr std::false_type check(...);
          // Realize that, by SFINAE, only one of the above definition of `check` will prevail.

          // this says "Would I be to call the 'check' function, what would be the return type"?
          using response=decltype(check<X>(static_cast<X*>(nullptr)));
      public:
          // the constexpre value will be true (X does have a PostProcess method matching the required signature)
          // or false otherwise.
          static constexpr bool value=response::value;
      };

      }// namespace detail

      Can you manage from here?

      --
      https://www.youtube.com/watch?v=aoFiw2jMy-0
      • (Score: 2) by Knowledge Troll on Saturday July 14 2018, @03:55PM (2 children)

        by Knowledge Troll (5948) on Saturday July 14 2018, @03:55PM (#707154) Homepage Journal

        Wow thanks again! Yeah that's beautiful, I just need a pointer really. I talked a bit with a friend and he introduced me to the type traits but said he had never done specialization. Thanks again! I will now explode my head.

        • (Score: 0) by Anonymous Coward on Saturday July 14 2018, @05:35PM

          by Anonymous Coward on Saturday July 14 2018, @05:35PM (#707216)

          > I just need a pointer really.

          Here you go: std::unique_ptr

          :D

        • (Score: 2) by c0lo on Saturday July 14 2018, @11:05PM

          by c0lo (156) on Saturday July 14 2018, @11:05PM (#707365) Journal

          Ah, shit, there are a few place where I missed to &lt; the <.

          //...
                  // constexpr data member - named `check` - of type function, will be used T has a PostProcess method
                  // with matching arguments. The return type is either std::true_type or std::false_type
                  template
                  static constexpr auto check(T*) ->
                          typename std::is_same<
                              decltype(std::declval<T>().PostProcess(std::declval<Args>()...)),
                              Ret
                          >::type;

          --
          https://www.youtube.com/watch?v=aoFiw2jMy-0