up-and-running.skb 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. (section
  2. :title [Installing Guile and friends]
  3. (p [To use this tutorial, you'll need to install Guile onto your computer.
  4. If you don't have Guile yet,
  5. ,(ref :url [https://www.gnu.org/software/guile/download/]
  6. :text [go install it])
  7. then come back.])
  8. (p [You'll also need a text editor of some sort.
  9. You will want to use something that edits plain text, which means
  10. you don't want to use a word processor (so, no Libreoffice!),
  11. you want an editor to edit programs.
  12. If you already have an editor you like to use, great use that!
  13. Most Guile developers find that the best editor to use is
  14. ,(ref :url [https://www.gnu.org/software/emacs/]
  15. :text [Emacs])
  16. combined with
  17. ,(ref :url [http://www.nongnu.org/geiser/]
  18. :text [Geiser]),
  19. but if you aren't already an Emacs user, it can be overwhelming
  20. to learn multiple things at once.
  21. (If do learn to use Emacs with Geiser, there are even more
  22. fun things you can do than what we show here.
  23. ,(ref :url [http://www.nongnu.org/geiser/geiser_3.html#The-REPL]
  24. :text [See the Geiser manual])
  25. for more information!)
  26. If you've never programmed before, you might want to start with
  27. something simple, like ,(code [gedit]) for
  28. ,(ref :url [http://gnome.org/]
  29. :text [Gnome]).
  30. You can always set up a more advanced setup later!]))
  31. (section
  32. :title [Running Guile]
  33. (p [So let's get started.
  34. Open a terminal and run ,(code [guile]).
  35. You should see something like this:])
  36. (frame
  37. (prog :line #f
  38. "GNU Guile 2.0.11
  39. Copyright (C) 1995-2014 Free Software Foundation, Inc.
  40. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
  41. This program is free software, and you are welcome to redistribute it
  42. under certain conditions; type `,show c' for details.
  43. Enter `,help' for help.
  44. scheme@(guile-user)> "))
  45. (p [Great!
  46. That means Guile is working just fine.
  47. Now let's try entering a small command.
  48. Type ,(code "(display \"Hello world!\\n)") and hit enter, like this:])
  49. (frame
  50. (prog :line #f
  51. "scheme@(guile-user)> (display \"Hello world!\\n\")
  52. Hello world!
  53. scheme@(guile-user)> "))
  54. (p [Excellent!
  55. You just wrote your first piece of Guile code!])
  56. (p [Now you might be wondering, how do I get out of this thing?
  57. You can type ,(code "(quit)") to quit.
  58. (Or, if you want to be a bit more fancy and hit two buttons at once,
  59. you can press ,(code [Ctrl-d]) instead.)])
  60. (p [This fancy "enter code and experiment with it" thing is called
  61. Guile's "REPL" (Read Eval Print Loop) and is a great way to experiment
  62. with code.]))
  63. (section
  64. :title [Making your life easier: readline and editor friends]
  65. (p [Two more things.
  66. These aren't required to continue with this tutorial, but they will
  67. make it much more pleasant.
  68. The first is that you may want to
  69. ,(ref :url [https://www.gnu.org/software/guile/manual/html_node/Loading-Readline-Support.html#Loading-Readline-Support]
  70. :text [add readline support])
  71. to your REPL.
  72. This will make playing around much nicer, because you can now
  73. keep a "history" of commands around.])
  74. (p [You also might build up some fun toys while running through this
  75. tutorial.
  76. You might want to play with them and re-use them without having
  77. to type them in all over again.
  78. This is where your text editor comes into play!
  79. Try opening a new file, we'll call it "sandbox.scm".
  80. When you build something in this tutorial you'd like to use
  81. over and over again without retyping it between REPL sessions,
  82. you can put it here.
  83. Let's try putting something there now:])
  84. (frame
  85. (prog :line #f
  86. "(define my-friends 'your-friends)"))
  87. (p [Now start up ,(code [guile]) again, in the same directory
  88. as your "sandbox.scm" file.
  89. We can use a nifty tool called ,(code [load]) to pull toys
  90. from our sandbox file into our REPL.
  91. Let's try it!])
  92. (frame
  93. (prog :line #f
  94. "scheme@(guile-user)> (load \"sandbox.scm\")
  95. sheme@(guile-user)> my-friends
  96. $1 = your-friends"))
  97. (p [It looks like it worked!
  98. We also see that my friends are your friends.
  99. We're all friends here!])
  100. (p [Note the ,(code "$1 = your-friends") line.
  101. When at the REPL, you can refer to the value you got back by
  102. making use of this number again:])
  103. (frame
  104. (prog :line #f
  105. "scheme@(guile-user)> $1
  106. $2 = your-friends"))
  107. (p [However, for the rest of the tutorial, we'll be dropping the
  108. dollar-sign-number pattern and showing things like this,
  109. just so we don't have to keep track of numbers:])
  110. (frame
  111. (prog :line #f
  112. "scheme@(guile-user)> (+ 1 2)
  113. ;; => 3"))
  114. (p [... which of course means you got 3 back as a result.])
  115. (p [Okay, that's enough setting things up.
  116. We have our sandbox, we're in our REPL playground.
  117. Lets break out the toys and have some fun!]))