Skip to content

Conversation

@codingbum
Copy link

A few snippets for the Racket programming language.

@AndreaCrotti
Copy link
Owner

Looks good but I'm not super convinced by having snippets that take the body as well.
I mean suppose you write quite a long cond with a lot options, you would have to write everything still while expanding the snippet.
I would rather simply have $0 be the body, so at that point you write the more bulky part you expanded the whole snippet already.

What do you think @codingbum ?

@codingbum
Copy link
Author

codingbum commented Apr 20, 2018

I did set $0 as the body but i am not sure about the do-loop snippet which is now

(do ([${1:name} ${2:init} ${3:step}]$4) (${5:stop-predicate} ${6:finish}) $0)

# name: (for... (...) ...)
# key: for
# --
(for$1 (${2:for-clause}) $0) No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the $1 just next to the for here?
Does it mean you might want to add something to "for"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because racket has a multitude of for/...

(for/list ...) ;; build a list
(for/vector ...) ;; build a vector
(for/sum ...) ;; sum
(for/and ...) ;; checks if all iterations return (not #f)
...

https://docs.racket-lang.org/reference/for.html?q=for#%28part._.Iteration_and_.Comprehension_.Forms%29

@AndreaCrotti
Copy link
Owner

Well don't see why not, what's the problem with the $0 there in the do loop @codingbum ?
One slight issue for me is that some of these snippets have way too much stuff to expand in general, for example the do loop just mentioned has 6 things to expand.

I don't think there is a "rule" for this but normally most snippets involve maximum 3-4 tabs..
It would be nice to stay around that, even if it means the snippet is a bit less precise, but the important thing after all is to give a good skeleton not to help you write everything imho.

@AndreaCrotti AndreaCrotti added the seen PR was seen and initial feedback was given label Apr 21, 2018
@codingbum
Copy link
Author

# name: (do ([... ... ...]...) (... ...) ...)
# key: do
# --
(do ([${1:name} ${2:init} ${3:step}]$4)
Copy link
Owner

@AndreaCrotti AndreaCrotti Apr 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm yeah I think that 7 expansions is way too much, I would just do something like

(do ([$1] $2)
         ($3)
     $0)

(with the appropriate placeholder names)
Would that make sense?

@AndreaCrotti
Copy link
Owner

Ok I tried the snippets again and I think it's fine, we can keep also the do as it is..
Thanks!

@AndreaCrotti AndreaCrotti merged commit 796a316 into AndreaCrotti:master Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

seen PR was seen and initial feedback was given

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants