Continuations: The Swiss Army Knife of Flow Control

Поділитися
Вставка
  • Опубліковано 16 лип 2024
  • In this talk, we are discussing a programming construct called "continuations," which essentially allow points in your program to be saved and returned to at a later point. We are also discussing the many different flow control operators that can be built from this tool, including exception handling, multithreading, and logic programming.
  • Наука та технологія

КОМЕНТАРІ • 19

  • @matejfandl1588
    @matejfandl1588 4 роки тому +12

    this deserves more views. thank you.

  • @catonano123
    @catonano123 Рік тому +4

    This talk is really eye opening. Thank you
    It'd be nice if you would do a tour of what delimited continuations are and what advantages they offer

  • @rstewart2702
    @rstewart2702 8 місяців тому

    Great video; thanks for helping us humble programmers get to a better understanding of continuations!
    It’s a bit confusing in some places, though, when you say “stack frame,” and you are actually talking about the entire stack.
    That is minor, keep doing what you are doing; fantastic stuff, good work!

  • @yetanotherchannelyac1434
    @yetanotherchannelyac1434 3 роки тому +4

    This was a great talk 👍

  • @firalanger6850
    @firalanger6850 4 місяці тому

    2:33 - The order the sub-expressions are evaluated (i.e. executed) is undefined, but the order of the values of these sub-expressions is defined.
    (f (g) (h))
    might run "g" first or might run "h" first, but the value of the application (i.e. execution) of the procedure "g" (i.e. "(g)") will always be the first argument, and "(h)" will always be the second argument to the application of the function "f".

  • @user-fg6ng7ej6w
    @user-fg6ng7ej6w Рік тому +2

    cool explanation. this guy has probably mentioned this book: "Essentials of Programming Languages" by D. Friedman and M. Wand, 3rd ed.

  • @acobster
    @acobster 3 роки тому +2

    This is great but why would you animate a stack going down?? Sorry for nitpicking but the visual metaphor is kind of an important piece to understanding stacks. Anyway good talk regardless.

    • @BPLearningTV
      @BPLearningTV  2 роки тому +7

      True, but, honestly, stacks usually grow downward. Memory allocations grow from the bottom of memory up, stacks usually grow from the top of memory down (though, in Scheme, not all implementations use a hardware stack). Additionally, in the visual, it makes them both start nearby each other :)

    • @AdrianBoyko
      @AdrianBoyko 2 роки тому +9

      What is wrong with you two? Memory is horizontal 😑

  • @NikolajLepka
    @NikolajLepka Рік тому

    ngl, I kinda hate the (define foo (lambda x ...)) style some schemers write, why not just do the shorter (define (foo x) ...) instead?

    • @BPLearningTV
      @BPLearningTV  Рік тому +4

      When I'm teaching I often like to separate out different parts of constructions rather than using shortcuts. It helps students recognize the difference between creating a function and defining the meaning of a symbol, and helps them recognize that, in Scheme, there is nothing special about assigning a function vs. any other kind of value.

    • @NikolajLepka
      @NikolajLepka Рік тому

      @@BPLearningTV It's not really a shortcut though. Every programming language separates the function creation syntax from the variable creation syntax; saying one is how you define a function and one is how you define a variable isn't really very confusing and may in fact help students when moving to other languages.
      Heck, even Haskell and OCaml which both also have a similar approach to Scheme regarding the visual difference between values and functions don't have teachers bend over backwards to prefer
      let f = fun x -> foo x
      instead of just writing
      let f x = foo x
      even though both effectively give you the same result.
      Let functions be functions and variables be variables. It's not any more confusing to a student to say both of them define a new symbol.

    • @BPLearningTV
      @BPLearningTV  Рік тому +5

      @@NikolajLepka Students often fail to recognize when they are defined differently that they play in the same namespace, and both represent values. Treating a function as a value is in fact something that new students have trouble with, and separating the function creation syntax from the assignment syntax makes this more clear.

    • @PixelOutlaw
      @PixelOutlaw 8 місяців тому +1

      Showing it without the syntactic sugar gives a good foundation for what's actually going on before they start using that syntactic sugar. He's also stressing the symbolic nature of Scheme. You don't just create a toplevel function and it magically gets stored somewhere - you need it to be bound to a symbol which is what the long hand form demonstrates.

    • @vyrsh0
      @vyrsh0 6 місяців тому

      ​@@NikolajLepka Continuation work because in scheme variable and function definitions share the same space.
      If you do it in common lisp, you will get an error that your collector function which you defined as a variable in the argument list, is an undefined function, as you have not defined it as a function.
      To get around this, you will have to use funcall whenever you use the collector function in the main function definition

  • @ThePandaGuitar
    @ThePandaGuitar 3 роки тому

    It’s like JavaScript ;) This is all nice, but what is the performance like?

    • @replikvltyoutube3727
      @replikvltyoutube3727 5 місяців тому

      JavaScript was a scheme first. It got Java and C-ified in syntax

  • @jimnewton4534
    @jimnewton4534 5 років тому +13

    There is no such word "parenthesee". The singular form of parentheses is parenthesis, not parenthesee.