1. 21
  1.  

  2. 8

    Love your style, looking forward to more. TButton1!

    1. 6

      Yeah, the stream-of-consciousness thing really works as a way to show seasoned pros what it’s like to be a newbie again. As a maintainer this kind of thing would be really valuable for uncovering usability issues in my own software.

    2. 3

      Impressive job. As someone with lisp experience, but not much scheme experience I find this really useful.

      1. 2

        I love scheme, but it can be incredibly verbose. From his code, a simple function to swap items in a vector:

        (define (vector-swap vec i j)
          (let ([t (vector-ref vec i)])
            (vector-set! vec i (vector-ref vec j))
            (vector-set! vec j t)))
        

        I think that beats most other languages in terms of characters typed. It feels like a minor issue for an otherwise elegant language, but it has turned me off to writing large programs in scheme.

        1. 2

          It can be made less verbose with appropriate aliases, which you can write yourself and import into all your programs.

          (def (vector-swap v i j)
            (def t (!! v i))
            (v i . := . (!! v j))
            (v j . := . t))
          
          1. 1

            My limited experience is that Scheme is usually a little more verbose than Python, but not much. And it makes less difference for large programs, where hopefully a lot of your code looks like this:

            static int physmap_flash_remove(struct platform_device *dev)
            {
                    struct physmap_flash_info *info;
                    struct physmap_flash_data *physmap_data;
                    int i;
            
                    info = platform_get_drvdata(dev);
                    if (info == NULL)
                            return 0;
                    platform_set_drvdata(dev, NULL);
            
                    physmap_data = dev->dev.platform_data;
            
                    if (info->cmtd) {
                            mtd_device_unregister(info->cmtd);
                            if (info->cmtd != info->mtd[0])
                                    mtd_concat_destroy(info->cmtd);
                    }
            

            which is to say:

            (define (physmap-flash-remove dev)
              (let ((info (platform-get-drvdata dev)))
                (if (null? info) 0
                    (begin
                      (platform-set-drvdata dev NULL)
            
                      (let ((physmap-data (platform-data (platform-device-dev dev)))
                            (cmtd (physmap-flash-info-cmtd info)))
                        (if cmtd
                            (begin
                              (mtd-device-unregister cmtd)
                              (if (not (eq? cmtd (vector-ref (physmap-flash-info-mtd info) 0)))
                                  (mtd-concat-destroy cmtd)))))))))
            

            I mean, Scheme clearly has its drawbacks here, but I don’t think verbosity is much of a problem.

            (Confession, though: my first random piece of code from Linux was spi_tegra_fill_tx_fifo, which doesn’t match my preconceptions of what “large program code” looks like, and would probably be a lot more messy in vanilla Scheme without extra macros.)

            1. 2

              Uhh, I’m not really seeing how the Scheme code in that example is less verbose than the C code. If anything, the deeper indentation level makes it more difficult to read.

              1. 2

                The point is that the verbosity of the core forms and functions is only relevant when writing a code that needs them. Usually, you very quickly bootstrap to much higher realms of business logic and abstraction layers where it shines.

                1. 1

                  It’s not less verbose, and I agree about the nesting. But it’s not noticeably more verbose either. And that C code has been used to successfully write a large program.