News for hackers. Stuff that matters.
Re:The perils of Lisp in production by rbanffy on Wednesday April 04, 2012 @12:43PM (#3798392)
A compiler can only go so far. It'll happily compile:

  #include <stdio.h>

  int main(int argc, char *argv[])
  {
    FILE *fp = fopen("outfile", "w");
    fclose(fp);
    do_something(fp);
    return 0;
  }

  int do_something(FILE *f)
  {
    fprintf(f, "This should work if you know what you're doing");
  }
And it won't work.
Re:The perils of Lisp in production by maximilianburke on Wednesday April 04, 2012 @01:15PM (#3798592)
In C++, proper scoping with RAII (similar to CL's with-blah idioms) would alleviate that issue as do_something in the code below won't compile.

    struct WithOpenFile {
        FILE *fp;
        WithOpenFile(const char *fileName) : fp(fopen(fileName, "w")) {}
        ~WithOpenFile() { fclose(fp); }
    };

    int do_something(FILE *f)
    {
        fprintf(f, "This should work if you know what you're doing");
    }

    int main(int argc, char *argv[])
    {
        {
            WithOpenFile file("outfile");
        }
        do_something(file.fp);
        return 0;
    }
But Lisps will happily accept this:

    (defun do-something (foo)
        (1+ foo))

    (with-open-file (file "outfile")
        (do-something file))
Re:The perils of Lisp in production by rbanffy on Wednesday April 04, 2012 @01:22PM (#3798636)
Fine. But now you'll have to accept both files and network sockets. What do you do?
Re:The perils of Lisp in production by anonymoushn on Wednesday April 04, 2012 @02:09PM (#3798939)
Pass the int representing the FD instead of the FILE*?
Re:The perils of Lisp in production by rbanffy on Wednesday April 04, 2012 @04:38PM (#3799714)
And then you are back to dynamic typing again, except that, when the integer you send points to something fprintf doesn't like you'll get a segfault instead of a doesNotUnderstand.
Re:The perils of Lisp in production by eropple on Wednesday April 04, 2012 @01:21PM (#3798635)
The compiler will happily compile that because C's standard library thinks it's a fantastic idea to just throw type-safety out the window. Even C libraries can protect themselves from this via strong typing instead of overloading what FILE* effectively means.