post05_arguile.skr 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. (post
  2. :title "Introducing Arguile: a terse, hygenic lisp"
  3. :date (make-date* 2016 11 9)
  4. :tags '("arguile" "guile" "arc" "scheme" "lisp")
  5. (h3 [Update])
  6. (p [
  7. It's been a while since my last post! In the meantime, I've been
  8. monkeying around with two great lisps: Arc and Guile, and am combining
  9. them into a new dialect, Arguile. Right now, the code base is still
  10. highly experimental, but I'd like to explain my though process and why
  11. I think it's needed.
  12. ])
  13. (h3 [Specification])
  14. (ul
  15. (li
  16. (h4 [Terse])
  17. (p [
  18. This one I hadn't though of much until investigating Arc, but it
  19. seems obvious now. Lisp, and in particular the committee ratified
  20. lisp Scheme, favors explicitness over simplicity. Even after just
  21. replacing define with def,
  22. define-syntax with mac, and lambda with fn, I was saving an enormous
  23. number of keystrokes. In addition, macros often overuse parens.
  24. This is particularly noticeable with the let macro, where we go
  25. from])
  26. (code-block-scheme
  27. (car
  28. [(let ((a 1) a)) to (let a 1 a)
  29. (let ((a 1) (b 2)) (+ a b)) to (with (a 1 b 2) (+ a b))])))
  30. (li
  31. (h4 [Hygienic])
  32. (p [
  33. Hygienic macros are probably the main reason why I wasn't satisfied
  34. with Arc, and why I chose Arguile to be more Scheme oriented, than CL
  35. oriented. While I am not enough of a macro guru to refute Doug Hoyte
  36. in his book, Let Over Lambda, that CL macros are more
  37. intuitive and powerful BECAUSE they are unhygenic, I do love
  38. scheme's syntax pattern matching, and I have yet to see a CL macro feature
  39. that can't be constructed in a hygienic system. Once I learn
  40. more, though, an un-hygenic macro system could be added.
  41. ]))
  42. (li
  43. (h4 [Generic])
  44. (p [
  45. Generics are supported in Arc, and handles type coercion quite well.
  46. However, I believe they should have incorporated CLOS
  47. (common lisp object system) to make the system more extensible.
  48. Arguile follows Arc's type coercion approach, but also integrates it with
  49. GOOPS, Guiles object system. For those who don't like generics, the type
  50. specific functions are also exposed.]))
  51. (li
  52. (h4 [Data Structures])
  53. (p [
  54. Data structure manipulation in Scheme is extremely verbose, and IMO,
  55. its greatest weak point.
  56. Other languages, like Arc and Clojure combat this by allowing
  57. data-structures to be applicable, meaning they
  58. can be put in the function position:])
  59. (code-block-scheme (car
  60. [(vector-ref vec 1) becomes (vec 1)
  61. (vector-set! vec 0 (vector-ref vec 1)) is now (vec 0 (vec 1))]))
  62. (p [
  63. The issue I found with Arc, however, is that 1.
  64. there is no standard way to define new data types, and 2. new data types
  65. cannot easily become applicable. In Arguile, new data types follow Scheme's
  66. standardized define-record-type, but can be made applicable, and are easier to write.
  67. Compare])
  68. (code-block-scheme
  69. (car [
  70. (define-record-type mydata
  71. (make-mydata a b) mydata?
  72. (a my-data-a)
  73. (b my-data-b))]))
  74. (p [with])
  75. (code-block-scheme
  76. (car [(data mydata a b)]))
  77. (p [Although not yet implemented, Arguile will
  78. support algebraic data-types, like Haskell:])
  79. (code-block-scheme
  80. (car
  81. [(data mylist (mycons a b)
  82. (mynull))])))
  83. (li
  84. (h4 [Compatible])
  85. (p [Fragmentation is a problem in Scheme. Arc continues this tradition by redefining
  86. many of the core functions and by not inter-oping with rnrs code. This has some
  87. severe drawbacks. By defining an
  88. entirely different evaluation scheme, it misses out on all the great features
  89. developed in its parent language, Racket, which is why you won't see a native
  90. module system in Arc. Rebuilding one only requires wasteful re-implementation.
  91. Arguile's approach is to be a thin wrapper on top of Guile. This means
  92. that not only does Arguile
  93. get all of Guile's features for free, but Guile can run anything built in Arguile.
  94. Most Arguile features can be developed with macros, but when Guile itself must be
  95. modified, care is taken to add features that Guile could also benefit from. Never will we purposely break Guile code to add a feature.])))
  96. (h3 [Conclusion])
  97. (p [I really do think Arguile is needed. We need a modern lisp, one that is
  98. as powerful as any other, as terse as Arc, and as hackable as Python.]))