startup-in-a-month

https://www.twitch.tv/a_fry_
bringe 2021-01-27T20:57:53.007700Z

@andyfry01 Love to see your use of the comment form! It really is like a notebook where you can just try things out, come back to it later, and build things up.

bringe 2021-01-27T21:00:33.009Z

Inside the comment forms in Calva, you can have your cursor anywhere inside a form and hit alt+enter (but the Mac equivalent) to evaluate, so no need to put your cursor at the beginning/end of the form to evaluate (not sure if that was done in the latest stream).

bringe 2021-01-27T21:01:38.010100Z

Another tip - you can refactor this use of swap! to be something like (swap! app-state random-food 0) if you switch the args around to random-food.

pez 2021-01-27T21:01:45.010500Z

alt+enter on Mac as well.

2021-01-28T12:30:03.018800Z

Ah, that's a really interesting way to think about comment: a new top-level context. Like a namespace inside a namespace, where you can get the advantage of using all of the other vars which are defined in the parent namespace, but you don't have to worry about anything in the comment form interfering with the parent namespace. I can dig that. Block scoped variables in ES6 Javascript is the parallel that springs to mind right away:

const parentNamespace = () => {
    const variable = "Hello from the outer context"

    const richComment = () => {
        const variable = "Hello from the inner context"
        console.log(variable) 
    }
    
    richComment() // -> "Hello from the inner context"
    console.log(variable)
}

parentNamespace() // -> "Hello from the outer context"

2021-01-28T12:32:54.019Z

And yeah, I can see the benefit of defining and loading individual vars within a comment form as opposed to loading the whole comment form all at once. I'll give that do thing a try when I've got some setup code that I want to run all at once.

2021-01-28T12:34:33.019200Z

You guys have been invaluable this month for my Clojure growing pains 😅 Thanks so much for all of the tips, it's really improving my workflow

pez 2021-01-28T12:52:48.019400Z

You are most welcome, sir!

pez 2021-01-28T12:55:40.019600Z

About namespacing. Note that this is only a structural thing regarding the text in the file. When you evaluate something in the comment block it will both be “from” the same namespace as the file and “to” the same namespace. So hey will be defined in the file’s namespace. Don’t know if you meant anything else, but just in case. 😃

pez 2021-01-28T12:56:41.019800Z

Looking at your ES6 example it seems like my clarification was needed. Haha.

pez 2021-01-28T12:59:37.020Z

Clojure has global bindings that can be scoped by namespaces, and local bindings that are lexically scoped, much like the ES6 example there.

bringe 2021-01-28T19:56:15.020200Z

> the thing is that if we didn’t treat `comment` forms special at all what would be evaluated is the whole `comment` form (not just it’s content) and that would give you `nil`. Just to clarify here, and maybe Peter meant this, but if the whole comment form is evaluated, the result is nil and none of the forms inside it are evaluated.

1➕
bringe 2021-01-28T19:56:53.020400Z

So if you have defs in there and they haven't been evaluated, and you evaluate the whole comment form, those vars will still not be defined.

1➕
bringe 2021-01-27T21:02:11.010600Z

Oh, I thought alt was something else on Mac, is it not?

bringe 2021-01-27T21:02:59.011500Z

The function passed to swap! will receive the value of the atom as its first param

pez 2021-01-27T21:03:59.011700Z

It is sometimes/often labeled option, but it is aka alt.

1👍
pez 2021-01-27T21:04:54.012Z

This has confused some Mac users, because they do not find the alt key on their keyboards. So it is good to be aware of.

bringe 2021-01-27T21:08:00.012600Z

Also, that issue with Calva asking for the nrepl port at jack-in should be fixed soon

1👍
pez 2021-01-27T21:09:16.012900Z

Yeah. I just merged the the PR: https://github.com/BetterThanTomorrow/calva/pull/972

2021-01-27T23:28:50.015Z

@brandon.ringe The comment form has been revolutionary for me! I've got a few of them already in the file I was working in today. You did indeed guess it: they're all laid out like little scratch pads where I can define a bunch of variables and functions and experiment around with them, and I can isolate different ideas inside the scopes of each comment.

2021-01-27T23:30:04.015300Z

I've been a mac user for ... a while, and to this day I get mixed up with what keys are to be found on which keyboards 😛

2021-01-27T23:30:38.015500Z

It gets especially weird when apps start swapping around control with command

2021-01-27T23:35:44.015900Z

I was actually trying out option+enter (windows equivalent: alt+enter earlier today. I was trying to use that to load the whole comment block, vars and all, into the REPL. There may be a bug, or maybe I don't understand the command fully, but if I try it with this code for example, I get Unable to resolve symbol: hey in this context

(comment
    (def hey "hey")
    (def wat "wat")
    (str hey wat))

2021-01-27T23:36:13.016100Z

Thus requiring me to go through each form, load it into the REPL, and then evaluate (str hey wat) at the end.