make world chris smowton university of cambridge
play

make world Chris Smowton University of Cambridge spell-rite - PowerPoint PPT Presentation

make world Chris Smowton University of Cambridge spell-rite /usr/share/real_words ~/nonsense spell-rite /usr/share/real_words ~/nonsense spell-rite /usr/share/real_words ~/nonsense /usr/share/real_words ~/nonsense /usr/share/real_words


  1. make world Chris Smowton University of Cambridge

  2. spell-rite /usr/share/real_words ~/nonsense

  3. spell-rite /usr/share/real_words ~/nonsense

  4. spell-rite /usr/share/real_words ~/nonsense

  5. /usr/share/real_words ~/nonsense

  6. /usr/share/real_words ~/nonsense $> echo “quexalcote” >> /usr/share/real_words $> make speaknspell

  7. int f(bool x, int y) { if(x) { return 42; } else { return y; } }

  8. int f(bool x, int y) { if(x) { return 42; } x == true else { return y; } }

  9. int f(int y) { if(true) { return 42; } else { return y; } }

  10. int f(int y) { if(true) { return 42; } else { return y; } }

  11. return 42;

  12. void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }

  13. void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); } “/usr/share/dict” is “aardvark, ...”

  14. void spell(char* text) { Machine* m = make_machine(); apply_machine(m, text); }

  15. void spell(char* text) { Machine* m = apply_machine(m, text); }

  16. void apply_machine( ) { // There are no words! }

  17. void apply_machine( ) { // No word contains “$”! }

  18. int f() { int x = 5; x = pow(x, x); printf(x); }

  19. int f() { x? int x = 5; x = pow(x, x); printf(x); }

  20. return x ** x; int f() { x == 3125 int x = 5; x = pow(x, x); printf(x); }

  21. void spell() { ... read(dict_fd, buf); ... }

  22. void spell() { ... buf? read(dict_fd, buf); ... }

  23. void spell() { ... buf == “quexalcote\n” read(dict_fd, buf); ... }

  24. int wordcount() { fd = open(“~/stuff”); while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  25. int wordcount() { fd = <”~/stuff”, pos=0> ; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  26. int wordcount() { fd = <”~/stuff”, pos=0>; if(eof) return count; read(fd, buf); if(strstr(buf, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  27. int wordcount() { Not EOF yet! Not EOF yet! fd = <”~/stuff”, pos=0>; if(eof) return count; read(fd, buf); if(strstr(buf, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  28. int wordcount() { buf == “aardvark\n” fd = <”~/stuff”, pos=0>; read(fd, buf); if(strstr(buf, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  29. int wordcount() { fd = <”~/stuff”, pos=0>; read(fd, buf); if(strstr(“aardvark”, “bar”)) count++; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  30. int wordcount() { fd = <”~/stuff”, pos=10>; while(!eof) { read(fd, buf); if(strstr(buf, “bar”)) count++; } return count; }

  31. int wordcount() { return 42; }

  32. int wordcount() { count = 42; fd = <”~/stuff”, pos=200> ... }

  33. int wordcount() { count = 42; fd = open(“~/stuff”); lseek(fd, 200, SEEK_SET); }

  34. Challenges ● Adaptive optimisation ● IPC and servers ● Efficiency

  35. Summary ● Make programs better! ● No manual work!

Recommend


More recommend