Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Command for evaluating top level form to comment #349

Closed
PEZ opened this issue Sep 26, 2019 · 0 comments
Closed

[Feature Request] Command for evaluating top level form to comment #349

PEZ opened this issue Sep 26, 2019 · 0 comments

Comments

@PEZ
Copy link
Collaborator

@PEZ PEZ commented Sep 26, 2019

To better support the Design Journal suggested in this REPL Driven Development Guide, Calva should make it easy to evaluate the top level form and add the result as a ;; comment.

Here's the Documentation First:

Evaluate to comment

Calva has two commands for evaluating code and add as a comment in the file being edited:

  1. Evaluate current form, and append a comment with the result, ctrl+alt+c, c
  2. Evaluate current top level form, and append a comment with the result, ctrl+alt+c, ctrl+space

As with all commands for evaluating the top level form, they also work inside (comment) forms. This makes it smooth to build a Design Journal like this at the end of your file:

(comment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; REPL Experiments
;;;;;;;;;;;;;;;;;;;;;;;;
;; Generating a data structure to represet the game board
  
;; We could just hard code the board as follows, although that limits us to a specific size of board:
  [[:empty :empty :empty]
   [:empty :empty :empty]
   [:empty :empty :empty]]

;; To create a row is simple to do using the repeat function to generate 3 :empty keywords and return them as a list
  (repeat 3 :empty)
;; => (:empty :empty :empty)
  
;; To make this a vector we can just wrap that in a vec function
  (vec (repeat 3 :empty))
;; => [:empty :empty :empty]
  
;; To create three rows we just repeat the code above 3 times
  
  (vec (repeat 3 (vec (repeat 3 :empty))))
;; => [[:empty :empty :empty] [:empty :empty :empty] [:empty :empty :empty]]
  
;; And so on, and so forth
  ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.