The Debug Adapter Protocol is a REPL protocol in disguise

(zignar.net)

33 points | by Malp 2 days ago ago

5 comments

  • o11c 2 days ago ago

    Hmm, the is `type` the static type or the dynamic type, for languages where both apply?

    • ahoka a day ago ago

      It’s a very confusing question. How can an evaluated expression’s result have multiple types?

      • suspended_state a day ago ago

        I don't know what GP meant, but I can give an example of how I understand it (disregarding the spurious "the" in his comment): in a type system with sub-typing, your expression could be statically typed to return a certain type, and at runtime return any of its sub-types.

        For instance, in typescript you could ascribe an expression with the type Any, yet the actual runtime type will not be Any, it will be any concrete type.

        In object oriented languages, you may define a hierarchy of classes, say with "Car" and "Truck" being sub-classes of "Vehicle", each having a concrete implementation, and have an expression returning either a "Car" or a "Truck", or maybe even a "Vehicle". This expression will be statically typed as returning a "Vehicle", yet the dynamic type of the returned value will not necessary be (exactly) that.

      • o11c a day ago ago

        Any statically-typed language has this. In pseudo-Java:

          class Parent {};
          class Child extends Parent {};
          class Wrapper
          {
              Parent foo;
          }
        
          w = new Wrapper();
          w.foo = new Child();
        
          evaluate w.foo;
          // static type: Parent
          // dynamic type: Child
      • tmtvl a day ago ago

        Could be a Raku construct:

          my $day-of-week = 5 but "Friday";