CppCon 2018: Richard Powell “Named Arguments from Scratch”

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ต.ค. 2024

ความคิดเห็น • 12

  • @videojeroki
    @videojeroki 5 ปีที่แล้ว +14

    i wish i could just include and link any c++ library by a simple click like it is done here.

    • @BigPapaMitchell
      @BigPapaMitchell 5 ปีที่แล้ว +8

      Making and using libraries is probably one of the most frustrating part of C and C++ for me

    • @dennisrkb
      @dennisrkb 5 ปีที่แล้ว +1

      I have high hopes for vcpkg in this regard.

  • @darkwinter6028
    @darkwinter6028 5 ปีที่แล้ว +4

    Umm... that’s not how Objective-C works... (or Swift, for that matter - same runtime). “Named arguments” are a feature provided by the compiler’s parser stage; what’s actually going on is the argument name is part of the method name. So, for example, in the call [foo doSomethingWithThisInt:5 anotherInt:7]; to a method declared -(void)doSomethingWithThisInt:(int)a anotherInt:(int)b; the entire method name (it’s selector, in Objective-C terminology) is doSomethingWithThisInt:anotherInt: and it’s C function signature is void f(id self, int a, int b). The arguments are passed according to standard platform C ABI rules. The only thing objc_msgSend() does is find the C function that corresponds to the selector value passed to it, and jump to that function.
    P.s. - I *think* the selector is passed to the C function as well, but it’s been a while since I read the relevant sections of the Runtime Reference... 🤔

  • @terrance_huang
    @terrance_huang ปีที่แล้ว

    😱 stop this non-sense, C++!

  • @GrzesiuG44
    @GrzesiuG44 5 ปีที่แล้ว

    I tried to reproduce code samples without boost::hana, but after adding apply(auto &f) compiler started generating foo and stopped optimizing it into returning 42 (on clang(trunk) and gcc(8.2); gcc(trunk) and some experimental clangs did succeed).
    I wonder what trick hana did that makes it work... godbolt.org/z/hQtwqg

  • @petermuller9518
    @petermuller9518 5 ปีที่แล้ว

    Can you determine the name of Arguments in C++ (without meta classes)?

    • @Voy2378
      @Voy2378 5 ปีที่แล้ว +1

      no

  • @williamchamberlain2263
    @williamchamberlain2263 5 ปีที่แล้ว +1

    Works well in Matlab: makes the intent of each argument clear without having to check the API.

    • @kwinzman
      @kwinzman 5 ปีที่แล้ว

      But that's not the point here. See 52:49.

    • @MatthewWalker0
      @MatthewWalker0 5 ปีที่แล้ว +1

      calling something that takes 3 matrices and 2 floats is probably one of the most compelling use cases, but something like insertSorted(1, myArray) probably doesn't need it.

  • @abdullahalattar5642
    @abdullahalattar5642 5 ปีที่แล้ว

    Great Talk!!