Settings

Theme

The Debug Adapter Protocol is a REPL protocol in disguise

zignar.net

36 points by Malp a month ago · 5 comments

Reader

o11c a month ago

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

  • ahoka a month ago

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

    • suspended_state a month 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 month 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 month ago

      Could be a Raku construct:

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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection